1 //===-- UniqueDWARFASTType.h ------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef lldb_UniqueDWARFASTType_h_
11 #define lldb_UniqueDWARFASTType_h_
17 // Other libraries and framework includes
18 #include "llvm/ADT/DenseMap.h"
22 #include "lldb/Symbol/Declaration.h"
24 class UniqueDWARFASTType {
26 //------------------------------------------------------------------
27 // Constructors and Destructors
28 //------------------------------------------------------------------
30 : m_type_sp(), m_die(), m_declaration(),
32 -1) // Set to negative value to make sure we have a valid value
35 UniqueDWARFASTType(lldb::TypeSP &type_sp, const DWARFDIE &die,
36 const lldb_private::Declaration &decl, int32_t byte_size)
37 : m_type_sp(type_sp), m_die(die), m_declaration(decl),
38 m_byte_size(byte_size) {}
40 UniqueDWARFASTType(const UniqueDWARFASTType &rhs)
41 : m_type_sp(rhs.m_type_sp), m_die(rhs.m_die),
42 m_declaration(rhs.m_declaration), m_byte_size(rhs.m_byte_size) {}
44 ~UniqueDWARFASTType() {}
46 UniqueDWARFASTType &operator=(const UniqueDWARFASTType &rhs) {
48 m_type_sp = rhs.m_type_sp;
50 m_declaration = rhs.m_declaration;
51 m_byte_size = rhs.m_byte_size;
56 lldb::TypeSP m_type_sp;
58 lldb_private::Declaration m_declaration;
62 class UniqueDWARFASTTypeList {
64 UniqueDWARFASTTypeList() : m_collection() {}
66 ~UniqueDWARFASTTypeList() {}
68 uint32_t GetSize() { return (uint32_t)m_collection.size(); }
70 void Append(const UniqueDWARFASTType &entry) {
71 m_collection.push_back(entry);
74 bool Find(const DWARFDIE &die, const lldb_private::Declaration &decl,
75 const int32_t byte_size, UniqueDWARFASTType &entry) const;
78 typedef std::vector<UniqueDWARFASTType> collection;
79 collection m_collection;
82 class UniqueDWARFASTTypeMap {
84 UniqueDWARFASTTypeMap() : m_collection() {}
86 ~UniqueDWARFASTTypeMap() {}
88 void Insert(const lldb_private::ConstString &name,
89 const UniqueDWARFASTType &entry) {
90 m_collection[name.GetCString()].Append(entry);
93 bool Find(const lldb_private::ConstString &name, const DWARFDIE &die,
94 const lldb_private::Declaration &decl, const int32_t byte_size,
95 UniqueDWARFASTType &entry) const {
96 const char *unique_name_cstr = name.GetCString();
97 collection::const_iterator pos = m_collection.find(unique_name_cstr);
98 if (pos != m_collection.end()) {
99 return pos->second.Find(die, decl, byte_size, entry);
105 // A unique name string should be used
106 typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection;
107 collection m_collection;
110 #endif // lldb_UniqueDWARFASTType_h_