diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 57bda49952f4..db49010a846f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -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 param_types; std::vector 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 = diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp index 4723fc8c35f2..885ca3d32d64 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -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 diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h index a61ed5bbfe67..2bb69e738a2f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h @@ -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, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index b1d82ddb4e3e..5ef2dd3f04b3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -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) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index e2163a7f4f0d..4510efcf25ff 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -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);