Skip to content

Commit f46e897

Browse files
committedJul 25, 2019
SymbolVendor: Remove the type list member
Summary: Similarly to the compile unit lists, the list of types can also be managed by the symbol file itself. Since the only purpose of this list seems to be to maintain an owning reference to all the types a symbol file has created (items are only ever added to the list, never retrieved), I remove the passthrough functions in SymbolVendor and Module. I also tighten the interface of the function (return a reference instead of a pointer, make it protected instead of public). Reviewers: clayborg, JDevlieghere, jingham Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D65135 llvm-svn: 366994
1 parent 5c606ce commit f46e897

15 files changed

+23
-65
lines changed
 

‎lldb/include/lldb/Core/Module.h

-7
Original file line numberDiff line numberDiff line change
@@ -653,13 +653,6 @@ class Module : public std::enable_shared_from_this<Module>,
653653
GetSymbolVendor(bool can_create = true,
654654
lldb_private::Stream *feedback_strm = nullptr);
655655

656-
/// Get accessor the type list for this module.
657-
///
658-
/// \return
659-
/// A valid type list pointer, or nullptr if there is no valid
660-
/// symbol vendor for this module.
661-
TypeList *GetTypeList();
662-
663656
/// Get a reference to the UUID value contained in this object.
664657
///
665658
/// If the executable image file doesn't not have a UUID value built into

‎lldb/include/lldb/Symbol/SymbolFile.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "lldb/Symbol/Function.h"
1717
#include "lldb/Symbol/SourceModule.h"
1818
#include "lldb/Symbol/Type.h"
19+
#include "lldb/Symbol/TypeList.h"
1920
#include "lldb/lldb-private.h"
2021

2122
#include "llvm/ADT/DenseSet.h"
@@ -191,10 +192,7 @@ class SymbolFile : public PluginInterface {
191192
virtual void
192193
GetMangledNamesForFunction(const std::string &scope_qualified_name,
193194
std::vector<ConstString> &mangled_names);
194-
// virtual uint32_t FindTypes (const SymbolContext& sc, const
195-
// RegularExpression& regex, bool append, uint32_t max_matches, TypeList&
196-
// types) = 0;
197-
virtual TypeList *GetTypeList();
195+
198196
virtual size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
199197
lldb::TypeClass type_mask,
200198
lldb_private::TypeList &type_list) = 0;
@@ -241,11 +239,13 @@ class SymbolFile : public PluginInterface {
241239
void AssertModuleLock();
242240
virtual uint32_t CalculateNumCompileUnits() = 0;
243241
virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t idx) = 0;
242+
virtual TypeList &GetTypeList() { return m_type_list; }
244243

245244
void SetCompileUnitAtIndex(uint32_t idx, const lldb::CompUnitSP &cu_sp);
246245

247246
ObjectFile *m_obj_file; // The object file that symbols can be extracted from.
248247
llvm::Optional<std::vector<lldb::CompUnitSP>> m_compile_units;
248+
TypeList m_type_list;
249249
uint32_t m_abilities;
250250
bool m_calculated_abilities;
251251

‎lldb/include/lldb/Symbol/SymbolVendor.h

-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "lldb/Core/ModuleChild.h"
1515
#include "lldb/Core/PluginInterface.h"
1616
#include "lldb/Symbol/SourceModule.h"
17-
#include "lldb/Symbol/TypeList.h"
1817
#include "lldb/Symbol/TypeMap.h"
1918
#include "lldb/lldb-private.h"
2019
#include "llvm/ADT/DenseSet.h"
@@ -112,10 +111,6 @@ class SymbolVendor : public ModuleChild, public PluginInterface {
112111

113112
virtual lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx);
114113

115-
TypeList &GetTypeList() { return m_type_list; }
116-
117-
const TypeList &GetTypeList() const { return m_type_list; }
118-
119114
virtual size_t GetTypes(SymbolContextScope *sc_scope,
120115
lldb::TypeClass type_mask, TypeList &type_list);
121116

