@@ -2488,6 +2488,7 @@ llvm::Error SymbolFileDWARF::FindAndResolveFunction(
2488
2488
lldb::eFunctionNameTypeMethod,
2489
2489
lldb::eLanguageTypeUnknown);
2490
2490
2491
+ llvm::DenseMap<uint8_t , DWARFDIE> variant_to_die;
2491
2492
m_index->GetFunctions (info, *this , {}, [&](DWARFDIE entry) {
2492
2493
if (entry.GetAttributeValueAsUnsigned (llvm::dwarf::DW_AT_declaration, 0 ))
2493
2494
return true ;
@@ -2516,14 +2517,30 @@ llvm::Error SymbolFileDWARF::FindAndResolveFunction(
2516
2517
if (D.partialDemangle (mangled))
2517
2518
return true ;
2518
2519
2519
- if (D.getCtorOrDtorVariant () != structor_variant)
2520
+ auto maybe_variant = D.getCtorOrDtorVariant ();
2521
+ if (!maybe_variant)
2520
2522
return true ;
2521
2523
2522
- die = entry ;
2524
+ assert (!variant_to_die. contains (*maybe_variant)) ;
2523
2525
2524
- return false ;
2526
+ variant_to_die[*maybe_variant] = entry;
2527
+
2528
+ return true ;
2525
2529
});
2526
2530
2531
+ if (structor_variant) {
2532
+ if (auto it = variant_to_die.find (*structor_variant);
2533
+ it != variant_to_die.end ()) {
2534
+ die = it->getSecond ();
2535
+ }
2536
+ // TODO: only do this for constructors.
2537
+ else if (structor_variant == 1 )
2538
+ // On Linux the C1 constructor variant is often an alias
2539
+ // to C2 (and C1 is never actually emitted into the object file).
2540
+ if (auto it = variant_to_die.find (2 ); it != variant_to_die.end ())
2541
+ die = it->getSecond ();
2542
+ }
2543
+
2527
2544
if (!die.IsValid ())
2528
2545
return llvm::createStringError (
2529
2546
llvm::formatv (" failed to find definition DIE for [lookup_name={0}] "
0 commit comments