/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- UniqueDWARFASTType.cpp --------------------------------------------===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | |
9 | | #include "UniqueDWARFASTType.h" |
10 | | |
11 | | #include "lldb/Core/Declaration.h" |
12 | | |
13 | | using namespace lldb_private::dwarf; |
14 | | using namespace lldb_private::plugin::dwarf; |
15 | | |
16 | | bool UniqueDWARFASTTypeList::Find(const DWARFDIE &die, |
17 | | const lldb_private::Declaration &decl, |
18 | | const int32_t byte_size, |
19 | 74 | UniqueDWARFASTType &entry) const { |
20 | 74 | for (const UniqueDWARFASTType &udt : m_collection) { |
21 | | // Make sure the tags match |
22 | 74 | if (udt.m_die.Tag() == die.Tag()) { |
23 | | // Validate byte sizes of both types only if both are valid. |
24 | 74 | if (udt.m_byte_size < 0 || byte_size < 0 || |
25 | 74 | udt.m_byte_size == byte_size72 ) { |
26 | | // Make sure the file and line match |
27 | 35 | if (udt.m_declaration == decl) { |
28 | | // The type has the same name, and was defined on the same file and |
29 | | // line. Now verify all of the parent DIEs match. |
30 | 35 | DWARFDIE parent_arg_die = die.GetParent(); |
31 | 35 | DWARFDIE parent_pos_die = udt.m_die.GetParent(); |
32 | 35 | bool match = true; |
33 | 35 | bool done = false; |
34 | 70 | while (!done && match37 && parent_arg_die37 && parent_pos_die36 ) { |
35 | 35 | const dw_tag_t parent_arg_tag = parent_arg_die.Tag(); |
36 | 35 | const dw_tag_t parent_pos_tag = parent_pos_die.Tag(); |
37 | 35 | if (parent_arg_tag == parent_pos_tag) { |
38 | 33 | switch (parent_arg_tag) { |
39 | 0 | case DW_TAG_class_type: |
40 | 0 | case DW_TAG_structure_type: |
41 | 0 | case DW_TAG_union_type: |
42 | 0 | case DW_TAG_namespace: { |
43 | 0 | const char *parent_arg_die_name = parent_arg_die.GetName(); |
44 | 0 | if (parent_arg_die_name == |
45 | 0 | nullptr) // Anonymous (i.e. no-name) struct |
46 | 0 | { |
47 | 0 | match = false; |
48 | 0 | } else { |
49 | 0 | const char *parent_pos_die_name = parent_pos_die.GetName(); |
50 | 0 | if (parent_pos_die_name == nullptr || |
51 | 0 | ((parent_arg_die_name != parent_pos_die_name) && |
52 | 0 | strcmp(parent_arg_die_name, parent_pos_die_name))) |
53 | 0 | match = false; |
54 | 0 | } |
55 | 0 | } break; |
56 | | |
57 | 33 | case DW_TAG_compile_unit: |
58 | 33 | case DW_TAG_partial_unit: |
59 | 33 | done = true; |
60 | 33 | break; |
61 | 0 | default: |
62 | 0 | break; |
63 | 33 | } |
64 | 33 | } |
65 | 35 | parent_arg_die = parent_arg_die.GetParent(); |
66 | 35 | parent_pos_die = parent_pos_die.GetParent(); |
67 | 35 | } |
68 | | |
69 | 35 | if (match) { |
70 | 35 | entry = udt; |
71 | 35 | return true; |
72 | 35 | } |
73 | 35 | } |
74 | 35 | } |
75 | 74 | } |
76 | 74 | } |
77 | 39 | return false; |
78 | 74 | } |