Skip to content

Commit

Permalink
Remove DWARFDIECollection.
Browse files Browse the repository at this point in the history
This is a very thin wrapper over a std::vector<DWARFDIE> and does
not seem to provide any real value over just using a container
directly.

Differential Revision: https://reviews.llvm.org/D59165

llvm-svn: 355974
  • Loading branch information
Zachary Turner committed Mar 12, 2019
1 parent d5364df commit 0eaa6d5
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 143 deletions.
1 change: 0 additions & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
Expand Up @@ -21,7 +21,6 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
DWARFDeclContext.cpp
DWARFDefines.cpp
DWARFDIE.cpp
DWARFDIECollection.cpp
DWARFFormValue.cpp
DWARFIndex.cpp
DWARFUnit.cpp
Expand Down
25 changes: 10 additions & 15 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Expand Up @@ -10,7 +10,6 @@

#include "DWARFASTParserClang.h"
#include "DWARFDIE.h"
#include "DWARFDIECollection.h"
#include "DWARFDebugInfo.h"
#include "DWARFDeclContext.h"
#include "DWARFDefines.h"
Expand Down Expand Up @@ -1393,7 +1392,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc,
DIERef(class_type->GetID(), dwarf));
}
if (class_type_die) {
DWARFDIECollection failures;
std::vector<DWARFDIE> failures;

CopyUniqueClassMethodTypes(decl_ctx_die, class_type_die,
class_type, failures);
Expand Down Expand Up @@ -2194,7 +2193,7 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
std::vector<int> member_accessibilities;
bool is_a_class = false;
// Parse members and base classes first
DWARFDIECollection member_function_dies;
std::vector<DWARFDIE> member_function_dies;

DelayedPropertyList delayed_properties;
ParseChildMembers(sc, die, clang_type, class_language, bases,
Expand All @@ -2203,12 +2202,8 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
layout_info);

// Now parse any methods if there were any...
size_t num_functions = member_function_dies.Size();
if (num_functions > 0) {
for (size_t i = 0; i < num_functions; ++i) {
dwarf->ResolveType(member_function_dies.GetDIEAtIndex(i));
}
}
for (const DWARFDIE &die : member_function_dies)
dwarf->ResolveType(die);

if (class_language == eLanguageTypeObjC) {
ConstString class_name(clang_type.GetTypeName());
Expand Down Expand Up @@ -2677,7 +2672,7 @@ bool DWARFASTParserClang::ParseChildMembers(
CompilerType &class_clang_type, const LanguageType class_language,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
std::vector<int> &member_accessibilities,
DWARFDIECollection &member_function_dies,
std::vector<DWARFDIE> &member_function_dies,
DelayedPropertyList &delayed_properties, AccessType &default_accessibility,
bool &is_a_class, ClangASTImporter::LayoutInfo &layout_info) {
if (!parent_die)
Expand Down Expand Up @@ -3176,7 +3171,7 @@ bool DWARFASTParserClang::ParseChildMembers(

case DW_TAG_subprogram:
// Let the type parsing code handle this one for us.
member_function_dies.Append(die);
member_function_dies.push_back(die);
break;

case DW_TAG_inheritance: {
Expand Down Expand Up @@ -3872,7 +3867,7 @@ void DWARFASTParserClang::LinkDeclContextToDIE(clang::DeclContext *decl_ctx,

bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
const DWARFDIE &src_class_die, const DWARFDIE &dst_class_die,
lldb_private::Type *class_type, DWARFDIECollection &failures) {
lldb_private::Type *class_type, std::vector<DWARFDIE> &failures) {
if (!class_type || !src_class_die || !dst_class_die)
return false;
if (src_class_die.Tag() != dst_class_die.Tag())
Expand Down Expand Up @@ -4077,7 +4072,7 @@ bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
log->Printf("warning: couldn't find a match for 0x%8.8x",
dst_die.GetOffset());

failures.Append(dst_die);
failures.push_back(dst_die);
}
}
}
Expand Down Expand Up @@ -4142,9 +4137,9 @@ bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
"method '%s'",
dst_die.GetOffset(), dst_name_artificial.GetCString());

failures.Append(dst_die);
failures.push_back(dst_die);
}
}

return (failures.Size() != 0);
return !failures.empty();
}
7 changes: 4 additions & 3 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
Expand Up @@ -21,11 +21,12 @@
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangASTImporter.h"

#include <vector>

namespace lldb_private {
class CompileUnit;
}
class DWARFDebugInfoEntry;
class DWARFDIECollection;
class SymbolFileDWARF;