@@ -139,7 +134,6 @@ class SymbolVendor : public ModuleChild, public PluginInterface {
139134
uint32_t GetPluginVersion() override;
140135

141136
protected:
142-
TypeList m_type_list; // Uniqued types for all parsers owned by this module
143137
lldb::ObjectFileSP m_objfile_sp; // Keep a reference to the object file in
144138
// case it isn't the same as the module
145139
// object file (debug symbols in a separate

‎lldb/include/lldb/Symbol/Type.h

-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ class Type : public std::enable_shared_from_this<Type>, public UserID {
117117
SymbolFile *GetSymbolFile() { return m_symbol_file; }
118118
const SymbolFile *GetSymbolFile() const { return m_symbol_file; }
119119

120-
TypeList *GetTypeList();
121-
122120
ConstString GetName();
123121

124122
llvm::Optional<uint64_t> GetByteSize();

‎lldb/source/API/SBCompileUnit.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "lldb/Symbol/LineTable.h"
1717
#include "lldb/Symbol/SymbolVendor.h"
1818
#include "lldb/Symbol/Type.h"
19+
#include "lldb/Symbol/TypeList.h"
1920

2021
using namespace lldb;
2122
using namespace lldb_private;

‎lldb/source/Core/Module.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -1240,13 +1240,6 @@ void Module::Dump(Stream *s) {
12401240
s->IndentLess();
12411241
}
12421242

1243-
TypeList *Module::GetTypeList() {
1244-
SymbolVendor *symbols = GetSymbolVendor();
1245-
if (symbols)
1246-
return &symbols->GetTypeList();
1247-
return nullptr;
1248-
}
1249-
12501243
ConstString Module::GetObjectName() const { return m_object_name; }
12511244

12521245
ObjectFile *Module::GetObjectFile() {

‎lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWO(const DWARFDIE &die, Log *log) {
188188
nullptr, LLDB_INVALID_UID, Type::eEncodingInvalid,
189189
&dwo_type_sp->GetDeclaration(), type, Type::eResolveStateForward));
190190

191-
dwarf->GetTypeList()->Insert(type_sp);
191+
dwarf->GetTypeList().Insert(type_sp);
192192
dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
193193
clang::TagDecl *tag_decl = ClangASTContext::GetAsTagDecl(type);
194194
if (tag_decl)
@@ -434,7 +434,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc,
434434
return nullptr;
435435
}
436436

437-
TypeList *type_list = dwarf->GetTypeList();
437+
TypeList &type_list = dwarf->GetTypeList();
438438
if (type_is_new_ptr)
439439
*type_is_new_ptr = true;
440440

@@ -1672,7 +1672,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc,
16721672

16731673
// We are ready to put this type into the uniqued list up at the module
16741674
// level
1675-
type_list->Insert(type_sp);
1675+
type_list.Insert(type_sp);
16761676

16771677
dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
16781678
}

‎lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,13 @@ SymbolFile *SymbolFileDWARF::CreateInstance(ObjectFile *obj_file) {
202202
/*dwo_section_list*/ nullptr);
203203
}
204204

