UniqueDWARFASTType.cpp revision 341825
1//===-- UniqueDWARFASTType.cpp ----------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#include "UniqueDWARFASTType.h" 11 12// C Includes 13// C++ Includes 14// Other libraries and framework includes 15// Project includes 16#include "lldb/Symbol/Declaration.h" 17 18bool 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 file and 31 // 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(); 34 bool match = true; 35 bool done = false; 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 48 { 49 match = false; 50 } else { 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))) 55 match = false; 56 } 57 } break; 58 59 case DW_TAG_compile_unit: 60 case DW_TAG_partial_unit: 61 done = true; 62 break; 63 } 64 } 65 parent_arg_die = parent_arg_die.GetParent(); 66 parent_pos_die = parent_pos_die.GetParent(); 67 } 68 69 if (match) { 70 entry = udt; 71 return true; 72 } 73 } 74 } 75 } 76 } 77 return false; 78} 79