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_SOURCE_PLUGINS_SYMBOLFILE_DWARF_UNIQUEDWARFASTTYPE_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_UNIQUEDWARFASTTYPE_H
14 #include "llvm/ADT/DenseMap.h"
17 #include "lldb/Core/Declaration.h"
19 class UniqueDWARFASTType {
21 // Constructors and Destructors
22 UniqueDWARFASTType() : m_type_sp(), m_die(), m_declaration() {}
24 UniqueDWARFASTType(lldb::TypeSP &type_sp, const DWARFDIE &die,
25 const lldb_private::Declaration &decl, int32_t byte_size)
26 : m_type_sp(type_sp), m_die(die), m_declaration(decl),
27 m_byte_size(byte_size) {}
29 UniqueDWARFASTType(const UniqueDWARFASTType &rhs)
30 : m_type_sp(rhs.m_type_sp), m_die(rhs.m_die),
31 m_declaration(rhs.m_declaration), m_byte_size(rhs.m_byte_size) {}
33 ~UniqueDWARFASTType() = default;
35 UniqueDWARFASTType &operator=(const UniqueDWARFASTType &rhs) {
37 m_type_sp = rhs.m_type_sp;
39 m_declaration = rhs.m_declaration;
40 m_byte_size = rhs.m_byte_size;
45 lldb::TypeSP m_type_sp;
47 lldb_private::Declaration m_declaration;
48 int32_t m_byte_size = -1;
51 class UniqueDWARFASTTypeList {
53 UniqueDWARFASTTypeList() : m_collection() {}
55 ~UniqueDWARFASTTypeList() = default;
57 uint32_t GetSize() { return (uint32_t)m_collection.size(); }
59 void Append(const UniqueDWARFASTType &entry) {
60 m_collection.push_back(entry);
63 bool Find(const DWARFDIE &die, const lldb_private::Declaration &decl,
64 const int32_t byte_size, UniqueDWARFASTType &entry) const;
67 typedef std::vector<UniqueDWARFASTType> collection;
68 collection m_collection;
71 class UniqueDWARFASTTypeMap {
73 UniqueDWARFASTTypeMap() : m_collection() {}
75 ~UniqueDWARFASTTypeMap() = default;
77 void Insert(lldb_private::ConstString name,
78 const UniqueDWARFASTType &entry) {
79 m_collection[name.GetCString()].Append(entry);
82 bool Find(lldb_private::ConstString name, const DWARFDIE &die,
83 const lldb_private::Declaration &decl, const int32_t byte_size,
84 UniqueDWARFASTType &entry) const {
85 const char *unique_name_cstr = name.GetCString();
86 collection::const_iterator pos = m_collection.find(unique_name_cstr);
87 if (pos != m_collection.end()) {
88 return pos->second.Find(die, decl, byte_size, entry);
94 // A unique name string should be used
95 typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection;
96 collection m_collection;
99 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_UNIQUEDWARFASTTYPE_H