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"
12 #include "lldb/Symbol/Declaration.h"
14 bool UniqueDWARFASTTypeList::Find(const DWARFDIE &die,
15 const lldb_private::Declaration &decl,
16 const int32_t byte_size,
17 UniqueDWARFASTType &entry) const {
18 for (const UniqueDWARFASTType &udt : m_collection) {
19 // Make sure the tags match
20 if (udt.m_die.Tag() == die.Tag()) {
21 // Validate byte sizes of both types only if both are valid.
22 if (udt.m_byte_size < 0 || byte_size < 0 ||
23 udt.m_byte_size == byte_size) {
24 // Make sure the file and line match
25 if (udt.m_declaration == decl) {
26 // The type has the same name, and was defined on the same file and
27 // line. Now verify all of the parent DIEs match.
28 DWARFDIE parent_arg_die = die.GetParent();
29 DWARFDIE parent_pos_die = udt.m_die.GetParent();
32 while (!done && match && parent_arg_die && parent_pos_die) {
33 const dw_tag_t parent_arg_tag = parent_arg_die.Tag();
34 const dw_tag_t parent_pos_tag = parent_pos_die.Tag();
35 if (parent_arg_tag == parent_pos_tag) {
36 switch (parent_arg_tag) {
37 case DW_TAG_class_type:
38 case DW_TAG_structure_type:
39 case DW_TAG_union_type:
40 case DW_TAG_namespace: {
41 const char *parent_arg_die_name = parent_arg_die.GetName();
42 if (parent_arg_die_name ==
43 NULL) // Anonymous (i.e. no-name) struct
47 const char *parent_pos_die_name = parent_pos_die.GetName();
48 if (parent_pos_die_name == NULL ||
49 ((parent_arg_die_name != parent_pos_die_name) &&
50 strcmp(parent_arg_die_name, parent_pos_die_name)))
55 case DW_TAG_compile_unit:
56 case DW_TAG_partial_unit:
61 parent_arg_die = parent_arg_die.GetParent();
62 parent_pos_die = parent_pos_die.GetParent();