Skip to content

[lldb/DWARF] Remove some dead code #95127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
89 changes: 0 additions & 89 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading