Skip to content

Commit 56f668c

Browse files
authored
[lldb/DWARF] Remove some dead code (#95127)
`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.
1 parent 727ecbe commit 56f668c

File tree

4 files changed

+0
-108
lines changed

4 files changed

+0
-108
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -367,20 +367,6 @@ lldb_private::Type *DWARFDIE::ResolveTypeUID(const DWARFDIE &die) const {
367367
return nullptr;
368368
}
369369

370-
std::vector<DWARFDIE> DWARFDIE::GetDeclContextDIEs() const {
371-
if (!IsValid())
372-
return {};
373-
374-
std::vector<DWARFDIE> result;
375-
DWARFDIE parent = GetParentDeclContextDIE();
376-
while (parent.IsValid() && parent.GetDIE() != GetDIE()) {
377-
result.push_back(std::move(parent));
378-
parent = parent.GetParentDeclContextDIE();
379-
}
380-
381-
return result;
382-
}
383-
384370
static void GetDeclContextImpl(DWARFDIE die,
385371
llvm::SmallSet<lldb::user_id_t, 4> &seen,
386372
std::vector<CompilerContext> &context) {

lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ class DWARFDIE : public DWARFBaseDIE {
6969
DWARFDIE
7070
GetParentDeclContextDIE() const;
7171

72-
// DeclContext related functions
73-
std::vector<DWARFDIE> GetDeclContextDIEs() const;
74-
7572
/// Return this DIE's decl context as it is needed to look up types
7673
/// in Clang modules. This context will include any modules or functions that
7774
/// the type is declared in so an exact module match can be efficiently made.

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -3039,95 +3039,6 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
30393039
return type_sp;
30403040
}
30413041

3042-
// This function helps to ensure that the declaration contexts match for two
3043-
// different DIEs. Often times debug information will refer to a forward
3044-
// declaration of a type (the equivalent of "struct my_struct;". There will
3045-
// often be a declaration of that type elsewhere that has the full definition.
3046-
// When we go looking for the full type "my_struct", we will find one or more
3047-
// matches in the accelerator tables and we will then need to make sure the
3048-
// type was in the same declaration context as the original DIE. This function
3049-
// can efficiently compare two DIEs and will return true when the declaration
3050-
// context matches, and false when they don't.
3051-
bool SymbolFileDWARF::DIEDeclContextsMatch(const DWARFDIE &die1,
3052-
const DWARFDIE &die2) {
3053-
if (die1 == die2)
3054-
return true;
3055-
3056-
std::vector<DWARFDIE> decl_ctx_1;
3057-
std::vector<DWARFDIE> decl_ctx_2;
3058-
// The declaration DIE stack is a stack of the declaration context DIEs all
3059-
// the way back to the compile unit. If a type "T" is declared inside a class
3060-
// "B", and class "B" is declared inside a class "A" and class "A" is in a
3061-
// namespace "lldb", and the namespace is in a compile unit, there will be a
3062-
// stack of DIEs:
3063-
//
3064-
// [0] DW_TAG_class_type for "B"
3065-
// [1] DW_TAG_class_type for "A"
3066-
// [2] DW_TAG_namespace for "lldb"
3067-
// [3] DW_TAG_compile_unit or DW_TAG_partial_unit for the source file.
3068-
//
3069-
// We grab both contexts and make sure that everything matches all the way
3070-
// back to the compiler unit.
3071-
3072-
// First lets grab the decl contexts for both DIEs
3073-
decl_ctx_1 = die1.GetDeclContextDIEs();
3074-
decl_ctx_2 = die2.GetDeclContextDIEs();
3075-
// Make sure the context arrays have the same size, otherwise we are done
3076-
const size_t count1 = decl_ctx_1.size();
3077-
const size_t count2 = decl_ctx_2.size();
3078-
if (count1 != count2)
3079-
return false;
3080-
3081-
// Make sure the DW_TAG values match all the way back up the compile unit. If
3082-
// they don't, then we are done.
3083-
DWARFDIE decl_ctx_die1;
3084-
DWARFDIE decl_ctx_die2;
3085-
size_t i;
3086-
for (i = 0; i < count1; i++) {
3087-
decl_ctx_die1 = decl_ctx_1[i];
3088-
decl_ctx_die2 = decl_ctx_2[i];
3089-
if (decl_ctx_die1.Tag() != decl_ctx_die2.Tag())
3090-
return false;
3091-
}
3092-
#ifndef NDEBUG
3093-
3094-
// Make sure the top item in the decl context die array is always
3095-
// DW_TAG_compile_unit or DW_TAG_partial_unit. If it isn't then
3096-
// something went wrong in the DWARFDIE::GetDeclContextDIEs()
3097-
// function.
3098-
dw_tag_t cu_tag = decl_ctx_1[count1 - 1].Tag();
3099-
UNUSED_IF_ASSERT_DISABLED(cu_tag);
3100-
assert(cu_tag == DW_TAG_compile_unit || cu_tag == DW_TAG_partial_unit);
3101-
3102-
#endif
3103-
// Always skip the compile unit when comparing by only iterating up to "count
3104-
// - 1". Here we compare the names as we go.
3105-
for (i = 0; i < count1 - 1; i++) {
3106-
decl_ctx_die1 = decl_ctx_1[i];
3107-
decl_ctx_die2 = decl_ctx_2[i];
3108-
const char *name1 = decl_ctx_die1.GetName();
3109-
const char *name2 = decl_ctx_die2.GetName();
3110-
// If the string was from a DW_FORM_strp, then the pointer will often be
3111-
// the same!
3112-
if (name1 == name2)
3113-
continue;
3114-
3115-
// Name pointers are not equal, so only compare the strings if both are not
3116-
// NULL.
3117-
if (name1 && name2) {
3118-
// If the strings don't compare, we are done...
3119-
if (strcmp(name1, name2) != 0)
3120-
return false;
3121-
} else {
3122-
// One name was NULL while the other wasn't
3123-
return false;
3124-
}
3125-
}
3126-
// We made it through all of the checks and the declaration contexts are
3127-
// equal.
3128-
return true;
3129-
}
3130-
31313042
TypeSP
31323043
SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
31333044
TypeSP type_sp;

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
461461
FindBlockContainingSpecification(const DWARFDIE &die,
462462
dw_offset_t spec_block_die_offset);
463463

464-
bool DIEDeclContextsMatch(const DWARFDIE &die1, const DWARFDIE &die2);
465-
466464
bool ClassContainsSelector(const DWARFDIE &class_die, ConstString selector);
467465

468466
/// Parse call site entries (DW_TAG_call_site), including any nested call site

0 commit comments

Comments
 (0)