LLDB mainline
UniqueDWARFASTType.h
Go to the documentation of this file.
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"
18
19namespace lldb_private::plugin {
20namespace dwarf {
22public:
23 // Constructors and Destructors
25
27 const Declaration &decl, int32_t byte_size)
28 : m_type_sp(type_sp), m_die(die), m_declaration(decl),
29 m_byte_size(byte_size) {}
30
32 : m_type_sp(rhs.m_type_sp), m_die(rhs.m_die),
34
36
38 if (this != &rhs) {
39 m_type_sp = rhs.m_type_sp;
40 m_die = rhs.m_die;
43 }
44 return *this;
45 }
46
50 int32_t m_byte_size = -1;
51};
52
54public:
56
58
59 uint32_t GetSize() { return (uint32_t)m_collection.size(); }
60
61 void Append(const UniqueDWARFASTType &entry) {
62 m_collection.push_back(entry);
63 }
64
65 bool Find(const DWARFDIE &die, const Declaration &decl,
66 const int32_t byte_size, UniqueDWARFASTType &entry) const;
67
68protected:
69 typedef std::vector<UniqueDWARFASTType> collection;
71};
72
74public:
76
78
79 void Insert(ConstString name, const UniqueDWARFASTType &entry) {
80 m_collection[name.GetCString()].Append(entry);
81 }
82
83 bool Find(ConstString name, const DWARFDIE &die, const Declaration &decl,
84 const int32_t byte_size, UniqueDWARFASTType &entry) const {
85 const char *unique_name_cstr = name.GetCString();
86 collection::const_iterator pos = m_collection.find(unique_name_cstr);
87 if (pos != m_collection.end()) {
88 return pos->second.Find(die, decl, byte_size, entry);
89 }
90 return false;
91 }
92
93protected:
94 // A unique name string should be used
95 typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection;
97};
98} // namespace dwarf
99} // namespace lldb_private::plugin
100
101#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_UNIQUEDWARFASTTYPE_H
A uniqued constant string class.
Definition: ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:214
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
void Append(const UniqueDWARFASTType &entry)
bool Find(const DWARFDIE &die, const Declaration &decl, const int32_t byte_size, UniqueDWARFASTType &entry) const
llvm::DenseMap< const char *, UniqueDWARFASTTypeList > collection
void Insert(ConstString name, const UniqueDWARFASTType &entry)
bool Find(ConstString name, const DWARFDIE &die, const Declaration &decl, const int32_t byte_size, UniqueDWARFASTType &entry) const
UniqueDWARFASTType(lldb::TypeSP &type_sp, const DWARFDIE &die, const Declaration &decl, int32_t byte_size)
UniqueDWARFASTType(const UniqueDWARFASTType &rhs)
UniqueDWARFASTType & operator=(const UniqueDWARFASTType &rhs)
std::shared_ptr< lldb_private::Type > TypeSP
Definition: lldb-forward.h:449