Skip to content

Commit 9ef9db7

Browse files
authored
[lldb][DWARF] Remove m_forward_decl_die_to_compiler_type as it never actually being used. (#89427)
This removes `m_forward_decl_die_to_compiler_type` which is a map from `const DWARFDebugInfoEntry *` to `lldb::opaque_compiler_type_t`. This map is currently used in `DWARFASTParserClang::ParseEnum` and `DWARFASTParserClang::ParseStructureLikeDIE` to avoid creating duplicate CompilerType for the specific DIE. But before entering these two functions in `DWARFASTParserClang::ParseTypeFromDWARF`, we already checked with `SymbolFileDWARF::GetDIEToType()` if we have a Type created from this DIE to avoid trying to parse the same DIE twice. So, this map is unnecessary and not useful.
1 parent 9803196 commit 9ef9db7

File tree

4 files changed

+65
-99
lines changed

4 files changed

+65
-99
lines changed

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

Lines changed: 65 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -854,36 +854,26 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
854854
DW_TAG_value_to_name(tag), type_name_cstr);
855855

856856
CompilerType enumerator_clang_type;
857-
CompilerType clang_type;
858-
clang_type = CompilerType(
859-
m_ast.weak_from_this(),
860-
dwarf->GetForwardDeclDIEToCompilerType().lookup(die.GetDIE()));
861-
if (!clang_type) {
862-
if (attrs.type.IsValid()) {
863-
Type *enumerator_type =
864-
dwarf->ResolveTypeUID(attrs.type.Reference(), true);
865-
if (enumerator_type)
866-
enumerator_clang_type = enumerator_type->GetFullCompilerType();
867-
}
857+
if (attrs.type.IsValid()) {
858+
Type *enumerator_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true);
859+
if (enumerator_type)
860+
enumerator_clang_type = enumerator_type->GetFullCompilerType();
861+
}
868862

869-
if (!enumerator_clang_type) {
870-
if (attrs.byte_size) {
871-
enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
872-
"", DW_ATE_signed, *attrs.byte_size * 8);
873-
} else {
874-
enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt);
875-
}
863+
if (!enumerator_clang_type) {
864+
if (attrs.byte_size) {
865+
enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
866+
"", DW_ATE_signed, *attrs.byte_size * 8);
867+
} else {
868+
enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt);
876869
}
877-
878-
clang_type = m_ast.CreateEnumerationType(
879-
attrs.name.GetStringRef(),
880-
GetClangDeclContextContainingDIE(die, nullptr),
881-
GetOwningClangModule(die), attrs.decl, enumerator_clang_type,
882-
attrs.is_scoped_enum);
883-
} else {
884-
enumerator_clang_type = m_ast.GetEnumerationIntegerType(clang_type);
885870
}
886871

872+
CompilerType clang_type = m_ast.CreateEnumerationType(
873+
attrs.name.GetStringRef(), GetClangDeclContextContainingDIE(die, nullptr),
874+
GetOwningClangModule(die), attrs.decl, enumerator_clang_type,
875+
attrs.is_scoped_enum);
876+
887877
LinkDeclContextToDIE(TypeSystemClang::GetDeclContextForType(clang_type), die);
888878

