Skip to content

[lldb][DWARF] Remove m_forward_decl_die_to_compiler_type as it never actually being used. #89427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 65 additions & 83 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,36 +854,26 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
DW_TAG_value_to_name(tag), type_name_cstr);

CompilerType enumerator_clang_type;
CompilerType clang_type;
clang_type = CompilerType(
m_ast.weak_from_this(),
dwarf->GetForwardDeclDIEToCompilerType().lookup(die.GetDIE()));
if (!clang_type) {
if (attrs.type.IsValid()) {
Type *enumerator_type =
dwarf->ResolveTypeUID(attrs.type.Reference(), true);
if (enumerator_type)
enumerator_clang_type = enumerator_type->GetFullCompilerType();
}
if (attrs.type.IsValid()) {
Type *enumerator_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true);
if (enumerator_type)
enumerator_clang_type = enumerator_type->GetFullCompilerType();
}

if (!enumerator_clang_type) {
if (attrs.byte_size) {
enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
"", DW_ATE_signed, *attrs.byte_size * 8);
} else {
enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt);
}
if (!enumerator_clang_type) {
if (attrs.byte_size) {
enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
"", DW_ATE_signed, *attrs.byte_size * 8);
} else {
enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt);
}

clang_type = m_ast.CreateEnumerationType(
attrs.name.GetStringRef(),
GetClangDeclContextContainingDIE(die, nullptr),
GetOwningClangModule(die), attrs.decl, enumerator_clang_type,
attrs.is_scoped_enum);
} else {
enumerator_clang_type = m_ast.GetEnumerationIntegerType(clang_type);
}

CompilerType clang_type = m_ast.CreateEnumerationType(
attrs.name.GetStringRef(), GetClangDeclContextContainingDIE(die, nullptr),
GetOwningClangModule(die), attrs.decl, enumerator_clang_type,
attrs.is_scoped_enum);

LinkDeclContextToDIE(TypeSystemClang::GetDeclContextForType(clang_type), die);

type_sp =
Expand Down Expand Up @@ -1781,65 +1771,59 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
assert(tag_decl_kind != -1);
UNUSED_IF_ASSERT_DISABLED(tag_decl_kind);
bool clang_type_was_created = false;
clang_type = CompilerType(
m_ast.weak_from_this(),
dwarf->GetForwardDeclDIEToCompilerType().lookup(die.GetDIE()));
if (!clang_type) {
clang::DeclContext *decl_ctx =
GetClangDeclContextContainingDIE(die, nullptr);

PrepareContextToReceiveMembers(m_ast, GetClangASTImporter(), decl_ctx, die,
attrs.name.GetCString());

if (attrs.accessibility == eAccessNone && decl_ctx) {
// Check the decl context that contains this class/struct/union. If
// it is a class we must give it an accessibility.
const clang::Decl::Kind containing_decl_kind = decl_ctx->getDeclKind();
if (DeclKindIsCXXClass(containing_decl_kind))
attrs.accessibility = default_accessibility;
}

ClangASTMetadata metadata;
metadata.SetUserID(die.GetID());
metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));

TypeSystemClang::TemplateParameterInfos template_param_infos;
if (ParseTemplateParameterInfos(die, template_param_infos)) {
clang::ClassTemplateDecl *class_template_decl =
m_ast.ParseClassTemplateDecl(
decl_ctx, GetOwningClangModule(die), attrs.accessibility,
attrs.name.GetCString(), tag_decl_kind, template_param_infos);
if (!class_template_decl) {
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
"SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" "
"clang::ClassTemplateDecl failed to return a decl.",
static_cast<void *>(this), die.GetOffset(),
DW_TAG_value_to_name(tag), attrs.name.GetCString());
}
return TypeSP();
}
clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE(die, nullptr);

clang::ClassTemplateSpecializationDecl *class_specialization_decl =
m_ast.CreateClassTemplateSpecializationDecl(
decl_ctx, GetOwningClangModule(die), class_template_decl,
tag_decl_kind, template_param_infos);
clang_type = m_ast.CreateClassTemplateSpecializationType(
class_specialization_decl);
clang_type_was_created = true;
PrepareContextToReceiveMembers(m_ast, GetClangASTImporter(), decl_ctx, die,
attrs.name.GetCString());

m_ast.SetMetadata(class_template_decl, metadata);
m_ast.SetMetadata(class_specialization_decl, metadata);
}
if (attrs.accessibility == eAccessNone && decl_ctx) {
// Check the decl context that contains this class/struct/union. If
// it is a class we must give it an accessibility.
const clang::Decl::Kind containing_decl_kind = decl_ctx->getDeclKind();
if (DeclKindIsCXXClass(containing_decl_kind))
attrs.accessibility = default_accessibility;
}

