Coverage Report

Created: 2022-01-22 13:19

/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
bool UniqueDWARFASTTypeList::Find(const DWARFDIE &die,
14
                                  const lldb_private::Declaration &decl,
15
                                  const int32_t byte_size,
16
40
                                  UniqueDWARFASTType &entry) const {
17
40
  for (const UniqueDWARFASTType &udt : m_collection) {
18
    // Make sure the tags match
19
40
    if (udt.m_die.Tag() == die.Tag()) {
20
      // Validate byte sizes of both types only if both are valid.
21
40
      if (udt.m_byte_size < 0 || byte_size < 0 ||
22
40
          udt.m_byte_size == byte_size) {
23
        // Make sure the file and line match
24
31
        if (udt.m_declaration == decl) {
25
          // The type has the same name, and was defined on the same file and
26
          // line. Now verify all of the parent DIEs match.
27
31
          DWARFDIE parent_arg_die = die.GetParent();
28
31
          DWARFDIE parent_pos_die = udt.m_die.GetParent();
29
31
          bool match = true;
30
31
          bool done = false;
31
82
          while (!done && 
match53
&&
parent_arg_die53
&&
parent_pos_die52
) {
32
51
            const dw_tag_t parent_arg_tag = parent_arg_die.Tag();
33
51
            const dw_tag_t parent_pos_tag = parent_pos_die.Tag();
34
51
            if (parent_arg_tag == parent_pos_tag) {
35
49
              switch (parent_arg_tag) {
36
0
              case DW_TAG_class_type:
37
0
              case DW_TAG_structure_type:
38
0
              case DW_TAG_union_type:
39
12
              case DW_TAG_namespace: {
40
12
                const char *parent_arg_die_name = parent_arg_die.GetName();
41
12
                if (parent_arg_die_name ==
42
12
                    nullptr) // Anonymous (i.e. no-name) struct
43
0
                {
44
0
                  match = false;
45
12
                } else {
46
12
                  const char *parent_pos_die_name = parent_pos_die.GetName();
47
12
                  if (parent_pos_die_name == nullptr ||
48
12
                      ((parent_arg_die_name != parent_pos_die_name) &&
49
12
                       
strcmp(parent_arg_die_name, parent_pos_die_name)0
))
50
0
                    match = false;
51
12
                }
52
12
              } break;
53
54
29
              case DW_TAG_compile_unit:
55
29
              case DW_TAG_partial_unit:
56
29
                done = true;
57
29
                break;
58
8
              default:
59
8
                break;
60
49
              }
61
49
            }
62
51
            parent_arg_die = parent_arg_die.GetParent();
63
51
            parent_pos_die = parent_pos_die.GetParent();
64
51
          }
65
66
31
          if (match) {
67
31
            entry = udt;
68
31
            return true;
69
31
          }
70
31
        }
71
31
      }
72
40
    }
73
40
  }
74
9
  return false;
75
40
}