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"
21 #include "lldb/Symbol/Declaration.h"
24 class UniqueDWARFASTType
27 //------------------------------------------------------------------
28 // Constructors and Destructors
29 //------------------------------------------------------------------
30 UniqueDWARFASTType () :
34 m_byte_size (-1) // Set to negative value to make sure we have a valid value
38 UniqueDWARFASTType (lldb::TypeSP &type_sp,
40 const lldb_private::Declaration &decl,
45 m_byte_size (byte_size)
49 UniqueDWARFASTType (const UniqueDWARFASTType &rhs) :
50 m_type_sp (rhs.m_type_sp),
52 m_declaration (rhs.m_declaration),
53 m_byte_size (rhs.m_byte_size)
62 operator= (const UniqueDWARFASTType &rhs)
66 m_type_sp = rhs.m_type_sp;
68 m_declaration = rhs.m_declaration;
69 m_byte_size = rhs.m_byte_size;
74 lldb::TypeSP m_type_sp;
76 lldb_private::Declaration m_declaration;
80 class UniqueDWARFASTTypeList
83 UniqueDWARFASTTypeList () :
88 ~UniqueDWARFASTTypeList ()
95 return (uint32_t)m_collection.size();
99 Append (const UniqueDWARFASTType &entry)
101 m_collection.push_back (entry);
105 Find (const DWARFDIE &die,
106 const lldb_private::Declaration &decl,
107 const int32_t byte_size,
108 UniqueDWARFASTType &entry) const;
111 typedef std::vector<UniqueDWARFASTType> collection;
112 collection m_collection;
115 class UniqueDWARFASTTypeMap
118 UniqueDWARFASTTypeMap () :
123 ~UniqueDWARFASTTypeMap ()
128 Insert (const lldb_private::ConstString &name,
129 const UniqueDWARFASTType &entry)
131 m_collection[name.GetCString()].Append (entry);
135 Find (const lldb_private::ConstString &name,
137 const lldb_private::Declaration &decl,
138 const int32_t byte_size,
139 UniqueDWARFASTType &entry) const
141 const char *unique_name_cstr = name.GetCString();
142 collection::const_iterator pos = m_collection.find (unique_name_cstr);
143 if (pos != m_collection.end())
145 return pos->second.Find (die, decl, byte_size, entry);
151 // A unique name string should be used
152 typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection;
153 collection m_collection;
156 #endif // lldb_UniqueDWARFASTType_h_