class DWARFASTParserClang : public DWARFASTParser {
Expand Down Expand Up @@ -85,7 +86,7 @@ class DWARFASTParserClang : public DWARFASTParser {
const lldb::LanguageType class_language,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
std::vector<int> &member_accessibilities,
DWARFDIECollection &member_function_dies,
std::vector<DWARFDIE> &member_function_dies,
DelayedPropertyList &delayed_properties,
lldb::AccessType &default_accessibility, bool &is_a_class,
lldb_private::ClangASTImporter::LayoutInfo &layout_info);
Expand Down Expand Up @@ -117,7 +118,7 @@ class DWARFASTParserClang : public DWARFASTParser {
bool CopyUniqueClassMethodTypes(const DWARFDIE &src_class_die,
const DWARFDIE &dst_class_die,
lldb_private::Type *class_type,
DWARFDIECollection &failures);
std::vector<DWARFDIE> &failures);

clang::DeclContext *GetCachedClangDeclContextForDIE(const DWARFDIE &die);

Expand Down
1 change: 0 additions & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
Expand Up @@ -18,7 +18,6 @@ class DWARFAttributes;
class DWARFUnit;
class DWARFDebugInfoEntry;
class DWARFDeclContext;
class DWARFDIECollection;
class SymbolFileDWARF;

class DWARFBaseDIE {
Expand Down
20 changes: 11 additions & 9 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
Expand Up @@ -9,7 +9,6 @@
#include "DWARFDIE.h"

#include "DWARFASTParser.h"
#include "DWARFDIECollection.h"
#include "DWARFDebugInfo.h"
#include "DWARFDebugInfoEntry.h"
#include "DWARFDeclContext.h"
Expand Down Expand Up @@ -200,15 +199,18 @@ lldb_private::Type *DWARFDIE::ResolveTypeUID(const DIERef &die_ref) const {
return nullptr;
}

void DWARFDIE::GetDeclContextDIEs(DWARFDIECollection &decl_context_dies) const {
if (IsValid()) {
DWARFDIE parent_decl_ctx_die =
m_die->GetParentDeclContextDIE(GetDWARF(), GetCU());
if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != GetDIE()) {
decl_context_dies.Append(parent_decl_ctx_die);
parent_decl_ctx_die.GetDeclContextDIEs(decl_context_dies);
}
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;
}

void DWARFDIE::GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const {
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
Expand Up @@ -81,7 +81,7 @@ class DWARFDIE : public DWARFBaseDIE {
//----------------------------------------------------------------------
// DeclContext related functions
//----------------------------------------------------------------------
void GetDeclContextDIEs(DWARFDIECollection &decl_context_dies) const;
std::vector<DWARFDIE> GetDeclContextDIEs() const;

void GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const;

Expand Down
34 changes: 0 additions & 34 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp

This file was deleted.

37 changes: 0 additions & 37 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h

This file was deleted.

7 changes: 3 additions & 4 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
Expand Up @@ -18,7 +18,6 @@
#include "lldb/Utility/Stream.h"

#include "DWARFUnit.h"
#include "DWARFDIECollection.h"
#include "DWARFDebugAbbrev.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
Expand Down Expand Up @@ -1381,11 +1380,11 @@ void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
}
}

void DWARFDebugInfoEntry::GetDeclContextDIEs(
DWARFUnit *cu, DWARFDIECollection &decl_context_dies) const {
std::vector<DWARFDIE>
DWARFDebugInfoEntry::GetDeclContextDIEs(DWARFUnit *cu) const {

DWARFDIE die(cu, const_cast<DWARFDebugInfoEntry *>(this));
die.GetDeclContextDIEs(decl_context_dies);
return die.GetDeclContextDIEs();
}

void DWARFDebugInfoEntry::GetDWARFDeclContext(
Expand Down
3 changes: 1 addition & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
Expand Up @@ -230,8 +230,7 @@ class DWARFDebugInfoEntry {
return HasChildren() ? this + 1 : NULL;
}

void GetDeclContextDIEs(DWARFUnit *cu,
DWARFDIECollection &decl_context_dies) const;
std::vector<DWARFDIE> GetDeclContextDIEs(DWARFUnit *cu) const;

void GetDWARFDeclContext(SymbolFileDWARF *dwarf2Data, DWARFUnit *cu,
DWARFDeclContext &dwarf_decl_ctx) const;
Expand Down
12 changes: 5 additions & 7 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
Expand Up @@ -17,7 +17,6 @@
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"

#include "DWARFDIECollection.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
#include "LogChannelDWARF.h"
Expand Down Expand Up @@ -400,24 +399,23 @@ DWARFDIE DWARFUnit::LookupAddress(const dw_addr_t address) {
}

size_t DWARFUnit::AppendDIEsWithTag(const dw_tag_t tag,
DWARFDIECollection &dies,
uint32_t depth) const {
size_t old_size = dies.Size();
std::vector<DWARFDIE> &dies,
uint32_t depth) const {
size_t old_size = dies.size();
{
llvm::sys::ScopedReader lock(m_die_array_mutex);
DWARFDebugInfoEntry::const_iterator pos;
DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
for (pos = m_die_array.begin(); pos != end; ++pos) {
if (pos->Tag() == tag)
dies.Append(DWARFDIE(this, &(*pos)));
dies.emplace_back(this, &(*pos));
}
}

// Return the number of DIEs added to the collection
return dies.Size() - old_size;
return dies.size() - old_size;
}


lldb::user_id_t DWARFUnit::GetID() const {
dw_offset_t local_id =
m_base_obj_offset != DW_INVALID_OFFSET ? m_base_obj_offset : m_offset;
Expand Down
3 changes: 1 addition & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
Expand Up @@ -54,8 +54,7 @@ class DWARFUnit {
ScopedExtractDIEs ExtractDIEsScoped();

DWARFDIE LookupAddress(const dw_addr_t address);
size_t AppendDIEsWithTag(const dw_tag_t tag,
DWARFDIECollection &matching_dies,
size_t AppendDIEsWithTag(const dw_tag_t tag, std::vector<DWARFDIE> &dies,
uint32_t depth = UINT32_MAX) const;
bool Verify(lldb_private::Stream *s) const;
virtual void Dump(lldb_private::Stream *s) const = 0;
Expand Down

0 comments on commit 0eaa6d5

Please sign in to comment.