Coverage Report

Created: 2022-01-22 13:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
Line
Count
Source (jump to first uncovered line)
1
//===-- UniqueDWARFASTType.h ------------------------------------*- C++ -*-===//
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
#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_UNIQUEDWARFASTTYPE_H
10
#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_UNIQUEDWARFASTTYPE_H
11
12
#include <vector>
13
14
#include "llvm/ADT/DenseMap.h"
15
16
#include "DWARFDIE.h"
17
#include "lldb/Core/Declaration.h"
18
19
class UniqueDWARFASTType {
20
public:
21
  // Constructors and Destructors
22
14.4k
  UniqueDWARFASTType() : m_type_sp(), m_die(), m_declaration() {}
23
24
  UniqueDWARFASTType(lldb::TypeSP &type_sp, const DWARFDIE &die,
25
                     const lldb_private::Declaration &decl, int32_t byte_size)
26
      : m_type_sp(type_sp), m_die(die), m_declaration(decl),
27
0
        m_byte_size(byte_size) {}
28
29
  UniqueDWARFASTType(const UniqueDWARFASTType &rhs)
30
      : m_type_sp(rhs.m_type_sp), m_die(rhs.m_die),
31
19.0k
        m_declaration(rhs.m_declaration), m_byte_size(rhs.m_byte_size) {}
32
33
33.3k
  ~UniqueDWARFASTType() = default;
34
35
31
  UniqueDWARFASTType &operator=(const UniqueDWARFASTType &rhs) {
36
31
    if (this != &rhs) {
37
31
      m_type_sp = rhs.m_type_sp;
38
31
      m_die = rhs.m_die;
39
31
      m_declaration = rhs.m_declaration;
40
31
      m_byte_size = rhs.m_byte_size;
41
31
    }
42
31
    return *this;
43
31
  }
44
45
  lldb::TypeSP m_type_sp;
46
  DWARFDIE m_die;
47
  lldb_private::Declaration m_declaration;
48
  int32_t m_byte_size = -1;
49
};
50
51
class UniqueDWARFASTTypeList {
52
public:
53
13.6k
  UniqueDWARFASTTypeList() : m_collection() {}
54
55
18.3k
  ~UniqueDWARFASTTypeList() = default;
56
57
0
  uint32_t GetSize() { return (uint32_t)m_collection.size(); }
58
59
13.8k
  void Append(const UniqueDWARFASTType &entry) {
60
13.8k
    m_collection.push_back(entry);
61
13.8k
  }
62
63
  bool Find(const DWARFDIE &die, const lldb_private::Declaration &decl,
64
            const int32_t byte_size, UniqueDWARFASTType &entry) const;
65
66
protected:
67
  typedef std::vector<UniqueDWARFASTType> collection;
68
  collection m_collection;
69
};
70
71
class UniqueDWARFASTTypeMap {
72
public:
73
276k
  UniqueDWARFASTTypeMap() : m_collection() {}
74
75
276k
  ~UniqueDWARFASTTypeMap() = default;
76
77
  void Insert(lldb_private::ConstString name,
78
13.8k
              const UniqueDWARFASTType &entry) {
79
13.8k
    m_collection[name.GetCString()].Append(entry);
80
13.8k
  }
81
82
  bool Find(lldb_private::ConstString name, const DWARFDIE &die,
83
            const lldb_private::Declaration &decl, const int32_t byte_size,
84
14.0k
            UniqueDWARFASTType &entry) const {
85
14.0k
    const char *unique_name_cstr = name.GetCString();
86
14.0k
    collection::const_iterator pos = m_collection.find(unique_name_cstr);
87
14.0k
    if (pos != m_collection.end()) {
88
40
      return pos->second.Find(die, decl, byte_size, entry);
89
40
    }
90
13.9k
    return false;
91
14.0k
  }
92
93
protected:
94
  // A unique name string should be used
95
  typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection;
96
  collection m_collection;
97
};
98
99
#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_UNIQUEDWARFASTTYPE_H