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"
17 #include "lldb/Core/Declaration.h"
18 
20 public:
21  // Constructors and Destructors
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  m_byte_size(byte_size) {}
28 
30  : m_type_sp(rhs.m_type_sp), m_die(rhs.m_die),
32 
33  ~UniqueDWARFASTType() = default;
34 
36  if (this != &rhs) {
37  m_type_sp = rhs.m_type_sp;
38  m_die = rhs.m_die;
41  }
42  return *this;
43  }
44 
45  lldb::TypeSP m_type_sp;
48  int32_t m_byte_size = -1;
49 };
50 
52 public:
54 
55  ~UniqueDWARFASTTypeList() = default;
56 
57  uint32_t GetSize() { return (uint32_t)m_collection.size(); }
58 
59  void Append(const UniqueDWARFASTType &entry) {
60  m_collection.push_back(entry);
61  }
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;
69 };
70 
72 public:
74 
75  ~UniqueDWARFASTTypeMap() = default;
76 
78  const UniqueDWARFASTType &entry) {
79  m_collection[name.GetCString()].Append(entry);
80  }
81 
82  bool Find(lldb_private::ConstString name, const DWARFDIE &die,
83  const lldb_private::Declaration &decl, const int32_t byte_size,
84  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 
93 protected:
94  // A unique name string should be used
95  typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection;
97 };
98 
99 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_UNIQUEDWARFASTTYPE_H
UniqueDWARFASTTypeList
Definition: UniqueDWARFASTType.h:51
UniqueDWARFASTType::m_byte_size
int32_t m_byte_size
Definition: UniqueDWARFASTType.h:48
UniqueDWARFASTType::UniqueDWARFASTType
UniqueDWARFASTType(const UniqueDWARFASTType &rhs)
Definition: UniqueDWARFASTType.h:29
UniqueDWARFASTType::UniqueDWARFASTType
UniqueDWARFASTType()
Definition: UniqueDWARFASTType.h:22
UniqueDWARFASTTypeList::GetSize
uint32_t GetSize()
Definition: UniqueDWARFASTType.h:57
DWARFDIE.h
UniqueDWARFASTTypeList::UniqueDWARFASTTypeList
UniqueDWARFASTTypeList()
Definition: UniqueDWARFASTType.h:53
UniqueDWARFASTTypeList::Append
void Append(const UniqueDWARFASTType &entry)
Definition: UniqueDWARFASTType.h:59
UniqueDWARFASTType
Definition: UniqueDWARFASTType.h:19
UniqueDWARFASTTypeList::Find
bool Find(const DWARFDIE &die, const lldb_private::Declaration &decl, const int32_t byte_size, UniqueDWARFASTType &entry) const
Definition: UniqueDWARFASTType.cpp:13
UniqueDWARFASTTypeList::collection
std::vector< UniqueDWARFASTType > collection
Definition: UniqueDWARFASTType.h:67
UniqueDWARFASTTypeMap::collection
llvm::DenseMap< const char *, UniqueDWARFASTTypeList > collection
Definition: UniqueDWARFASTType.h:95
DWARFDIE
Definition: DWARFDIE.h:16
UniqueDWARFASTType::m_die
DWARFDIE m_die
Definition: UniqueDWARFASTType.h:46
UniqueDWARFASTTypeList::~UniqueDWARFASTTypeList
~UniqueDWARFASTTypeList()=default
UniqueDWARFASTTypeMap::UniqueDWARFASTTypeMap
UniqueDWARFASTTypeMap()
Definition: UniqueDWARFASTType.h:73
Declaration.h
UniqueDWARFASTType::UniqueDWARFASTType
UniqueDWARFASTType(lldb::TypeSP &type_sp, const DWARFDIE &die, const lldb_private::Declaration &decl, int32_t byte_size)
Definition: UniqueDWARFASTType.h:24
lldb_private::ConstString
Definition: ConstString.h:40
UniqueDWARFASTTypeMap
Definition: UniqueDWARFASTType.h:71
UniqueDWARFASTType::m_type_sp
lldb::TypeSP m_type_sp
Definition: UniqueDWARFASTType.h:45
UniqueDWARFASTTypeMap::Find
bool Find(lldb_private::ConstString name, const DWARFDIE &die, const lldb_private::Declaration &decl, const int32_t byte_size, UniqueDWARFASTType &entry) const
Definition: UniqueDWARFASTType.h:82
uint32_t
UniqueDWARFASTTypeMap::m_collection
collection m_collection
Definition: UniqueDWARFASTType.h:96
UniqueDWARFASTTypeMap::~UniqueDWARFASTTypeMap
~UniqueDWARFASTTypeMap()=default
UniqueDWARFASTType::operator=
UniqueDWARFASTType & operator=(const UniqueDWARFASTType &rhs)
Definition: UniqueDWARFASTType.h:35
UniqueDWARFASTType::~UniqueDWARFASTType
~UniqueDWARFASTType()=default
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
UniqueDWARFASTTypeList::m_collection
collection m_collection
Definition: UniqueDWARFASTType.h:68
lldb_private::Declaration
Definition: Declaration.h:24
UniqueDWARFASTTypeMap::Insert
void Insert(lldb_private::ConstString name, const UniqueDWARFASTType &entry)
Definition: UniqueDWARFASTType.h:77
UniqueDWARFASTType::m_declaration
lldb_private::Declaration m_declaration
Definition: UniqueDWARFASTType.h:47