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#include "lldb/Symbol/Type.h"
19
20namespace lldb_private::plugin {
21namespace dwarf {
23public:
24 // Constructors and Destructors
26
28 : m_type_sp(rhs.m_type_sp), m_die(rhs.m_die),
31
33
34 // This UniqueDWARFASTType might be created from declaration, update its info
35 // to definition DIE.
36 void UpdateToDefDIE(const DWARFDIE &def_die, Declaration &declaration,
37 int32_t byte_size) {
38 // Need to update Type ID to refer to the definition DIE, because
39 // it's used in DWARFASTParserClang::ParseCXXMethod to determine if we need
40 // to copy cxx method types from a declaration DIE to this definition DIE.
41 m_type_sp->SetID(def_die.GetID());
42 if (declaration.IsValid())
43 m_declaration = declaration;
44 if (byte_size)
45 m_byte_size = byte_size;
47 }
48
52 int32_t m_byte_size = -1;
53 // True if the m_die is a forward declaration DIE.
55};
56
58public:
60
62
63 uint32_t GetSize() { return (uint32_t)m_collection.size(); }
64
65 void Append(const UniqueDWARFASTType &entry) {
66 m_collection.push_back(entry);
67 }
68
69 UniqueDWARFASTType *Find(const DWARFDIE &die, const Declaration &decl,
70 const int32_t byte_size,
71 bool is_forward_declaration);
72
73protected:
74 typedef std::vector<UniqueDWARFASTType> collection;
76};
77
79public:
81
83
84 void Insert(ConstString name, const UniqueDWARFASTType &entry) {
85 m_collection[name.GetCString()].Append(entry);
86 }
87
89 const Declaration &decl, const int32_t byte_size,
90 bool is_forward_declaration) {
91 const char *unique_name_cstr = name.GetCString();
92 collection::iterator pos = m_collection.find(unique_name_cstr);
93 if (pos != m_collection.end()) {
94 return pos->second.Find(die, decl, byte_size, is_forward_declaration);
95 }
96 return nullptr;
97 }
98
99protected:
100 // A unique name string should be used
101 typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection;
103};
104} // namespace dwarf
105} // namespace lldb_private::plugin
106
107#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:216
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
UniqueDWARFASTType * Find(const DWARFDIE &die, const Declaration &decl, const int32_t byte_size, bool is_forward_declaration)
void Append(const UniqueDWARFASTType &entry)
llvm::DenseMap< const char *, UniqueDWARFASTTypeList > collection
UniqueDWARFASTType * Find(ConstString name, const DWARFDIE &die, const Declaration &decl, const int32_t byte_size, bool is_forward_declaration)
void Insert(ConstString name, const UniqueDWARFASTType &entry)
UniqueDWARFASTType(const UniqueDWARFASTType &rhs)
void UpdateToDefDIE(const DWARFDIE &def_die, Declaration &declaration, int32_t byte_size)
std::shared_ptr< lldb_private::Type > TypeSP
Definition: lldb-forward.h:456