Skip to content

Commit 10508b6

Browse files
[LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (#70157)
This effectively moves a few functions from protected to public. In any case, for the sake of having a cleaner SymbolFileDWARF API, it's better if it's not a friend of a one of its consumers, DWARFASTParserClang. Another effect of this change is that I can use SymbolFileDWARF for the out-of-tree mojo dwarf parser, which relies on pretty much the same functions that DWARFASTParserClang needs from SymbolFileDWARF.
1 parent a1b4238 commit 10508b6

File tree

6 files changed

+63
-59
lines changed

6 files changed

+63
-59
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -834,9 +834,9 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
834834

835835
CompilerType enumerator_clang_type;
836836
CompilerType clang_type;
837-
clang_type =
838-
CompilerType(m_ast.weak_from_this(),
839-
dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
837+
clang_type = CompilerType(
838+
m_ast.weak_from_this(),
839+
dwarf->GetForwardDeclDIEToCompilerType().lookup(die.GetDIE()));
840840
if (!clang_type) {
841841
if (attrs.type.IsValid()) {
842842
Type *enumerator_type =
@@ -1764,9 +1764,9 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
17641764
assert(tag_decl_kind != -1);
17651765
(void)tag_decl_kind;
17661766
bool clang_type_was_created = false;
1767-
clang_type =
1768-
CompilerType(m_ast.weak_from_this(),
1769-
dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
1767+
clang_type = CompilerType(
1768+
m_ast.weak_from_this(),
1769+
dwarf->GetForwardDeclDIEToCompilerType().lookup(die.GetDIE()));
17701770
if (!clang_type) {
17711771
clang::DeclContext *decl_ctx =
17721772
GetClangDeclContextContainingDIE(die, nullptr);
@@ -1896,16 +1896,16 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
18961896
// the SymbolFile virtual function
18971897
// "SymbolFileDWARF::CompleteType(Type *)" When the definition
18981898
// needs to be defined.
1899-
assert(!dwarf->GetForwardDeclClangTypeToDie().count(
1899+
assert(!dwarf->GetForwardDeclCompilerTypeToDIE().count(
19001900
ClangUtil::RemoveFastQualifiers(clang_type)
19011901
.GetOpaqueQualType()) &&
19021902
"Type already in the forward declaration map!");
19031903
// Can't assume m_ast.GetSymbolFile() is actually a
19041904
// SymbolFileDWARF, it can be a SymbolFileDWARFDebugMap for Apple
19051905
// binaries.
1906-
dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] =
1906+
dwarf->GetForwardDeclDIEToCompilerType()[die.GetDIE()] =
19071907
clang_type.GetOpaqueQualType();
1908-
dwarf->GetForwardDeclClangTypeToDie().try_emplace(
1908+
dwarf->GetForwardDeclCompilerTypeToDIE().try_emplace(
19091909
ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType(),
19101910
*die.GetDIERef());
19111911
m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true);

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,11 +1532,11 @@ Type *SymbolFileDWARF::ResolveTypeUID(const DWARFDIE &die,
15321532
// This function is used when SymbolFileDWARFDebugMap owns a bunch of
15331533
// SymbolFileDWARF objects to detect if this DWARF file is the one that can
15341534
// resolve a compiler_type.
1535-
bool SymbolFileDWARF::HasForwardDeclForClangType(
1535+
bool SymbolFileDWARF::HasForwardDeclForCompilerType(
15361536
const CompilerType &compiler_type) {
15371537
CompilerType compiler_type_no_qualifiers =
15381538
ClangUtil::RemoveFastQualifiers(compiler_type);
1539-
if (GetForwardDeclClangTypeToDie().count(
1539+
if (GetForwardDeclCompilerTypeToDIE().count(
15401540
compiler_type_no_qualifiers.GetOpaqueQualType())) {
15411541
return true;
15421542
}
@@ -1564,9 +1564,9 @@ bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
15641564
// We have a struct/union/class/enum that needs to be fully resolved.
15651565
CompilerType compiler_type_no_qualifiers =
15661566
ClangUtil::RemoveFastQualifiers(compiler_type);
1567-
auto die_it = GetForwardDeclClangTypeToDie().find(
1567+
auto die_it = GetForwardDeclCompilerTypeToDIE().find(
15681568
compiler_type_no_qualifiers.GetOpaqueQualType());
1569-
if (die_it == GetForwardDeclClangTypeToDie().end()) {
1569+
if (die_it == GetForwardDeclCompilerTypeToDIE().end()) {
15701570
// We have already resolved this type...
15711571
return true;
15721572
}
@@ -1577,7 +1577,7 @@ bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
15771577
// declaration map in case anyone child members or other types require this
15781578
// type to get resolved. The type will get resolved when all of the calls
15791579
// to SymbolFileDWARF::ResolveClangOpaqueTypeDefinition are done.
1580-
GetForwardDeclClangTypeToDie().erase(die_it);
1580+
GetForwardDeclCompilerTypeToDIE().erase(die_it);
15811581

15821582
Type *type = GetDIEToType().lookup(dwarf_die.GetDIE());
15831583

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

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
8383
friend class DWARFCompileUnit;
8484
friend class DWARFDIE;
8585
friend class DWARFASTParser;
86-
friend class ::DWARFASTParserClang;
8786

8887
// Static Functions
8988
static void Initialize();
@@ -138,7 +137,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
138137

139138
size_t ParseVariablesForContext(const SymbolContext &sc) override;
140139

141-
Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
142140
std::optional<ArrayInfo>
143141
GetDynamicArrayInfoForUID(lldb::user_id_t type_uid,
144142
const ExecutionContext *exe_ctx) override;
@@ -225,7 +223,7 @@ class SymbolFileDWARF : public SymbolFileCommon {
225223
DWARFDIE
226224
GetDeclContextDIEContainingDIE(const DWARFDIE &die);
227225

228-
bool HasForwardDeclForClangType(const CompilerType &compiler_type);
226+
bool HasForwardDeclForCompilerType(const CompilerType &compiler_type);
229227

230228
CompileUnit *GetCompUnitForDWARFCompUnit(DWARFCompileUnit &dwarf_cu);
231229

@@ -325,14 +323,46 @@ class SymbolFileDWARF : public SymbolFileCommon {
325323
m_file_index = file_index;
326324
}
327325

328-
protected:
329326
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, Type *> DIEToTypePtr;
330-
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP>
331-
DIEToVariableSP;
327+
328+
virtual DIEToTypePtr &GetDIEToType() { return m_die_to_type; }
329+
332330
typedef llvm::DenseMap<const DWARFDebugInfoEntry *,
333331
lldb::opaque_compiler_type_t>
334-
DIEToClangType;
335-
typedef llvm::DenseMap<lldb::opaque_compiler_type_t, DIERef> ClangTypeToDIE;
332+
DIEToCompilerType;
333+
334+
virtual DIEToCompilerType &GetForwardDeclDIEToCompilerType() {
335+
return m_forward_decl_die_to_compiler_type;
336+
}
337+
338+
typedef llvm::DenseMap<lldb::opaque_compiler_type_t, DIERef>
339+
CompilerTypeToDIE;
340+
341+
virtual CompilerTypeToDIE &GetForwardDeclCompilerTypeToDIE() {
342+
return m_forward_decl_compiler_type_to_die;
343+
}
344+
345+
virtual UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap();
346+
347+
bool ClassOrStructIsVirtual(const DWARFDIE &die);
348+
349+
SymbolFileDWARFDebugMap *GetDebugMapSymfile();
350+
351+
virtual lldb::TypeSP
352+
FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die);
353+
354+
virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
355+
const DWARFDIE &die, ConstString type_name, bool must_be_implementation);
356+
357+
Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
358+
359+
Type *ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed);
360+
361+
Type *ResolveTypeUID(const DIERef &die_ref);
362+
363+
protected:
364+
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP>
365+
DIEToVariableSP;
336366

337367
SymbolFileDWARF(const SymbolFileDWARF &) = delete;
338368
const SymbolFileDWARF &operator=(const SymbolFileDWARF &) = delete;
@@ -371,10 +401,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
371401
bool ParseSupportFiles(DWARFUnit &dwarf_cu, const lldb::ModuleSP &module,
372402
FileSpecList &support_files);
373403

374-
Type *ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed);
375-
376-
Type *ResolveTypeUID(const DIERef &die_ref);
377-
378404
lldb::VariableSP ParseVariableDIE(const SymbolContext &sc,
379405
const DWARFDIE &die,
380406
const lldb::addr_t func_low_pc);
@@ -402,8 +428,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
402428
DIEArray MergeBlockAbstractParameters(const DWARFDIE &block_die,
403429
DIEArray &&variable_dies);
404430

405-
bool ClassOrStructIsVirtual(const DWARFDIE &die);
406-
407431
// Given a die_offset, figure out the symbol context representing that die.
408432
bool ResolveFunction(const DWARFDIE &die, bool include_inlines,
409433
SymbolContextList &sc_list);
@@ -415,12 +439,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
415439
void ResolveFunctionAndBlock(lldb::addr_t file_vm_addr, bool lookup_block,
416440
SymbolContext &sc);
417441

418-
virtual lldb::TypeSP
419-
FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die);
420-
421-
virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
422-
const DWARFDIE &die, ConstString type_name, bool must_be_implementation);
423-
424442
Symbol *GetObjCClassSymbol(ConstString objc_class_name);
425443

426444
lldb::TypeSP GetTypeForDIE(const DWARFDIE &die,
@@ -430,8 +448,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
430448
m_debug_map_module_wp = module_sp;
431449
}
432450

433-
SymbolFileDWARFDebugMap *GetDebugMapSymfile();
434-
435451
DWARFDIE
436452
FindBlockContainingSpecification(const DIERef &func_die_ref,
437453
dw_offset_t spec_block_die_offset);
@@ -440,8 +456,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
440456
FindBlockContainingSpecification(const DWARFDIE &die,
441457
dw_offset_t spec_block_die_offset);
442458

443-
virtual UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap();
444-
445459
bool DIEDeclContextsMatch(const DWARFDIE &die1, const DWARFDIE &die2);
446460

447461
bool ClassContainsSelector(const DWARFDIE &class_die, ConstString selector);
@@ -473,18 +487,8 @@ class SymbolFileDWARF : public SymbolFileCommon {
473487

474488
void UpdateExternalModuleListIfNeeded();
475489

476-
virtual DIEToTypePtr &GetDIEToType() { return m_die_to_type; }
477-
478490
virtual DIEToVariableSP &GetDIEToVariable() { return m_die_to_variable_sp; }
479491

480-
virtual DIEToClangType &GetForwardDeclDieToClangType() {
481-
return m_forward_decl_die_to_clang_type;
482-
}
483-
484-
virtual ClangTypeToDIE &GetForwardDeclClangTypeToDie() {
485-
return m_forward_decl_clang_type_to_die;
486-
}
487-
488492
void BuildCuTranslationTable();
489493
std::optional<uint32_t> GetDWARFUnitIndex(uint32_t cu_idx);
490494

@@ -528,8 +532,8 @@ class SymbolFileDWARF : public SymbolFileCommon {
528532
UniqueDWARFASTTypeMap m_unique_ast_type_map;
529533
DIEToTypePtr m_die_to_type;
530534
DIEToVariableSP m_die_to_variable_sp;
531-
DIEToClangType m_forward_decl_die_to_clang_type;
532-
ClangTypeToDIE m_forward_decl_clang_type_to_die;
535+
DIEToCompilerType m_forward_decl_die_to_compiler_type;
536+
CompilerTypeToDIE m_forward_decl_compiler_type_to_die;
533537
llvm::DenseMap<dw_offset_t, FileSpecList> m_type_unit_support_files;
534538
std::vector<uint32_t> m_lldb_cu_to_dwarf_unit;
535539
/// DWARF does not provide a good way for traditional (concatenating) linkers

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ bool SymbolFileDWARFDebugMap::CompleteType(CompilerType &compiler_type) {
803803
bool success = false;
804804
if (compiler_type) {
805805
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
806-
if (oso_dwarf->HasForwardDeclForClangType(compiler_type)) {
806+
if (oso_dwarf->HasForwardDeclForCompilerType(compiler_type)) {
807807
oso_dwarf->CompleteType(compiler_type);
808808
success = true;
809809
return true;

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ SymbolFileDWARF::DIEToVariableSP &SymbolFileDWARFDwo::GetDIEToVariable() {
9999
return GetBaseSymbolFile().GetDIEToVariable();
100100
}
101101

102-
SymbolFileDWARF::DIEToClangType &
103-
SymbolFileDWARFDwo::GetForwardDeclDieToClangType() {
104-
return GetBaseSymbolFile().GetForwardDeclDieToClangType();
102+
SymbolFileDWARF::DIEToCompilerType &
103+
SymbolFileDWARFDwo::GetForwardDeclDIEToCompilerType() {
104+
return GetBaseSymbolFile().GetForwardDeclDIEToCompilerType();
105105
}
106106

107-
SymbolFileDWARF::ClangTypeToDIE &
108-
SymbolFileDWARFDwo::GetForwardDeclClangTypeToDie() {
109-
return GetBaseSymbolFile().GetForwardDeclClangTypeToDie();
107+
SymbolFileDWARF::CompilerTypeToDIE &
108+
SymbolFileDWARFDwo::GetForwardDeclCompilerTypeToDIE() {
109+
return GetBaseSymbolFile().GetForwardDeclCompilerTypeToDIE();
110110
}
111111

112112
void SymbolFileDWARFDwo::GetObjCMethods(

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF {
5656

5757
DIEToVariableSP &GetDIEToVariable() override;
5858

59-
DIEToClangType &GetForwardDeclDieToClangType() override;
59+
DIEToCompilerType &GetForwardDeclDIEToCompilerType() override;
6060

61-
ClangTypeToDIE &GetForwardDeclClangTypeToDie() override;
61+
CompilerTypeToDIE &GetForwardDeclCompilerTypeToDIE() override;
6262

6363
UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap() override;
6464

0 commit comments

Comments
 (0)