[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Mon Oct 23 17:38:25 PDT 2023
================
@@ -373,47 +373,49 @@ std::vector<DWARFDIE> DWARFDIE::GetDeclContextDIEs() const {
return result;
}
-void DWARFDIE::GetDeclContext(
- llvm::SmallVectorImpl<lldb_private::CompilerContext> &context) const {
+std::vector<lldb_private::CompilerContext> DWARFDIE::GetDeclContext() const {
+ std::vector<lldb_private::CompilerContext> context;
const dw_tag_t tag = Tag();
if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
- return;
+ return context;
DWARFDIE parent = GetParent();
if (parent)
- parent.GetDeclContext(context);
+ context = parent.GetDeclContext();
+ auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
+ context.push_back({kind, ConstString(name)});
+ };
switch (tag) {
case DW_TAG_module:
- context.push_back({CompilerContextKind::Module, ConstString(GetName())});
+ push_ctx(CompilerContextKind::Module, GetName());
break;
case DW_TAG_namespace:
- context.push_back({CompilerContextKind::Namespace, ConstString(GetName())});
+ push_ctx(CompilerContextKind::Namespace, GetName());
break;
case DW_TAG_structure_type:
- context.push_back({CompilerContextKind::Struct, ConstString(GetName())});
+ push_ctx(CompilerContextKind::Struct, GetName());
break;
case DW_TAG_union_type:
- context.push_back({CompilerContextKind::Union, ConstString(GetName())});
+ push_ctx(CompilerContextKind::Union, GetName());
break;
case DW_TAG_class_type:
- context.push_back({CompilerContextKind::Class, ConstString(GetName())});
+ push_ctx(CompilerContextKind::Class, GetName());
break;
case DW_TAG_enumeration_type:
- context.push_back({CompilerContextKind::Enum, ConstString(GetName())});
+ push_ctx(CompilerContextKind::Enum, GetName());
break;
case DW_TAG_subprogram:
- context.push_back(
- {CompilerContextKind::Function, ConstString(GetPubname())});
+ push_ctx(CompilerContextKind::Function, GetPubname());
break;
case DW_TAG_variable:
- context.push_back(
- {CompilerContextKind::Variable, ConstString(GetPubname())});
+push_ctx(CompilerContextKind::Variable, GetPubname());
----------------
clayborg wrote:
indent
https://github.com/llvm/llvm-project/pull/69981
More information about the lldb-commits
mailing list