889879
type_sp =
@@ -1781,65 +1771,59 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
17811771
assert(tag_decl_kind != -1);
17821772
UNUSED_IF_ASSERT_DISABLED(tag_decl_kind);
17831773
bool clang_type_was_created = false;
1784-
clang_type = CompilerType(
1785-
m_ast.weak_from_this(),
1786-
dwarf->GetForwardDeclDIEToCompilerType().lookup(die.GetDIE()));
1787-
if (!clang_type) {
1788-
clang::DeclContext *decl_ctx =
1789-
GetClangDeclContextContainingDIE(die, nullptr);
1790-
1791-
PrepareContextToReceiveMembers(m_ast, GetClangASTImporter(), decl_ctx, die,
1792-
attrs.name.GetCString());
1793-
1794-
if (attrs.accessibility == eAccessNone && decl_ctx) {
1795-
// Check the decl context that contains this class/struct/union. If
1796-
// it is a class we must give it an accessibility.
1797-
const clang::Decl::Kind containing_decl_kind = decl_ctx->getDeclKind();
1798-
if (DeclKindIsCXXClass(containing_decl_kind))
1799-
attrs.accessibility = default_accessibility;
1800-
}
1801-
1802-
ClangASTMetadata metadata;
1803-
metadata.SetUserID(die.GetID());
1804-
metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));
1805-
1806-
TypeSystemClang::TemplateParameterInfos template_param_infos;
1807-
if (ParseTemplateParameterInfos(die, template_param_infos)) {
1808-
clang::ClassTemplateDecl *class_template_decl =
1809-
m_ast.ParseClassTemplateDecl(
1810-
decl_ctx, GetOwningClangModule(die), attrs.accessibility,
1811-
attrs.name.GetCString(), tag_decl_kind, template_param_infos);
1812-
if (!class_template_decl) {
1813-
if (log) {
1814-
dwarf->GetObjectFile()->GetModule()->LogMessage(
1815-
log,
1816-
"SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" "
1817-
"clang::ClassTemplateDecl failed to return a decl.",
1818-
static_cast<void *>(this), die.GetOffset(),
1819-
DW_TAG_value_to_name(tag), attrs.name.GetCString());
1820-
}
1821-
return TypeSP();
1822-
}
1774+
clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE(die, nullptr);
18231775

1824-
clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1825-
m_ast.CreateClassTemplateSpecializationDecl(
1826-
decl_ctx, GetOwningClangModule(die), class_template_decl,
1827-
tag_decl_kind, template_param_infos);
1828-
clang_type = m_ast.CreateClassTemplateSpecializationType(
1829-
class_specialization_decl);
1830-
clang_type_was_created = true;
1776+
PrepareContextToReceiveMembers(m_ast, GetClangASTImporter(), decl_ctx, die,
1777+
attrs.name.GetCString());
18311778

1832-
m_ast.SetMetadata(class_template_decl, metadata);
1833-
m_ast.SetMetadata(class_specialization_decl, metadata);
1834-
}
1779+
if (attrs.accessibility == eAccessNone && decl_ctx) {
1780+
// Check the decl context that contains this class/struct/union. If
1781+
// it is a class we must give it an accessibility.
1782+
const clang::Decl::Kind containing_decl_kind = decl_ctx->getDeclKind();
1783+
if (DeclKindIsCXXClass(containing_decl_kind))
1784+
attrs.accessibility = default_accessibility;
1785+
}
1786+
1787+
ClangASTMetadata metadata;
1788+
metadata.SetUserID(die.GetID());
1789+
metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));
18351790