205-
TypeList *SymbolFileDWARF::GetTypeList() {
205+
TypeList &SymbolFileDWARF::GetTypeList() {
206206
// This method can be called without going through the symbol vendor so we
207207
// need to lock the module.
208208
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
209-
SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
210-
if (debug_map_symfile)
209+
if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile())
211210
return debug_map_symfile->GetTypeList();
212-
else
213-
return m_obj_file->GetModule()->GetTypeList();
211+
return SymbolFile::GetTypeList();
214212
}
215213
void SymbolFileDWARF::GetTypes(const DWARFDIE &die, dw_offset_t min_die_offset,
216214
dw_offset_t max_die_offset, uint32_t type_mask,
@@ -2971,9 +2969,7 @@ TypeSP SymbolFileDWARF::ParseType(const SymbolContext &sc, const DWARFDIE &die,
29712969
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
29722970
TypeSP type_sp = dwarf_ast->ParseTypeFromDWARF(sc, die, log, type_is_new_ptr);
29732971
if (type_sp) {
2974-
TypeList *type_list = GetTypeList();
2975-
if (type_list)
2976-
type_list->Insert(type_sp);
2972+
GetTypeList().Insert(type_sp);
29772973

29782974
if (die.Tag() == DW_TAG_subprogram) {
29792975
std::string scope_qualified_name(GetDeclContextForUID(die.GetID())

‎lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
186186
size_t FindTypes(const std::vector<lldb_private::CompilerContext> &context,
187187
bool append, lldb_private::TypeMap &types) override;
188188

189-
lldb_private::TypeList *GetTypeList() override;
190-
191189
size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
192190
lldb::TypeClass type_mask,
193191
lldb_private::TypeList &type_list) override;
@@ -331,6 +329,8 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
331329

332330
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
333331

332+
lldb_private::TypeList &GetTypeList() override;
333+
334334
virtual DWARFUnit *
335335
GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit);
336336

‎lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ TypeSP SymbolFileNativePDB::GetOrCreateType(PdbTypeSymId type_id) {
729729

730730
TypeSP type = CreateAndCacheType(type_id);
731731
if (type)
732-
m_obj_file->GetModule()->GetTypeList()->Insert(type);
732+
GetTypeList().Insert(type);
733733
return type;
734734
}
735735

@@ -1283,7 +1283,7 @@ size_t SymbolFileNativePDB::ParseTypes(CompileUnit &comp_unit) {
12831283
if (m_done_full_type_scan)
12841284
return 0;
12851285

1286-
size_t old_count = m_obj_file->GetModule()->GetTypeList()->GetSize();
1286+
const size_t old_count = GetTypeList().GetSize();
12871287
LazyRandomTypeCollection &types = m_index->tpi().typeCollection();
12881288

12891289
// First process the entire TPI stream.
@@ -1313,7 +1313,7 @@ size_t SymbolFileNativePDB::ParseTypes(CompileUnit &comp_unit) {
13131313
GetOrCreateTypedef(global);
13141314
}
13151315

1316-
size_t new_count = m_obj_file->GetModule()->GetTypeList()->GetSize();
1316+
const size_t new_count = GetTypeList().GetSize();
13171317

13181318
m_done_full_type_scan = true;
13191319

‎lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,7 @@ lldb_private::Type *SymbolFilePDB::ResolveTypeUID(lldb::user_id_t type_uid) {
557557
lldb::TypeSP result = pdb->CreateLLDBTypeFromPDBType(*pdb_type);
558558
if (result) {
559559
m_types.insert(std::make_pair(type_uid, result));
560-
auto type_list = GetTypeList();
561-
if (type_list)
562-
type_list->Insert(result);
560+
GetTypeList().Insert(result);
563561
}
564562
return result.get();
565563
}
@@ -1516,10 +1514,6 @@ size_t SymbolFilePDB::FindTypes(
15161514
return 0;
15171515
}
15181516

1519-
lldb_private::TypeList *SymbolFilePDB::GetTypeList() {
1520-
return m_obj_file->GetModule()->GetTypeList();
1521-
}
1522-
15231517
void SymbolFilePDB::GetTypesForPDBSymbol(const llvm::pdb::PDBSymbol &pdb_symbol,
15241518
uint32_t type_mask,
15251519
TypeCollection &type_collection) {

‎lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h

-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ class SymbolFilePDB : public lldb_private::SymbolFile {
138138
void FindTypesByRegex(const lldb_private::RegularExpression &regex,
139139
uint32_t max_matches, lldb_private::TypeMap &types);
140140

141-
lldb_private::TypeList *GetTypeList() override;
142-
143141
size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
144142
lldb::TypeClass type_mask,
145143
lldb_private::TypeList &type_list) override;

‎lldb/source/Symbol/SymbolFile.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ SymbolFile *SymbolFile::FindPlugin(ObjectFile *obj_file) {
8282
return best_symfile_up.release();
8383
}
8484

85-
TypeList *SymbolFile::GetTypeList() {
86-
if (m_obj_file)
87-
return m_obj_file->GetModule()->GetTypeList();
88-
return nullptr;
89-
}
90-
9185
TypeSystem *SymbolFile::GetTypeSystemForLanguage(lldb::LanguageType language) {
9286
TypeSystem *type_system =
9387
m_obj_file->GetModule()->GetTypeSystemForLanguage(language);
@@ -206,6 +200,10 @@ void SymbolFile::SetCompileUnitAtIndex(uint32_t idx, const CompUnitSP &cu_sp) {
206200
}
207201

208202
void SymbolFile::Dump(Stream &s) {
203+
s.PutCString("Types:\n");
204+
m_type_list.Dump(&s, /*show_context*/ false);
205+
s.PutChar('\n');
206+
209207
s.PutCString("Compile units:\n");
210208
if (m_compile_units) {
211209
for (const CompUnitSP &cu_sp : *m_compile_units) {

‎lldb/source/Symbol/SymbolVendor.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ SymbolVendor *SymbolVendor::FindPlugin(const lldb::ModuleSP &module_sp,
5858

5959
// SymbolVendor constructor
6060
SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp)
61-
: ModuleChild(module_sp), m_type_list(), m_sym_file_up(), m_symtab() {}
61+
: ModuleChild(module_sp), m_sym_file_up(), m_symtab() {}
6262

6363
// Destructor
6464
SymbolVendor::~SymbolVendor() {}
@@ -336,8 +336,6 @@ void SymbolVendor::Dump(Stream *s) {
336336
if (module_sp) {
337337
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
338338

339-
bool show_context = false;
340-
341339
s->Printf("%p: ", static_cast<void *>(this));
342340
s->Indent();
343341
s->PutCString("SymbolVendor");
@@ -354,9 +352,6 @@ void SymbolVendor::Dump(Stream *s) {
354352
}
355353
}
356354
s->EOL();
357-
s->PutCString("Types:\n");
358-
m_type_list.Dump(s, show_context);
359-
s->EOL();
360355
if (m_sym_file_up)
361356
m_sym_file_up->Dump(*s);
362357
s->IndentMore();

‎lldb/source/Symbol/Type.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,6 @@ bool Type::WriteToMemory(ExecutionContext *exe_ctx, lldb::addr_t addr,
425425
return false;
426426
}
427427

428-
TypeList *Type::GetTypeList() { return GetSymbolFile()->GetTypeList(); }
429-
430428
const Declaration &Type::GetDeclaration() const { return m_decl; }
431429

432430
bool Type::ResolveClangType(ResolveState compiler_type_resolve_state) {

0 commit comments

Comments
 (0)
Please sign in to comment.