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 bool UniqueDWARFASTTypeList::Find(const DWARFDIE &die,
19 const lldb_private::Declaration &decl,
20 const int32_t byte_size,
21 UniqueDWARFASTType &entry) const {
22 for (const UniqueDWARFASTType &udt : m_collection) {
23 // Make sure the tags match
24 if (udt.m_die.Tag() == die.Tag()) {
25 // Validate byte sizes of both types only if both are valid.
26 if (udt.m_byte_size < 0 || byte_size < 0 ||
27 udt.m_byte_size == byte_size) {
28 // Make sure the file and line match
29 if (udt.m_declaration == decl) {
30 // The type has the same name, and was defined on the same
31 // file and line. Now verify all of the parent DIEs match.
32 DWARFDIE parent_arg_die = die.GetParent();
33 DWARFDIE parent_pos_die = udt.m_die.GetParent();
36 while (!done && match && parent_arg_die && parent_pos_die) {
37 const dw_tag_t parent_arg_tag = parent_arg_die.Tag();
38 const dw_tag_t parent_pos_tag = parent_pos_die.Tag();
39 if (parent_arg_tag == parent_pos_tag) {
40 switch (parent_arg_tag) {
41 case DW_TAG_class_type:
42 case DW_TAG_structure_type:
43 case DW_TAG_union_type:
44 case DW_TAG_namespace: {
45 const char *parent_arg_die_name = parent_arg_die.GetName();
46 if (parent_arg_die_name ==
47 NULL) // Anonymous (i.e. no-name) struct
51 const char *parent_pos_die_name = parent_pos_die.GetName();
52 if (parent_pos_die_name == NULL ||
53 ((parent_arg_die_name != parent_pos_die_name) &&
54 strcmp(parent_arg_die_name, parent_pos_die_name)))
59 case DW_TAG_compile_unit:
64 parent_arg_die = parent_arg_die.GetParent();
65 parent_pos_die = parent_pos_die.GetParent();