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_UniqueDWARFASTType_h_
10 #define lldb_UniqueDWARFASTType_h_
11 
12 #include <vector>
13 
14 #include "llvm/ADT/DenseMap.h"
15 
16 #include "DWARFDIE.h"
18 
20 public:
21  // Constructors and Destructors
23  : m_type_sp(), m_die(), m_declaration(),
25  -1) // Set to negative value to make sure we have a valid value
26  {}
27 
28  UniqueDWARFASTType(lldb::TypeSP &type_sp, const DWARFDIE &die,
29  const lldb_private::Declaration &decl, int32_t byte_size)
30  : m_type_sp(type_sp), m_die(die), m_declaration(decl),
31  m_byte_size(byte_size) {}
32 
34  : m_type_sp(rhs.m_type_sp), m_die(rhs.m_die),
36 
38 
40  if (this != &rhs) {
41  m_type_sp = rhs.m_type_sp;
42  m_die = rhs.m_die;
45  }
46  return *this;
47  }
48 
49  lldb::TypeSP m_type_sp;
52  int32_t m_byte_size;
53 };
54 
56 public:
57  UniqueDWARFASTTypeList() : m_collection() {}
58 
60 
61  uint32_t GetSize() { return (uint32_t)m_collection.size(); }
62 
63  void Append(const UniqueDWARFASTType &entry) {
64  m_collection.push_back(entry);
65  }
66 
67  bool Find(const DWARFDIE &die, const lldb_private::Declaration &decl,
68  const int32_t byte_size, UniqueDWARFASTType &entry) const;
69 
70 protected:
71  typedef std::vector<UniqueDWARFASTType> collection;
72  collection m_collection;
73 };
74 
76 public:
77  UniqueDWARFASTTypeMap() : m_collection() {}
78 
80 
82  const UniqueDWARFASTType &entry) {
83  m_collection[name.GetCString()].Append(entry);
84  }
85 
86  bool Find(lldb_private::ConstString name, const DWARFDIE &die,
87  const lldb_private::Declaration &decl, const int32_t byte_size,
88  UniqueDWARFASTType &entry) const {
89  const char *unique_name_cstr = name.GetCString();
90  collection::const_iterator pos = m_collection.find(unique_name_cstr);
91  if (pos != m_collection.end()) {
92  return pos->second.Find(die, decl, byte_size, entry);
93  }
94  return false;
95  }
96 
97 protected:
98  // A unique name string should be used
99  typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection;
100  collection m_collection;
101 };
102 
103 #endif // lldb_UniqueDWARFASTType_h_
void Insert(lldb_private::ConstString name, const UniqueDWARFASTType &entry)
lldb_private::Declaration m_declaration
UniqueDWARFASTType(lldb::TypeSP &type_sp, const DWARFDIE &die, const lldb_private::Declaration &decl, int32_t byte_size)
A uniqued constant string class.
Definition: ConstString.h:38
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:247
void Append(const UniqueDWARFASTType &entry)
UniqueDWARFASTType(const UniqueDWARFASTType &rhs)
llvm::DenseMap< const char *, UniqueDWARFASTTypeList > collection
std::vector< UniqueDWARFASTType > collection
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
bool Find(lldb_private::ConstString name, const DWARFDIE &die, const lldb_private::Declaration &decl, const int32_t byte_size, UniqueDWARFASTType &entry) const
UniqueDWARFASTType & operator=(const UniqueDWARFASTType &rhs)