ClangASTMetadata metadata;
metadata.SetUserID(die.GetID());
metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));

if (!clang_type_was_created) {
clang_type_was_created = true;
clang_type = m_ast.CreateRecordType(
decl_ctx, GetOwningClangModule(die), attrs.accessibility,
attrs.name.GetCString(), tag_decl_kind, attrs.class_language,
&metadata, attrs.exports_symbols);
TypeSystemClang::TemplateParameterInfos template_param_infos;
if (ParseTemplateParameterInfos(die, template_param_infos)) {
clang::ClassTemplateDecl *class_template_decl =
m_ast.ParseClassTemplateDecl(
decl_ctx, GetOwningClangModule(die), attrs.accessibility,
attrs.name.GetCString(), tag_decl_kind, template_param_infos);
if (!class_template_decl) {
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
"SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" "
"clang::ClassTemplateDecl failed to return a decl.",
static_cast<void *>(this), die.GetOffset(),
DW_TAG_value_to_name(tag), attrs.name.GetCString());
}
return TypeSP();
}

clang::ClassTemplateSpecializationDecl *class_specialization_decl =
m_ast.CreateClassTemplateSpecializationDecl(
decl_ctx, GetOwningClangModule(die), class_template_decl,
tag_decl_kind, template_param_infos);
clang_type =
m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
clang_type_was_created = true;

m_ast.SetMetadata(class_template_decl, metadata);
m_ast.SetMetadata(class_specialization_decl, metadata);
}

if (!clang_type_was_created) {
clang_type_was_created = true;
clang_type = m_ast.CreateRecordType(
decl_ctx, GetOwningClangModule(die), attrs.accessibility,
attrs.name.GetCString(), tag_decl_kind, attrs.class_language, &metadata,
attrs.exports_symbols);
}

// Store a forward declaration to this class type in case any
Expand Down Expand Up @@ -1924,8 +1908,6 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
// Can't assume m_ast.GetSymbolFile() is actually a
// SymbolFileDWARF, it can be a SymbolFileDWARFDebugMap for Apple
// binaries.
dwarf->GetForwardDeclDIEToCompilerType()[die.GetDIE()] =
clang_type.GetOpaqueQualType();
dwarf->GetForwardDeclCompilerTypeToDIE().try_emplace(
ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType(),
*die.GetDIERef());
Expand Down
9 changes: 0 additions & 9 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,6 @@ class SymbolFileDWARF : public SymbolFileCommon {

virtual DIEToTypePtr &GetDIEToType() { return m_die_to_type; }

typedef llvm::DenseMap<const DWARFDebugInfoEntry *,
lldb::opaque_compiler_type_t>
DIEToCompilerType;

virtual DIEToCompilerType &GetForwardDeclDIEToCompilerType() {
return m_forward_decl_die_to_compiler_type;
}

typedef llvm::DenseMap<lldb::opaque_compiler_type_t, DIERef>
CompilerTypeToDIE;

Expand Down Expand Up @@ -543,7 +535,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
UniqueDWARFASTTypeMap m_unique_ast_type_map;
DIEToTypePtr m_die_to_type;
DIEToVariableSP m_die_to_variable_sp;
DIEToCompilerType m_forward_decl_die_to_compiler_type;
CompilerTypeToDIE m_forward_decl_compiler_type_to_die;
llvm::DenseMap<dw_offset_t, std::unique_ptr<SupportFileList>>
m_type_unit_support_files;
Expand Down
5 changes: 0 additions & 5 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ SymbolFileDWARF::DIEToVariableSP &SymbolFileDWARFDwo::GetDIEToVariable() {
return GetBaseSymbolFile().GetDIEToVariable();
}

SymbolFileDWARF::DIEToCompilerType &
SymbolFileDWARFDwo::GetForwardDeclDIEToCompilerType() {
return GetBaseSymbolFile().GetForwardDeclDIEToCompilerType();
}

SymbolFileDWARF::CompilerTypeToDIE &
SymbolFileDWARFDwo::GetForwardDeclCompilerTypeToDIE() {
return GetBaseSymbolFile().GetForwardDeclCompilerTypeToDIE();
Expand Down
2 changes: 0 additions & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF {

DIEToVariableSP &GetDIEToVariable() override;

DIEToCompilerType &GetForwardDeclDIEToCompilerType() override;

CompilerTypeToDIE &GetForwardDeclCompilerTypeToDIE() override;

UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap() override;
Expand Down