1 //===-- UniqueDWARFASTType.cpp ----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "UniqueDWARFASTType.h"
14 // Other libraries and framework includes
16 #include "lldb/Symbol/Declaration.h"
19 UniqueDWARFASTTypeList::Find (const DWARFDIE &die,
20 const lldb_private::Declaration &decl,
21 const int32_t byte_size,
22 UniqueDWARFASTType &entry) const
24 for (const UniqueDWARFASTType &udt : m_collection)
26 // Make sure the tags match
27 if (udt.m_die.Tag() == die.Tag())
29 // Validate byte sizes of both types only if both are valid.
30 if (udt.m_byte_size < 0 || byte_size < 0 || udt.m_byte_size == byte_size)
32 // Make sure the file and line match
33 if (udt.m_declaration == decl)
35 // The type has the same name, and was defined on the same
36 // file and line. Now verify all of the parent DIEs match.
37 DWARFDIE parent_arg_die = die.GetParent();
38 DWARFDIE parent_pos_die = udt.m_die.GetParent();
41 while (!done && match && parent_arg_die && parent_pos_die)
43 const dw_tag_t parent_arg_tag = parent_arg_die.Tag();
44 const dw_tag_t parent_pos_tag = parent_pos_die.Tag();
45 if (parent_arg_tag == parent_pos_tag)
47 switch (parent_arg_tag)
49 case DW_TAG_class_type:
50 case DW_TAG_structure_type:
51 case DW_TAG_union_type:
52 case DW_TAG_namespace:
54 const char *parent_arg_die_name = parent_arg_die.GetName();
55 if (parent_arg_die_name == NULL) // Anonymous (i.e. no-name) struct
61 const char *parent_pos_die_name = parent_pos_die.GetName();
62 if (parent_pos_die_name == NULL || ((parent_arg_die_name != parent_pos_die_name) && strcmp (parent_arg_die_name, parent_pos_die_name)))
68 case DW_TAG_compile_unit:
73 parent_arg_die = parent_arg_die.GetParent();
74 parent_pos_die = parent_pos_die.GetParent();