[Lldb-commits] [lldb] [lldb][DWARF] Remove m_forward_decl_die_to_compiler_type as it never actually being used. (PR #89427)

2024-04-19 Thread Zequan Wu via lldb-commits

https://github.com/ZequanWu created 
https://github.com/llvm/llvm-project/pull/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 creating two CompilerTypes for the same DIE. So, this map is unnecessary 
and unseful.

>From 200e0caa806ca7d84e8722d6408c8c37ffb9f598 Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Fri, 19 Apr 2024 13:57:06 -0400
Subject: [PATCH] [lldb][DWARF] Remove m_forward_decl_die_to_compiler_type as
 it never actually being used.

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 148 --
 .../SymbolFile/DWARF/SymbolFileDWARF.h|   9 --
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp   |   5 -
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.h |   2 -
 4 files changed, 65 insertions(+), 99 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 54d06b1115a229..41d81fbcf1b087 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -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 =
@@ -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, G

[Lldb-commits] [lldb] [lldb][DWARF] Remove m_forward_decl_die_to_compiler_type as it never actually being used. (PR #89427)

2024-04-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Zequan Wu (ZequanWu)


Changes

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 creating two CompilerTypes for the same DIE. So, this map is unnecessary 
and unseful.

---
Full diff: https://github.com/llvm/llvm-project/pull/89427.diff


4 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(+65-83) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (-9) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (-5) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (-2) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 54d06b1115a229..41d81fbcf1b087 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -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 =
@@ -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

[Lldb-commits] [lldb] [lldb][DWARF] Remove m_forward_decl_die_to_compiler_type as it never actually being used. (PR #89427)

2024-04-19 Thread Zequan Wu via lldb-commits

https://github.com/ZequanWu edited 
https://github.com/llvm/llvm-project/pull/89427
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Remove m_forward_decl_die_to_compiler_type as it never actually being used. (PR #89427)

2024-04-22 Thread Michael Buch via lldb-commits

Michael137 wrote:

LGTM thanks for the cleanup!

https://github.com/llvm/llvm-project/pull/89427
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Remove m_forward_decl_die_to_compiler_type as it never actually being used. (PR #89427)

2024-04-22 Thread Michael Buch via lldb-commits

https://github.com/Michael137 approved this pull request.


https://github.com/llvm/llvm-project/pull/89427
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Remove m_forward_decl_die_to_compiler_type as it never actually being used. (PR #89427)

2024-04-22 Thread Zequan Wu via lldb-commits

https://github.com/ZequanWu closed 
https://github.com/llvm/llvm-project/pull/89427
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits