@@ -376,6 +376,36 @@ lldb_private::Type *DWARFDIE::ResolveTypeUID(const DWARFDIE &die) const {
376
376
return nullptr ;
377
377
}
378
378
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
+
379
409
static void GetDeclContextImpl (DWARFDIE die,
380
410
llvm::SmallSet<lldb::user_id_t , 4 > &seen,
381
411
std::vector<CompilerContext> &context) {
@@ -388,34 +418,17 @@ static void GetDeclContextImpl(DWARFDIE die,
388
418
}
389
419
390
420
// 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
- };
394
421
switch (die.Tag ()) {
395
422
case DW_TAG_module:
396
- push_ctx (CompilerContextKind::Module, die.GetName ());
397
- break ;
398
423
case DW_TAG_namespace:
399
- push_ctx (CompilerContextKind::Namespace, die.GetName ());
400
- break ;
401
424
case DW_TAG_class_type:
402
425
case DW_TAG_structure_type:
403
- push_ctx (CompilerContextKind::ClassOrStruct, die.GetName ());
404
- break ;
405
426
case DW_TAG_union_type:
406
- push_ctx (CompilerContextKind::Union, die.GetName ());
407
- break ;
408
427
case DW_TAG_enumeration_type:
409
- push_ctx (CompilerContextKind::Enum, die.GetName ());
410
- break ;
411
428
case DW_TAG_subprogram:
412
- push_ctx (CompilerContextKind::Function, die.GetName ());
413
- break ;
414
429
case DW_TAG_variable:
415
- push_ctx (CompilerContextKind::Variable, die.GetName ());
416
- break ;
417
430
case DW_TAG_typedef:
418
- push_ctx (CompilerContextKind::Typedef, die. GetName ( ));
431
+ context. push_back ( GetContextEntry (die ));
419
432
break ;
420
433
default :
421
434
break ;
@@ -439,32 +452,18 @@ static void GetTypeLookupContextImpl(DWARFDIE die,
439
452
// Stop if we hit a cycle.
440
453
while (die && seen.insert (die.GetID ()).second ) {
441
454
// 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
- };
445
455
switch (die.Tag ()) {
446
456
case DW_TAG_namespace:
447
- push_ctx (CompilerContextKind::Namespace, die.GetName ());
448
- break ;
449
457
case DW_TAG_class_type:
450
458
case DW_TAG_structure_type:
451
- push_ctx (CompilerContextKind::ClassOrStruct, die.GetName ());
452
- break ;
453
459
case DW_TAG_union_type:
454
- push_ctx (CompilerContextKind::Union, die.GetName ());
455
- break ;
456
460
case DW_TAG_enumeration_type:
457
- push_ctx (CompilerContextKind::Enum, die.GetName ());
458
- break ;
459
461
case DW_TAG_variable:
460
- push_ctx (CompilerContextKind::Variable, die.GetName ());
461
- break ;
462
462
case DW_TAG_typedef:
463
- push_ctx (CompilerContextKind::Typedef, die.GetName ());
464
- break ;
465
463
case DW_TAG_base_type:
466
- push_ctx (CompilerContextKind::Builtin, die. GetName ( ));
464
+ context. push_back ( GetContextEntry (die ));
467
465
break ;
466
+
468
467
// If any of the tags below appear in the parent chain, stop the decl
469
468
// context and return. Prior to these being in here, if a type existed in a
470
469
// namespace "a" like "a::my_struct", but we also have a function in that
0 commit comments