[Lldb-commits] [lldb] [lldb/DWARF] Remove some dead code (PR #95127)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 11 07:37:20 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Pavel Labath (labath)
<details>
<summary>Changes</summary>
`GetDeclContextDIEs` and `DIEDeclContextsMatch` are unused (possibly since we added support for simplified template names, but I haven't checked). `GetDeclContextDIEs` is also very similar (but subtly different) from `GetDeclContext` and `GetTypeLookupContext`.
I am keeping `GetParentDeclContextDIE` as that one still has some callers, but I want to look into the possibility of merging it with at least one of the functions mentioned above.
---
Full diff: https://github.com/llvm/llvm-project/pull/95127.diff
4 Files Affected:
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (-14)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h (-3)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (-89)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (-2)
``````````diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index 7cf92adc6ef57..0ef94ed9f17c3 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -367,20 +367,6 @@ lldb_private::Type *DWARFDIE::ResolveTypeUID(const DWARFDIE &die) const {
return nullptr;
}
-std::vector<DWARFDIE> DWARFDIE::GetDeclContextDIEs() const {
- if (!IsValid())
- return {};
-
- std::vector<DWARFDIE> result;
- DWARFDIE parent = GetParentDeclContextDIE();
- while (parent.IsValid() && parent.GetDIE() != GetDIE()) {
- result.push_back(std::move(parent));
- parent = parent.GetParentDeclContextDIE();
- }
-
- return result;
-}
-
static void GetDeclContextImpl(DWARFDIE die,
llvm::SmallSet<lldb::user_id_t, 4> &seen,
std::vector<CompilerContext> &context) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
index 511ca62d0197a..c74a82061fccf 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ -69,9 +69,6 @@ class DWARFDIE : public DWARFBaseDIE {
DWARFDIE
GetParentDeclContextDIE() const;
- // DeclContext related functions
- std::vector<DWARFDIE> GetDeclContextDIEs() const;
-
/// Return this DIE's decl context as it is needed to look up types
/// in Clang modules. This context will include any modules or functions that
/// the type is declared in so an exact module match can be efficiently made.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index a52a7d6767374..d9e81f9c105b2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3039,95 +3039,6 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
return type_sp;
}
-// This function helps to ensure that the declaration contexts match for two
-// different DIEs. Often times debug information will refer to a forward
-// declaration of a type (the equivalent of "struct my_struct;". There will
-// often be a declaration of that type elsewhere that has the full definition.
-// When we go looking for the full type "my_struct", we will find one or more
-// matches in the accelerator tables and we will then need to make sure the
-// type was in the same declaration context as the original DIE. This function
-// can efficiently compare two DIEs and will return true when the declaration
-// context matches, and false when they don't.
-bool SymbolFileDWARF::DIEDeclContextsMatch(const DWARFDIE &die1,
- const DWARFDIE &die2) {
- if (die1 == die2)
- return true;
-
- std::vector<DWARFDIE> decl_ctx_1;
- std::vector<DWARFDIE> decl_ctx_2;
- // The declaration DIE stack is a stack of the declaration context DIEs all
- // the way back to the compile unit. If a type "T" is declared inside a class
- // "B", and class "B" is declared inside a class "A" and class "A" is in a
- // namespace "lldb", and the namespace is in a compile unit, there will be a
- // stack of DIEs:
- //
- // [0] DW_TAG_class_type for "B"
- // [1] DW_TAG_class_type for "A"
- // [2] DW_TAG_namespace for "lldb"
- // [3] DW_TAG_compile_unit or DW_TAG_partial_unit for the source file.
- //
- // We grab both contexts and make sure that everything matches all the way
- // back to the compiler unit.
-
- // First lets grab the decl contexts for both DIEs
- decl_ctx_1 = die1.GetDeclContextDIEs();
- decl_ctx_2 = die2.GetDeclContextDIEs();
- // Make sure the context arrays have the same size, otherwise we are done
- const size_t count1 = decl_ctx_1.size();
- const size_t count2 = decl_ctx_2.size();
- if (count1 != count2)
- return false;
-
- // Make sure the DW_TAG values match all the way back up the compile unit. If
- // they don't, then we are done.
- DWARFDIE decl_ctx_die1;
- DWARFDIE decl_ctx_die2;
- size_t i;
- for (i = 0; i < count1; i++) {
- decl_ctx_die1 = decl_ctx_1[i];
- decl_ctx_die2 = decl_ctx_2[i];
- if (decl_ctx_die1.Tag() != decl_ctx_die2.Tag())
- return false;
- }
-#ifndef NDEBUG
-
- // Make sure the top item in the decl context die array is always
- // DW_TAG_compile_unit or DW_TAG_partial_unit. If it isn't then
- // something went wrong in the DWARFDIE::GetDeclContextDIEs()
- // function.
- dw_tag_t cu_tag = decl_ctx_1[count1 - 1].Tag();
- UNUSED_IF_ASSERT_DISABLED(cu_tag);
- assert(cu_tag == DW_TAG_compile_unit || cu_tag == DW_TAG_partial_unit);
-
-#endif
- // Always skip the compile unit when comparing by only iterating up to "count
- // - 1". Here we compare the names as we go.
- for (i = 0; i < count1 - 1; i++) {
- decl_ctx_die1 = decl_ctx_1[i];
- decl_ctx_die2 = decl_ctx_2[i];
- const char *name1 = decl_ctx_die1.GetName();
- const char *name2 = decl_ctx_die2.GetName();
- // If the string was from a DW_FORM_strp, then the pointer will often be
- // the same!
- if (name1 == name2)
- continue;
-
- // Name pointers are not equal, so only compare the strings if both are not
- // NULL.
- if (name1 && name2) {
- // If the strings don't compare, we are done...
- if (strcmp(name1, name2) != 0)
- return false;
- } else {
- // One name was NULL while the other wasn't
- return false;
- }
- }
- // We made it through all of the checks and the declaration contexts are
- // equal.
- return true;
-}
-
TypeSP
SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
TypeSP type_sp;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 7282c08c6857c..5d3654efcce54 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -461,8 +461,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
FindBlockContainingSpecification(const DWARFDIE &die,
dw_offset_t spec_block_die_offset);
- bool DIEDeclContextsMatch(const DWARFDIE &die1, const DWARFDIE &die2);
-
bool ClassContainsSelector(const DWARFDIE &class_die, ConstString selector);
/// Parse call site entries (DW_TAG_call_site), including any nested call site
``````````
</details>
https://github.com/llvm/llvm-project/pull/95127
More information about the lldb-commits
mailing list