@@ -376,6 +376,36 @@ lldb_private::Type *DWARFDIE::ResolveTypeUID(const DWARFDIE &die) const {
376376 return nullptr ;
377377}
378378
379+ static CompilerContext GetContextEntry (DWARFDIE die) {
380+ auto ctx = [die](CompilerContextKind kind) {
381+ return CompilerContext (kind, ConstString (die.GetName ()));
382+ };
383+
384+ switch (die.Tag ()) {
385+ case DW_TAG_module:
386+ return ctx (CompilerContextKind::Module);
387+ case DW_TAG_namespace:
388+ return ctx (CompilerContextKind::Namespace);
389+ case DW_TAG_class_type:
390+ case DW_TAG_structure_type:
391+ return ctx (CompilerContextKind::ClassOrStruct);
392+ case DW_TAG_union_type:
393+ return ctx (CompilerContextKind::Union);
394+ case DW_TAG_enumeration_type:
395+ return ctx (CompilerContextKind::Enum);
396+ case DW_TAG_subprogram:
397+ return ctx (CompilerContextKind::Function);
398+ case DW_TAG_variable:
399+ return ctx (CompilerContextKind::Variable);
400+ case DW_TAG_typedef:
401+ return ctx (CompilerContextKind::Typedef);
402+ case DW_TAG_base_type:
403+ return ctx (CompilerContextKind::Builtin);
404+ default :
405+ llvm_unreachable (" Check tag type in the caller!" );
406+ }
407+ }
408+
379409static void GetDeclContextImpl (DWARFDIE die,
380410 llvm::SmallSet<lldb::user_id_t , 4 > &seen,
381411 std::vector<CompilerContext> &context) {
@@ -388,34 +418,17 @@ static void GetDeclContextImpl(DWARFDIE die,
388418 }
389419
390420 // Add this DIE's contribution at the end of the chain.
391- auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
392- context.push_back ({kind, ConstString (name)});
393- };
394421 switch (die.Tag ()) {
395422 case DW_TAG_module:
396- push_ctx (CompilerContextKind::Module, die.GetName ());
397- break ;
398423 case DW_TAG_namespace:
399- push_ctx (CompilerContextKind::Namespace, die.GetName ());
400- break ;
401424 case DW_TAG_class_type:
402425 case DW_TAG_structure_type:
403- push_ctx (CompilerContextKind::ClassOrStruct, die.GetName ());
404- break ;
405426 case DW_TAG_union_type:
406- push_ctx (CompilerContextKind::Union, die.GetName ());
407- break ;
408427 case DW_TAG_enumeration_type:
409- push_ctx (CompilerContextKind::Enum, die.GetName ());
410- break ;
411428 case DW_TAG_subprogram:
412- push_ctx (CompilerContextKind::Function, die.GetName ());
413- break ;
414429 case DW_TAG_variable:
415- push_ctx (CompilerContextKind::Variable, die.GetName ());
416- break ;
417430 case DW_TAG_typedef:
418- push_ctx (CompilerContextKind::Typedef, die. GetName ( ));
431+ context. push_back ( GetContextEntry (die ));
419432 break ;
420433 default :
421434 break ;
@@ -439,32 +452,18 @@ static void GetTypeLookupContextImpl(DWARFDIE die,
439452 // Stop if we hit a cycle.
440453 while (die && seen.insert (die.GetID ()).second ) {
441454 // Add this DIE's contribution at the end of the chain.
442- auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
443- context.push_back ({kind, ConstString (name)});
444- };
445455 switch (die.Tag ()) {
446456 case DW_TAG_namespace:
447- push_ctx (CompilerContextKind::Namespace, die.GetName ());
448- break ;
449457 case DW_TAG_class_type:
450458 case DW_TAG_structure_type:
451- push_ctx (CompilerContextKind::ClassOrStruct, die.GetName ());
452- break ;
453459 case DW_TAG_union_type:
454- push_ctx (CompilerContextKind::Union, die.GetName ());
455- break ;
456460 case DW_TAG_enumeration_type:
457- push_ctx (CompilerContextKind::Enum, die.GetName ());
458- break ;
459461 case DW_TAG_variable:
460- push_ctx (CompilerContextKind::Variable, die.GetName ());
461- break ;
462462 case DW_TAG_typedef:
463- push_ctx (CompilerContextKind::Typedef, die.GetName ());
464- break ;
465463 case DW_TAG_base_type:
466- push_ctx (CompilerContextKind::Builtin, die. GetName ( ));
464+ context. push_back ( GetContextEntry (die ));
467465 break ;
466+
468467 // If any of the tags below appear in the parent chain, stop the decl
469468 // context and return. Prior to these being in here, if a type existed in a
470469 // namespace "a" like "a::my_struct", but we also have a function in that
0 commit comments