[Lldb-commits] [lldb] 8a98287 - [lldb][NFCish] Move DWARFDebugInfoEntry::GetQualifiedName() into DWARFASTParserClang
Arthur Eubanks via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 14 15:37:25 PDT 2022
Author: Arthur Eubanks
Date: 2022-10-14T15:36:58-07:00
New Revision: 8a98287f255b974a8636c50a662e13ad61a59446
URL: https://github.com/llvm/llvm-project/commit/8a98287f255b974a8636c50a662e13ad61a59446
DIFF: https://github.com/llvm/llvm-project/commit/8a98287f255b974a8636c50a662e13ad61a59446.diff
LOG: [lldb][NFCish] Move DWARFDebugInfoEntry::GetQualifiedName() into DWARFASTParserClang
In D134378, we'll need the clang AST to be able to construct the qualified in some cases.
This makes logging in one place slightly less informative.
Reviewed By: dblaikie, Michael137
Differential Revision: https://reviews.llvm.org/D135979
Added:
Modified:
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 988dc0236652..3f2614af64d4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1523,6 +1523,55 @@ TypeSP DWARFASTParserClang::UpdateSymbolContextScopeForType(
return type_sp;
}
+std::string
+DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE &die) {
+ if (!die.IsValid())
+ return "";
+ const char *name = die.GetName();
+ if (!name)
+ return "";
+ std::string qualified_name;
+ DWARFDIE parent_decl_ctx_die = die.GetParentDeclContextDIE();
+ // TODO: change this to get the correct decl context parent....
+ while (parent_decl_ctx_die) {
+ const dw_tag_t parent_tag = parent_decl_ctx_die.Tag();
+ switch (parent_tag) {
+ case DW_TAG_namespace: {
+ if (const char *namespace_name = parent_decl_ctx_die.GetName()) {
+ qualified_name.insert(0, "::");
+ qualified_name.insert(0, namespace_name);
+ } else {
+ qualified_name.insert(0, "(anonymous namespace)::");
+ }
+ parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
+ break;
+ }
+
+ case DW_TAG_class_type:
+ case DW_TAG_structure_type:
+ case DW_TAG_union_type: {
+ if (const char *class_union_struct_name = parent_decl_ctx_die.GetName()) {
+ qualified_name.insert(0, "::");
+ qualified_name.insert(0, class_union_struct_name);
+ }
+ parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
+ break;
+ }
+
+ default:
+ parent_decl_ctx_die.Clear();
+ break;
+ }
+ }
+
+ if (qualified_name.empty())
+ qualified_name.append("::");
+
+ qualified_name.append(name);
+
+ return qualified_name;
+}
+
TypeSP
DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
const DWARFDIE &die,
@@ -1548,8 +1597,8 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
// For C++, we rely solely upon the one definition rule that says
// only one thing can exist at a given decl context. We ignore the
// file and line that things are declared on.
- std::string qualified_name;
- if (die.GetQualifiedName(qualified_name))
+ std::string qualified_name = GetCPlusPlusQualifiedName(die);
+ if (!qualified_name.empty())
unique_typename = ConstString(qualified_name);
unique_decl.Clear();
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index a8640b4a5693..860e5f4f7d5b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -121,11 +121,14 @@ class DWARFASTParserClang : public DWARFASTParser {
bool ParseTemplateDIE(const DWARFDIE &die,
lldb_private::TypeSystemClang::TemplateParameterInfos
&template_param_infos);
+
bool ParseTemplateParameterInfos(
const DWARFDIE &parent_die,
lldb_private::TypeSystemClang::TemplateParameterInfos
&template_param_infos);
+ std::string GetCPlusPlusQualifiedName(const DWARFDIE &die);
+
bool ParseChildMembers(
const DWARFDIE &die, lldb_private::CompilerType &class_compiler_type,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index e8492079af88..7b9da6fa166f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -210,13 +210,6 @@ const char *DWARFDIE::GetPubname() const {
return nullptr;
}
-const char *DWARFDIE::GetQualifiedName(std::string &storage) const {
- if (IsValid())
- return m_die->GetQualifiedName(m_cu, storage);
- else
- return nullptr;
-}
-
// GetName
//
// Get value of the DW_AT_name attribute and place that value into the supplied
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
index 7ce9550a081e..3564f757dbd8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ -30,8 +30,6 @@ class DWARFDIE : public DWARFBaseDIE {
const char *GetPubname() const;
- const char *GetQualifiedName(std::string &storage) const;
-
using DWARFBaseDIE::GetName;
void GetName(lldb_private::Stream &s) const;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 5a584e15c397..c10eae311a93 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -798,66 +798,6 @@ DWARFDebugInfoEntry::GetParentDeclContextDIE(
return DWARFDIE();
}
-const char *DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
- std::string &storage) const {
- DWARFAttributes attributes;
- GetAttributes(cu, attributes, Recurse::yes);
- return GetQualifiedName(cu, attributes, storage);
-}
-
-const char *
-DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
- const DWARFAttributes &attributes,
- std::string &storage) const {
-
- const char *name = GetName(cu);
-
- if (name) {
- DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
- storage.clear();
- // TODO: change this to get the correct decl context parent....
- while (parent_decl_ctx_die) {
- const dw_tag_t parent_tag = parent_decl_ctx_die.Tag();
- switch (parent_tag) {
- case DW_TAG_namespace: {
- const char *namespace_name = parent_decl_ctx_die.GetName();
- if (namespace_name) {
- storage.insert(0, "::");
- storage.insert(0, namespace_name);
- } else {
- storage.insert(0, "(anonymous namespace)::");
- }
- parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
- } break;
-
- case DW_TAG_class_type:
- case DW_TAG_structure_type:
- case DW_TAG_union_type: {
- const char *class_union_struct_name = parent_decl_ctx_die.GetName();
-
- if (class_union_struct_name) {
- storage.insert(0, "::");
- storage.insert(0, class_union_struct_name);
- }
- parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
- } break;
-
- default:
- parent_decl_ctx_die.Clear();
- break;
- }
- }
-
- if (storage.empty())
- storage.append("::");
-
- storage.append(name);
- }
- if (storage.empty())
- return nullptr;
- return storage.c_str();
-}
-
lldb::offset_t DWARFDebugInfoEntry::GetFirstAttributeOffset() const {
return GetOffset() + llvm::getULEB128Size(m_abbr_idx);
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
index 63d6aa79240b..de34dc566069 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -99,11 +99,6 @@ class DWARFDebugInfoEntry {
const char *GetPubname(const DWARFUnit *cu) const;
- const char *GetQualifiedName(DWARFUnit *cu, std::string &storage) const;
-
- const char *GetQualifiedName(DWARFUnit *cu, const DWARFAttributes &attributes,
- std::string &storage) const;
-
bool GetDIENamesAndRanges(
DWARFUnit *cu, const char *&name, const char *&mangled,
DWARFRangeList &rangeList, int &decl_file, int &decl_line,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 06c12454d9fd..d029e4da8617 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2960,8 +2960,6 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
if (!try_resolving_type) {
if (log) {
- std::string qualified_name;
- type_die.GetQualifiedName(qualified_name);
GetObjectFile()->GetModule()->LogMessage(
log,
"SymbolFileDWARF::"
@@ -2969,7 +2967,7 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
"qualified-name='%s') ignoring die=0x%8.8x (%s)",
DW_TAG_value_to_name(dwarf_decl_ctx[0].tag),
dwarf_decl_ctx.GetQualifiedName(), type_die.GetOffset(),
- qualified_name.c_str());
+ type_die.GetName());
}
return true;
}
More information about the lldb-commits
mailing list