forked from OSchip/llvm-project
[lldb] [NFC] Refactor GetDWARFDeclContext to return DWARFDeclContext
Suggested by Pavel Labath. Differential Revision: https://reviews.llvm.org/D73787
This commit is contained in:
parent
31cf581998
commit
1d11d5f624
|
@ -726,8 +726,7 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
|
||||||
if (type_sp)
|
if (type_sp)
|
||||||
return type_sp;
|
return type_sp;
|
||||||
|
|
||||||
DWARFDeclContext die_decl_ctx;
|
DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
|
||||||
SymbolFileDWARF::GetDWARFDeclContext(die, die_decl_ctx);
|
|
||||||
|
|
||||||
type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
|
type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
|
||||||
|
|
||||||
|
@ -1515,8 +1514,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
|
||||||
if (type_sp)
|
if (type_sp)
|
||||||
return type_sp;
|
return type_sp;
|
||||||
|
|
||||||
DWARFDeclContext die_decl_ctx;
|
DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
|
||||||
SymbolFileDWARF::GetDWARFDeclContext(die, die_decl_ctx);
|
|
||||||
|
|
||||||
// type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
|
// type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
|
||||||
// type_name_const_str);
|
// type_name_const_str);
|
||||||
|
@ -2323,10 +2321,9 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
|
||||||
unsigned type_quals = 0;
|
unsigned type_quals = 0;
|
||||||
std::vector<CompilerType> param_types;
|
std::vector<CompilerType> param_types;
|
||||||
std::vector<clang::ParmVarDecl *> param_decls;
|
std::vector<clang::ParmVarDecl *> param_decls;
|
||||||
DWARFDeclContext decl_ctx;
|
|
||||||
StreamString sstr;
|
StreamString sstr;
|
||||||
|
|
||||||
SymbolFileDWARF::GetDWARFDeclContext(die, decl_ctx);
|
DWARFDeclContext decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
|
||||||
sstr << decl_ctx.GetQualifiedName();
|
sstr << decl_ctx.GetQualifiedName();
|
||||||
|
|
||||||
clang::DeclContext *containing_decl_ctx =
|
clang::DeclContext *containing_decl_ctx =
|
||||||
|
|
|
@ -868,21 +868,30 @@ void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWARFDebugInfoEntry::GetDWARFDeclContext(
|
DWARFDeclContext
|
||||||
DWARFUnit *cu, DWARFDeclContext &dwarf_decl_ctx) const {
|
DWARFDebugInfoEntry::GetDWARFDeclContextStatic(const DWARFDebugInfoEntry *die,
|
||||||
const dw_tag_t tag = Tag();
|
DWARFUnit *cu) {
|
||||||
if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
|
DWARFDeclContext dwarf_decl_ctx;
|
||||||
return;
|
for (;;) {
|
||||||
dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
|
const dw_tag_t tag = die->Tag();
|
||||||
DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
|
if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
|
||||||
if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this) {
|
return dwarf_decl_ctx;
|
||||||
if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit &&
|
dwarf_decl_ctx.AppendDeclContext(tag, die->GetName(cu));
|
||||||
parent_decl_ctx_die.Tag() != DW_TAG_partial_unit)
|
DWARFDIE parent_decl_ctx_die = die->GetParentDeclContextDIE(cu);
|
||||||
parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
|
if (!parent_decl_ctx_die || parent_decl_ctx_die.GetDIE() == die)
|
||||||
parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
|
return dwarf_decl_ctx;
|
||||||
|
if (parent_decl_ctx_die.Tag() == DW_TAG_compile_unit ||
|
||||||
|
parent_decl_ctx_die.Tag() == DW_TAG_partial_unit)
|
||||||
|
return dwarf_decl_ctx;
|
||||||
|
die = parent_decl_ctx_die.GetDIE();
|
||||||
|
cu = parent_decl_ctx_die.GetCU();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DWARFDeclContext DWARFDebugInfoEntry::GetDWARFDeclContext(DWARFUnit *cu) const {
|
||||||
|
return GetDWARFDeclContextStatic(this, cu);
|
||||||
|
}
|
||||||
|
|
||||||
DWARFDIE
|
DWARFDIE
|
||||||
DWARFDebugInfoEntry::GetParentDeclContextDIE(DWARFUnit *cu) const {
|
DWARFDebugInfoEntry::GetParentDeclContextDIE(DWARFUnit *cu) const {
|
||||||
DWARFAttributes attributes;
|
DWARFAttributes attributes;
|
||||||
|
|
|
@ -158,8 +158,7 @@ public:
|
||||||
return HasChildren() ? this + 1 : nullptr;
|
return HasChildren() ? this + 1 : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetDWARFDeclContext(DWARFUnit *cu,
|
DWARFDeclContext GetDWARFDeclContext(DWARFUnit *cu) const;
|
||||||
DWARFDeclContext &dwarf_decl_ctx) const;
|
|
||||||
|
|
||||||
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu) const;
|
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu) const;
|
||||||
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu,
|
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu,
|
||||||
|
@ -169,6 +168,9 @@ public:
|
||||||
void SetParentIndex(uint32_t idx) { m_parent_idx = idx; }
|
void SetParentIndex(uint32_t idx) { m_parent_idx = idx; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
static DWARFDeclContext
|
||||||
|
GetDWARFDeclContextStatic(const DWARFDebugInfoEntry *die, DWARFUnit *cu);
|
||||||
|
|
||||||
dw_offset_t m_offset; // Offset within the .debug_info/.debug_types
|
dw_offset_t m_offset; // Offset within the .debug_info/.debug_types
|
||||||
uint32_t m_parent_idx; // How many to subtract from "this" to get the parent.
|
uint32_t m_parent_idx; // How many to subtract from "this" to get the parent.
|
||||||
// If zero this die has no parent
|
// If zero this die has no parent
|
||||||
|
|
|
@ -2959,8 +2959,8 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (try_resolving_type) {
|
if (try_resolving_type) {
|
||||||
DWARFDeclContext type_dwarf_decl_ctx;
|
DWARFDeclContext type_dwarf_decl_ctx =
|
||||||
GetDWARFDeclContext(type_die, type_dwarf_decl_ctx);
|
GetDWARFDeclContext(type_die);
|
||||||
|
|
||||||
if (log) {
|
if (log) {
|
||||||
GetObjectFile()->GetModule()->LogMessage(
|
GetObjectFile()->GetModule()->LogMessage(
|
||||||
|
@ -3377,12 +3377,10 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
|
||||||
// declaration context.
|
// declaration context.
|
||||||
if ((parent_tag == DW_TAG_compile_unit ||
|
if ((parent_tag == DW_TAG_compile_unit ||
|
||||||
parent_tag == DW_TAG_partial_unit) &&
|
parent_tag == DW_TAG_partial_unit) &&
|
||||||
Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU()))) {
|
Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU())))
|
||||||
DWARFDeclContext decl_ctx;
|
mangled = GetDWARFDeclContext(die)
|
||||||
|
.GetQualifiedNameAsConstString()
|
||||||
GetDWARFDeclContext(die, decl_ctx);
|
.GetCString();
|
||||||
mangled = decl_ctx.GetQualifiedNameAsConstString().GetCString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == DW_TAG_formal_parameter)
|
if (tag == DW_TAG_formal_parameter)
|
||||||
|
@ -3984,14 +3982,13 @@ SymbolFileDWARF::GetContainingDeclContext(const DWARFDIE &die) {
|
||||||
return CompilerDeclContext();
|
return CompilerDeclContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolFileDWARF::GetDWARFDeclContext(const DWARFDIE &die,
|
DWARFDeclContext SymbolFileDWARF::GetDWARFDeclContext(const DWARFDIE &die) {
|
||||||
DWARFDeclContext &dwarf_decl_ctx) {
|
if (!die.IsValid())
|
||||||
if (!die.IsValid()) {
|
return {};
|
||||||
dwarf_decl_ctx.Clear();
|
DWARFDeclContext dwarf_decl_ctx =
|
||||||
return;
|
die.GetDIE()->GetDWARFDeclContext(die.GetCU());
|
||||||
}
|
|
||||||
dwarf_decl_ctx.SetLanguage(GetLanguage(*die.GetCU()));
|
dwarf_decl_ctx.SetLanguage(GetLanguage(*die.GetCU()));
|
||||||
die.GetDIE()->GetDWARFDeclContext(die.GetCU(), dwarf_decl_ctx);
|
return dwarf_decl_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
LanguageType SymbolFileDWARF::LanguageTypeFromDWARF(uint64_t val) {
|
LanguageType SymbolFileDWARF::LanguageTypeFromDWARF(uint64_t val) {
|
||||||
|
|
|
@ -308,8 +308,7 @@ public:
|
||||||
static lldb_private::CompilerDeclContext
|
static lldb_private::CompilerDeclContext
|
||||||
GetContainingDeclContext(const DWARFDIE &die);
|
GetContainingDeclContext(const DWARFDIE &die);
|
||||||
|
|
||||||
static void GetDWARFDeclContext(const DWARFDIE &die,
|
static DWARFDeclContext GetDWARFDeclContext(const DWARFDIE &die);
|
||||||
DWARFDeclContext &dwarf_decl_ctx);
|
|
||||||
|
|
||||||
static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val);
|
static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue