]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
MFV: r334448
[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 "DWARFDIE.h"
22 #include "lldb/Symbol/Declaration.h"
23
24 class UniqueDWARFASTType {
25 public:
26   //------------------------------------------------------------------
27   // Constructors and Destructors
28   //------------------------------------------------------------------
29   UniqueDWARFASTType()
30       : m_type_sp(), m_die(), m_declaration(),
31         m_byte_size(
32             -1) // Set to negative value to make sure we have a valid value
33   {}
34
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) {}
39
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) {}
43
44   ~UniqueDWARFASTType() {}
45
46   UniqueDWARFASTType &operator=(const UniqueDWARFASTType &rhs) {
47     if (this != &rhs) {
48       m_type_sp = rhs.m_type_sp;
49       m_die = rhs.m_die;
50       m_declaration = rhs.m_declaration;
51       m_byte_size = rhs.m_byte_size;
52     }
53     return *this;
54   }
55
56   lldb::TypeSP m_type_sp;
57   DWARFDIE m_die;
58   lldb_private::Declaration m_declaration;
59   int32_t m_byte_size;
60 };
61
62 class UniqueDWARFASTTypeList {
63 public:
64   UniqueDWARFASTTypeList() : m_collection() {}
65
66   ~UniqueDWARFASTTypeList() {}
67
68   uint32_t GetSize() { return (uint32_t)m_collection.size(); }
69
70   void Append(const UniqueDWARFASTType &entry) {
71     m_collection.push_back(entry);
72   }
73
74   bool Find(const DWARFDIE &die, const lldb_private::Declaration &decl,
75             const int32_t byte_size, UniqueDWARFASTType &entry) const;
76
77 protected:
78   typedef std::vector<UniqueDWARFASTType> collection;
79   collection m_collection;
80 };
81
82 class UniqueDWARFASTTypeMap {
83 public:
84   UniqueDWARFASTTypeMap() : m_collection() {}
85
86   ~UniqueDWARFASTTypeMap() {}
87
88   void Insert(const lldb_private::ConstString &name,
89               const UniqueDWARFASTType &entry) {
90     m_collection[name.GetCString()].Append(entry);
91   }
92
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);
100     }
101     return false;
102   }
103
104 protected:
105   // A unique name string should be used
106   typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection;
107   collection m_collection;
108 };
109
110 #endif // lldb_UniqueDWARFASTType_h_