1 //===-- UniqueDWARFASTType.h ------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef lldb_UniqueDWARFASTType_h_
10 #define lldb_UniqueDWARFASTType_h_
14 #include "llvm/ADT/DenseMap.h"
17 #include "lldb/Symbol/Declaration.h"
19 class UniqueDWARFASTType {
21 // Constructors and Destructors
23 : m_type_sp(), m_die(), m_declaration(),
25 -1) // Set to negative value to make sure we have a valid value
28 UniqueDWARFASTType(lldb::TypeSP &type_sp, const DWARFDIE &die,
29 const lldb_private::Declaration &decl, int32_t byte_size)
30 : m_type_sp(type_sp), m_die(die), m_declaration(decl),
31 m_byte_size(byte_size) {}
33 UniqueDWARFASTType(const UniqueDWARFASTType &rhs)
34 : m_type_sp(rhs.m_type_sp), m_die(rhs.m_die),
35 m_declaration(rhs.m_declaration), m_byte_size(rhs.m_byte_size) {}
37 ~UniqueDWARFASTType() {}
39 UniqueDWARFASTType &operator=(const UniqueDWARFASTType &rhs) {
41 m_type_sp = rhs.m_type_sp;
43 m_declaration = rhs.m_declaration;
44 m_byte_size = rhs.m_byte_size;
49 lldb::TypeSP m_type_sp;
51 lldb_private::Declaration m_declaration;
55 class UniqueDWARFASTTypeList {
57 UniqueDWARFASTTypeList() : m_collection() {}
59 ~UniqueDWARFASTTypeList() {}
61 uint32_t GetSize() { return (uint32_t)m_collection.size(); }
63 void Append(const UniqueDWARFASTType &entry) {
64 m_collection.push_back(entry);
67 bool Find(const DWARFDIE &die, const lldb_private::Declaration &decl,
68 const int32_t byte_size, UniqueDWARFASTType &entry) const;
71 typedef std::vector<UniqueDWARFASTType> collection;
72 collection m_collection;
75 class UniqueDWARFASTTypeMap {
77 UniqueDWARFASTTypeMap() : m_collection() {}
79 ~UniqueDWARFASTTypeMap() {}
81 void Insert(lldb_private::ConstString name,
82 const UniqueDWARFASTType &entry) {
83 m_collection[name.GetCString()].Append(entry);
86 bool Find(lldb_private::ConstString name, const DWARFDIE &die,
87 const lldb_private::Declaration &decl, const int32_t byte_size,
88 UniqueDWARFASTType &entry) const {
89 const char *unique_name_cstr = name.GetCString();
90 collection::const_iterator pos = m_collection.find(unique_name_cstr);
91 if (pos != m_collection.end()) {
92 return pos->second.Find(die, decl, byte_size, entry);
98 // A unique name string should be used
99 typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection;
100 collection m_collection;
103 #endif // lldb_UniqueDWARFASTType_h_