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"
18 #include "DWARFDebugInfoEntry.h"
21 UniqueDWARFASTTypeList::Find
23 SymbolFileDWARF *symfile,
24 const DWARFCompileUnit *cu,
25 const DWARFDebugInfoEntry *die,
26 const lldb_private::Declaration &decl,
27 const int32_t byte_size,
28 UniqueDWARFASTType &entry
31 collection::const_iterator pos, end = m_collection.end();
32 for (pos = m_collection.begin(); pos != end; ++pos)
34 // Make sure the tags match
35 if (pos->m_die->Tag() == die->Tag())
37 // Validate byte sizes of both types only if both are valid.
38 if (pos->m_byte_size < 0 || byte_size < 0 || pos->m_byte_size == byte_size)
40 // Make sure the file and line match
41 if (pos->m_declaration == decl)
43 // The type has the same name, and was defined on the same
44 // file and line. Now verify all of the parent DIEs match.
45 const DWARFDebugInfoEntry *parent_arg_die = die->GetParent();
46 const DWARFDebugInfoEntry *parend_pos_die = pos->m_die->GetParent();
49 while (!done && match && parent_arg_die && parend_pos_die)
51 if (parent_arg_die->Tag() == parend_pos_die->Tag())
53 const dw_tag_t tag = parent_arg_die->Tag();
56 case DW_TAG_class_type:
57 case DW_TAG_structure_type:
58 case DW_TAG_union_type:
59 case DW_TAG_namespace:
61 const char *parent_arg_die_name = parent_arg_die->GetName(symfile, cu);
62 if (parent_arg_die_name == NULL) // Anonymous (i.e. no-name) struct
68 const char *parent_pos_die_name = parend_pos_die->GetName(pos->m_symfile, pos->m_cu);
69 if (parent_pos_die_name == NULL || strcmp (parent_arg_die_name, parent_pos_die_name))
75 case DW_TAG_compile_unit:
80 parent_arg_die = parent_arg_die->GetParent();
81 parend_pos_die = parend_pos_die->GetParent();