1836-
if (!clang_type_was_created) {
1837-
clang_type_was_created = true;
1838-
clang_type = m_ast.CreateRecordType(
1839-
decl_ctx, GetOwningClangModule(die), attrs.accessibility,
1840-
attrs.name.GetCString(), tag_decl_kind, attrs.class_language,
1841-
&metadata, attrs.exports_symbols);
1791+
TypeSystemClang::TemplateParameterInfos template_param_infos;
1792+
if (ParseTemplateParameterInfos(die, template_param_infos)) {
1793+
clang::ClassTemplateDecl *class_template_decl =
1794+
m_ast.ParseClassTemplateDecl(
1795+
decl_ctx, GetOwningClangModule(die), attrs.accessibility,
1796+
attrs.name.GetCString(), tag_decl_kind, template_param_infos);
1797+
if (!class_template_decl) {
1798+
if (log) {
1799+
dwarf->GetObjectFile()->GetModule()->LogMessage(
1800+
log,
1801+
"SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" "
1802+
"clang::ClassTemplateDecl failed to return a decl.",
1803+
static_cast<void *>(this), die.GetOffset(),
1804+
DW_TAG_value_to_name(tag), attrs.name.GetCString());
1805+
}
1806+
return TypeSP();
18421807
}
1808+
1809+
clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1810+
m_ast.CreateClassTemplateSpecializationDecl(
1811+
decl_ctx, GetOwningClangModule(die), class_template_decl,
1812+
tag_decl_kind, template_param_infos);
1813+
clang_type =
1814+
m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
1815+
clang_type_was_created = true;
1816+
1817+
m_ast.SetMetadata(class_template_decl, metadata);
1818+
m_ast.SetMetadata(class_specialization_decl, metadata);
1819+
}
1820+
1821+
if (!clang_type_was_created) {
1822+
clang_type_was_created = true;
1823+
clang_type = m_ast.CreateRecordType(
1824+
decl_ctx, GetOwningClangModule(die), attrs.accessibility,
1825+
attrs.name.GetCString(), tag_decl_kind, attrs.class_language, &metadata,
1826+
attrs.exports_symbols);
18431827
}
18441828

18451829
// Store a forward declaration to this class type in case any
@@ -1924,8 +1908,6 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
19241908
// Can't assume m_ast.GetSymbolFile() is actually a
19251909
// SymbolFileDWARF, it can be a SymbolFileDWARFDebugMap for Apple
19261910
// binaries.
1927-
dwarf->GetForwardDeclDIEToCompilerType()[die.GetDIE()] =
1928-
clang_type.GetOpaqueQualType();
19291911
dwarf->GetForwardDeclCompilerTypeToDIE().try_emplace(
19301912
ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType(),
19311913
*die.GetDIERef());

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
335335

336336
virtual DIEToTypePtr &GetDIEToType() { return m_die_to_type; }
337337

338-
typedef llvm::DenseMap<const DWARFDebugInfoEntry *,
339-
lldb::opaque_compiler_type_t>
340-
DIEToCompilerType;
341-
342-
virtual DIEToCompilerType &GetForwardDeclDIEToCompilerType() {
343-
return m_forward_decl_die_to_compiler_type;
344-
}
345-
346338
typedef llvm::DenseMap<lldb::opaque_compiler_type_t, DIERef>
347339
CompilerTypeToDIE;
348340

@@ -543,7 +535,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
543535
UniqueDWARFASTTypeMap m_unique_ast_type_map;
544536
DIEToTypePtr m_die_to_type;
545537
DIEToVariableSP m_die_to_variable_sp;
546-
DIEToCompilerType m_forward_decl_die_to_compiler_type;
547538
CompilerTypeToDIE m_forward_decl_compiler_type_to_die;
548539
llvm::DenseMap<dw_offset_t, std::unique_ptr<SupportFileList>>
549540
m_type_unit_support_files;

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ SymbolFileDWARF::DIEToVariableSP &SymbolFileDWARFDwo::GetDIEToVariable() {
110110
return GetBaseSymbolFile().GetDIEToVariable();
111111
}
112112

113-
SymbolFileDWARF::DIEToCompilerType &
114-
SymbolFileDWARFDwo::GetForwardDeclDIEToCompilerType() {
115-
return GetBaseSymbolFile().GetForwardDeclDIEToCompilerType();
116-
}
117-
118113
SymbolFileDWARF::CompilerTypeToDIE &
119114
SymbolFileDWARFDwo::GetForwardDeclCompilerTypeToDIE() {
120115
return GetBaseSymbolFile().GetForwardDeclCompilerTypeToDIE();

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF {
7272

7373
DIEToVariableSP &GetDIEToVariable() override;
7474

75-
DIEToCompilerType &GetForwardDeclDIEToCompilerType() override;
76-
7775
CompilerTypeToDIE &GetForwardDeclCompilerTypeToDIE() override;
7876

7977
UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap() override;

0 commit comments

Comments
 (0)