@@ -373,47 +373,49 @@ std::vector<DWARFDIE> DWARFDIE::GetDeclContextDIEs() const {
373373 return result;
374374}
375375
376- void DWARFDIE::GetDeclContext (
377- llvm::SmallVectorImpl <lldb_private::CompilerContext> & context) const {
376+ std::vector<lldb_private::CompilerContext> DWARFDIE::GetDeclContext () const {
377+ std::vector <lldb_private::CompilerContext> context;
378378 const dw_tag_t tag = Tag ();
379379 if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
380- return ;
380+ return context ;
381381 DWARFDIE parent = GetParent ();
382382 if (parent)
383- parent.GetDeclContext (context);
383+ context = parent.GetDeclContext ();
384+ auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
385+ context.push_back ({kind, ConstString (name)});
386+ };
384387 switch (tag) {
385388 case DW_TAG_module:
386- context. push_back ({ CompilerContextKind::Module, ConstString ( GetName ())} );
389+ push_ctx ( CompilerContextKind::Module, GetName ());
387390 break ;
388391 case DW_TAG_namespace:
389- context. push_back ({ CompilerContextKind::Namespace, ConstString ( GetName ())} );
392+ push_ctx ( CompilerContextKind::Namespace, GetName ());
390393 break ;
391394 case DW_TAG_structure_type:
392- context. push_back ({ CompilerContextKind::Struct, ConstString ( GetName ())} );
395+ push_ctx ( CompilerContextKind::Struct, GetName ());
393396 break ;
394397 case DW_TAG_union_type:
395- context. push_back ({ CompilerContextKind::Union, ConstString ( GetName ())} );
398+ push_ctx ( CompilerContextKind::Union, GetName ());
396399 break ;
397400 case DW_TAG_class_type:
398- context. push_back ({ CompilerContextKind::Class, ConstString ( GetName ())} );
401+ push_ctx ( CompilerContextKind::Class, GetName ());
399402 break ;
400403 case DW_TAG_enumeration_type:
401- context. push_back ({ CompilerContextKind::Enum, ConstString ( GetName ())} );
404+ push_ctx ( CompilerContextKind::Enum, GetName ());
402405 break ;
403406 case DW_TAG_subprogram:
404- context.push_back (
405- {CompilerContextKind::Function, ConstString (GetPubname ())});
407+ push_ctx (CompilerContextKind::Function, GetPubname ());
406408 break ;
407409 case DW_TAG_variable:
408- context.push_back (
409- {CompilerContextKind::Variable, ConstString (GetPubname ())});
410+ push_ctx (CompilerContextKind::Variable, GetPubname ());
410411 break ;
411412 case DW_TAG_typedef:
412- context. push_back ({ CompilerContextKind::Typedef, ConstString ( GetName ())} );
413+ push_ctx ( CompilerContextKind::Typedef, GetName ());
413414 break ;
414415 default :
415416 break ;
416417 }
418+ return context;
417419}
418420
419421DWARFDIE
0 commit comments