[lldb] Revert refactorization from: Move non-DWARF code: DWARFUnit -> SymbolFileDWARF

Reverting part of commit 789beeeca3.

Its DWARFDebugInfoEntry::GetDWARFDeclContext() refactorization for
return value is now adding it in opposite order.
This commit is contained in:
Jan Kratochvil 2020-01-31 16:04:40 +01:00
parent 6fb544d1d2
commit 6dd0163502
5 changed files with 30 additions and 23 deletions

View File

@ -726,7 +726,8 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
if (type_sp)
return type_sp;
DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
DWARFDeclContext die_decl_ctx;
SymbolFileDWARF::GetDWARFDeclContext(die, die_decl_ctx);
type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
@ -1514,7 +1515,8 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
if (type_sp)
return type_sp;
DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
DWARFDeclContext die_decl_ctx;
SymbolFileDWARF::GetDWARFDeclContext(die, die_decl_ctx);
// type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
// type_name_const_str);
@ -2323,9 +2325,10 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
unsigned type_quals = 0;
std::vector<CompilerType> param_types;
std::vector<clang::ParmVarDecl *> param_decls;
DWARFDeclContext decl_ctx;
StreamString sstr;
DWARFDeclContext decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
SymbolFileDWARF::GetDWARFDeclContext(die, decl_ctx);
sstr << decl_ctx.GetQualifiedName();
clang::DeclContext *containing_decl_ctx =

View File

@ -868,20 +868,19 @@ void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
}
}
DWARFDeclContext DWARFDebugInfoEntry::GetDWARFDeclContext(DWARFUnit *cu) const {
DWARFDeclContext dwarf_decl_ctx;
void DWARFDebugInfoEntry::GetDWARFDeclContext(
DWARFUnit *cu, DWARFDeclContext &dwarf_decl_ctx) const {
const dw_tag_t tag = Tag();
if (tag != DW_TAG_compile_unit && tag != DW_TAG_partial_unit) {
dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this) {
if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit &&
parent_decl_ctx_die.Tag() != DW_TAG_partial_unit)
dwarf_decl_ctx = parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
parent_decl_ctx_die.GetCU());
parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
}
dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
}
return dwarf_decl_ctx;
}
DWARFDIE

View File

@ -158,7 +158,8 @@ public:
return HasChildren() ? this + 1 : nullptr;
}
DWARFDeclContext GetDWARFDeclContext(DWARFUnit *cu) const;
void GetDWARFDeclContext(DWARFUnit *cu,
DWARFDeclContext &dwarf_decl_ctx) const;
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu) const;
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu,

View File

@ -2956,8 +2956,8 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
}
if (try_resolving_type) {
DWARFDeclContext type_dwarf_decl_ctx =
GetDWARFDeclContext(type_die);
DWARFDeclContext type_dwarf_decl_ctx;
GetDWARFDeclContext(type_die, type_dwarf_decl_ctx);
if (log) {
GetObjectFile()->GetModule()->LogMessage(
@ -3374,10 +3374,12 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
// declaration context.
if ((parent_tag == DW_TAG_compile_unit ||
parent_tag == DW_TAG_partial_unit) &&
Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU())))
mangled = GetDWARFDeclContext(die)
.GetQualifiedNameAsConstString()
.GetCString();
Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU()))) {
DWARFDeclContext decl_ctx;
GetDWARFDeclContext(die, decl_ctx);
mangled = decl_ctx.GetQualifiedNameAsConstString().GetCString();
}
}
if (tag == DW_TAG_formal_parameter)
@ -3979,13 +3981,14 @@ SymbolFileDWARF::GetContainingDeclContext(const DWARFDIE &die) {
return CompilerDeclContext();
}
DWARFDeclContext SymbolFileDWARF::GetDWARFDeclContext(const DWARFDIE &die) {
if (!die.IsValid())
return {};
DWARFDeclContext dwarf_decl_ctx =
die.GetDIE()->GetDWARFDeclContext(die.GetCU());
void SymbolFileDWARF::GetDWARFDeclContext(const DWARFDIE &die,
DWARFDeclContext &dwarf_decl_ctx) {
if (!die.IsValid()) {
dwarf_decl_ctx.Clear();
return;
}
dwarf_decl_ctx.SetLanguage(GetLanguage(*die.GetCU()));
return dwarf_decl_ctx;
die.GetDIE()->GetDWARFDeclContext(die.GetCU(), dwarf_decl_ctx);
}
LanguageType SymbolFileDWARF::LanguageTypeFromDWARF(uint64_t val) {

View File

@ -315,7 +315,8 @@ public:
static lldb_private::CompilerDeclContext
GetContainingDeclContext(const DWARFDIE &die);
static DWARFDeclContext GetDWARFDeclContext(const DWARFDIE &die);
static void GetDWARFDeclContext(const DWARFDIE &die,
DWARFDeclContext &dwarf_decl_ctx);
static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val);