]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
Merge OpenSSL 1.0.2i.
[FreeBSD/FreeBSD.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 #include "DWARFDIE.h"
23
24 class UniqueDWARFASTType
25 {
26 public:
27         //------------------------------------------------------------------
28         // Constructors and Destructors
29         //------------------------------------------------------------------
30         UniqueDWARFASTType () :
31         m_type_sp (),
32         m_die (),
33         m_declaration (),
34         m_byte_size (-1) // Set to negative value to make sure we have a valid value
35     {
36     }
37
38         UniqueDWARFASTType (lldb::TypeSP &type_sp,
39                         const DWARFDIE &die,
40                         const lldb_private::Declaration &decl,
41                         int32_t byte_size) :
42         m_type_sp (type_sp),
43         m_die (die),
44         m_declaration (decl),
45         m_byte_size (byte_size)
46     {
47     }
48     
49     UniqueDWARFASTType (const UniqueDWARFASTType &rhs) :
50         m_type_sp (rhs.m_type_sp),
51         m_die (rhs.m_die),
52         m_declaration (rhs.m_declaration),
53         m_byte_size (rhs.m_byte_size)
54     {
55     }
56
57         ~UniqueDWARFASTType()
58     {
59     }
60
61     UniqueDWARFASTType &
62     operator= (const UniqueDWARFASTType &rhs)
63     {
64         if (this != &rhs)
65         {
66             m_type_sp = rhs.m_type_sp;
67             m_die = rhs.m_die;
68             m_declaration = rhs.m_declaration;
69             m_byte_size = rhs.m_byte_size;
70         }
71         return *this;
72     }
73
74     lldb::TypeSP m_type_sp;
75     DWARFDIE m_die;
76     lldb_private::Declaration m_declaration;
77     int32_t m_byte_size;
78 };
79
80 class UniqueDWARFASTTypeList
81 {
82 public:
83     UniqueDWARFASTTypeList () :
84         m_collection()
85     {
86     }
87     
88     ~UniqueDWARFASTTypeList ()
89     {
90     }
91     
92     uint32_t
93     GetSize()
94     {
95         return (uint32_t)m_collection.size();
96     }
97     
98     void
99     Append (const UniqueDWARFASTType &entry)
100     {
101         m_collection.push_back (entry);
102     }
103     
104     bool
105     Find (const DWARFDIE &die,
106           const lldb_private::Declaration &decl,
107           const int32_t byte_size,
108           UniqueDWARFASTType &entry) const;
109     
110 protected:
111     typedef std::vector<UniqueDWARFASTType> collection;
112     collection m_collection;
113 };
114
115 class UniqueDWARFASTTypeMap
116 {
117 public:
118     UniqueDWARFASTTypeMap () :
119         m_collection ()
120     {
121     }
122     
123     ~UniqueDWARFASTTypeMap ()
124     {
125     }
126
127     void
128     Insert (const lldb_private::ConstString &name, 
129             const UniqueDWARFASTType &entry)
130     {
131         m_collection[name.GetCString()].Append (entry);
132     }
133
134     bool
135     Find (const lldb_private::ConstString &name,
136           const DWARFDIE &die,
137           const lldb_private::Declaration &decl,
138           const int32_t byte_size,
139           UniqueDWARFASTType &entry) const
140     {
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())
144         {
145             return pos->second.Find (die, decl, byte_size, entry);
146         }
147         return false;
148     }
149
150 protected:
151     // A unique name string should be used
152     typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection;
153     collection m_collection;
154 };
155
156 #endif  // lldb_UniqueDWARFASTType_h_