]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / llvm / tools / lldb / source / Plugins / SymbolFile / DWARF / UniqueDWARFASTType.h
1 //===-- UniqueDWARFASTType.h ------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef lldb_UniqueDWARFASTType_h_
11 #define lldb_UniqueDWARFASTType_h_
12
13 // C Includes
14 // C++ Includes
15 #include <vector>
16
17 // Other libraries and framework includes
18 #include "llvm/ADT/DenseMap.h"
19
20 // Project includes
21 #include "lldb/Symbol/Declaration.h"
22
23 class DWARFCompileUnit;
24 class DWARFDebugInfoEntry;
25 class SymbolFileDWARF;
26
27 class UniqueDWARFASTType
28 {
29 public:
30         //------------------------------------------------------------------
31         // Constructors and Destructors
32         //------------------------------------------------------------------
33         UniqueDWARFASTType () :
34         m_type_sp (),
35         m_symfile (NULL),
36         m_cu (NULL),
37         m_die (NULL),
38         m_declaration (),
39         m_byte_size (-1) // Set to negative value to make sure we have a valid value
40     {
41     }
42
43         UniqueDWARFASTType (lldb::TypeSP &type_sp,
44                         SymbolFileDWARF *symfile,
45                         DWARFCompileUnit *cu,
46                         DWARFDebugInfoEntry *die,
47                         const lldb_private::Declaration &decl,
48                         int32_t byte_size) :
49         m_type_sp (type_sp),
50         m_symfile (symfile),
51         m_cu (cu),
52         m_die (die),
53         m_declaration (decl),
54         m_byte_size (byte_size)
55     {
56     }
57     
58     UniqueDWARFASTType (const UniqueDWARFASTType &rhs) :
59         m_type_sp (rhs.m_type_sp),
60         m_symfile (rhs.m_symfile),
61         m_cu (rhs.m_cu),
62         m_die (rhs.m_die),
63         m_declaration (rhs.m_declaration),
64         m_byte_size (rhs.m_byte_size)
65     {
66     }
67
68         ~UniqueDWARFASTType()
69     {
70     }
71
72     UniqueDWARFASTType &
73     operator= (const UniqueDWARFASTType &rhs)
74     {
75         if (this != &rhs)
76         {
77             m_type_sp = rhs.m_type_sp;
78             m_symfile = rhs.m_symfile;
79             m_cu = rhs.m_cu;
80             m_die = rhs.m_die;
81             m_declaration = rhs.m_declaration;
82             m_byte_size = rhs.m_byte_size;
83         }
84         return *this;
85     }
86
87     lldb::TypeSP m_type_sp;
88     SymbolFileDWARF *m_symfile;
89     const DWARFCompileUnit *m_cu;
90     const DWARFDebugInfoEntry *m_die;
91     lldb_private::Declaration m_declaration;
92     int32_t m_byte_size;
93 };
94
95 class UniqueDWARFASTTypeList
96 {
97 public:
98     UniqueDWARFASTTypeList () :
99         m_collection()
100     {
101     }
102     
103     ~UniqueDWARFASTTypeList ()
104     {
105     }
106     
107     uint32_t
108     GetSize()
109     {
110         return (uint32_t)m_collection.size();
111     }
112     
113     void
114     Append (const UniqueDWARFASTType &entry)
115     {
116         m_collection.push_back (entry);
117     }
118     
119     bool
120     Find (SymbolFileDWARF *symfile,
121           const DWARFCompileUnit *cu,
122           const DWARFDebugInfoEntry *die, 
123           const lldb_private::Declaration &decl,
124           const int32_t byte_size,
125           UniqueDWARFASTType &entry) const;
126     
127 protected:
128     typedef std::vector<UniqueDWARFASTType> collection;
129     collection m_collection;
130 };
131
132 class UniqueDWARFASTTypeMap
133 {
134 public:
135     UniqueDWARFASTTypeMap () :
136         m_collection ()
137     {
138     }
139     
140     ~UniqueDWARFASTTypeMap ()
141     {
142     }
143
144     void
145     Insert (const lldb_private::ConstString &name, 
146             const UniqueDWARFASTType &entry)
147     {
148         m_collection[name.GetCString()].Append (entry);
149     }
150
151     bool
152     Find (const lldb_private::ConstString &name, 
153           SymbolFileDWARF *symfile,
154           const DWARFCompileUnit *cu,
155           const DWARFDebugInfoEntry *die, 
156           const lldb_private::Declaration &decl,
157           const int32_t byte_size,
158           UniqueDWARFASTType &entry) const
159     {
160         const char *unique_name_cstr = name.GetCString();
161         collection::const_iterator pos = m_collection.find (unique_name_cstr);
162         if (pos != m_collection.end())
163         {
164             return pos->second.Find (symfile, cu, die, decl, byte_size, entry);
165         }
166         return false;
167     }
168
169 protected:
170     // A unique name string should be used
171     typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection;
172     collection m_collection;
173 };
174
175 #endif  // lldb_UniqueDWARFASTType_h_