[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.
This commit is contained in:
parent
9803196849
commit
9ef9db7087
@ -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 (!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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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 =
|
||||
@ -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);
|
||||
clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE(die, nullptr);
|
||||
|
||||
PrepareContextToReceiveMembers(m_ast, GetClangASTImporter(), decl_ctx, die,
|
||||
attrs.name.GetCString());
|
||||
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;
|
||||
}
|
||||
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));
|
||||
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();
|
||||
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());
|
||||
}
|
||||
|
||||
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);
|
||||
return TypeSP();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
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
|
||||
@ -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());
|
||||
|
||||
@ -335,14 +335,6 @@ public:
|
||||
|
||||
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;
|
||||
|
||||
@ -543,7 +535,6 @@ protected:
|
||||
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;
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -72,8 +72,6 @@ protected:
|
||||
|
||||
DIEToVariableSP &GetDIEToVariable() override;
|
||||
|
||||
DIEToCompilerType &GetForwardDeclDIEToCompilerType() override;
|
||||
|
||||
CompilerTypeToDIE &GetForwardDeclCompilerTypeToDIE() override;
|
||||
|
||||
UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap() override;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user