@@ -2536,8 +2536,9 @@ GetItaniumCtorDtorVariant(llvm::StringRef discriminator) {
2536
2536
return ClangToItaniumDtorKind (static_cast <clang::CXXDtorType>(structor_kind));
2537
2537
}
2538
2538
2539
- DWARFDIE SymbolFileDWARF::FindFunctionDefinition (const FunctionCallLabel &label,
2540
- const DWARFDIE &declaration) {
2539
+ llvm::Expected<DWARFDIE>
2540
+ SymbolFileDWARF::FindFunctionDefinition (const FunctionCallLabel &label,
2541
+ const DWARFDIE &declaration) {
2541
2542
DWARFDIE definition;
2542
2543
llvm::DenseMap<int , DWARFDIE> structor_variant_to_die;
2543
2544
@@ -2571,6 +2572,8 @@ DWARFDIE SymbolFileDWARF::FindFunctionDefinition(const FunctionCallLabel &label,
2571
2572
if (!mangled)
2572
2573
return IterationAction::Continue;
2573
2574
2575
+ // FIXME: we should make DWARF encode the structor variant instead of
2576
+ // needing to re-demangle.
2574
2577
llvm::ItaniumPartialDemangler D;
2575
2578
if (D.partialDemangle (mangled))
2576
2579
return IterationAction::Continue;
@@ -2595,7 +2598,9 @@ DWARFDIE SymbolFileDWARF::FindFunctionDefinition(const FunctionCallLabel &label,
2595
2598
2596
2599
auto label_variant = GetItaniumCtorDtorVariant (label.discriminator );
2597
2600
if (!label_variant)
2598
- return {};
2601
+ return llvm::createStringError (
2602
+ llvm::formatv (" failed to retrieve structor variant from label: {0}" ,
2603
+ label.discriminator ));
2599
2604
2600
2605
auto it = structor_variant_to_die.find (*label_variant);
2601
2606
@@ -2605,13 +2610,16 @@ DWARFDIE SymbolFileDWARF::FindFunctionDefinition(const FunctionCallLabel &label,
2605
2610
2606
2611
// We need a C1 constructor. If debug-info only contains a DIE for C2,
2607
2612
// assume C1 was aliased to C2.
2613
+ //
2614
+ // FIXME: can DWARF encode this information for us?
2608
2615
if (!label.lookup_name .starts_with (" ~" ) && label_variant == 1 ) {
2609
2616
if (auto it = structor_variant_to_die.find (2 );
2610
2617
it != structor_variant_to_die.end ())
2611
2618
return it->getSecond ();
2612
2619
}
2613
2620
2614
- return {};
2621
+ return llvm::createStringError (llvm::formatv (
2622
+ " failed to find structor variant DIE for label: {0}" , label));
2615
2623
}
2616
2624
2617
2625
llvm::Expected<SymbolContext>
@@ -2626,9 +2634,13 @@ SymbolFileDWARF::ResolveFunctionCallLabel(const FunctionCallLabel &label) {
2626
2634
// Label was created using a declaration DIE. Need to fetch the definition
2627
2635
// to resolve the function call.
2628
2636
if (die.GetAttributeValueAsUnsigned (llvm::dwarf::DW_AT_declaration, 0 )) {
2629
- die = FindFunctionDefinition (label, die);
2630
- if (!die.IsValid ())
2631
- return llvm::createStringError (" failed to find definition DIE" );
2637
+ auto die_or_err = FindFunctionDefinition (label, die);
2638
+ if (!die_or_err)
2639
+ return llvm::joinErrors (
2640
+ llvm::createStringError (" failed to find definition DIE" ),
2641
+ die_or_err.takeError ());
2642
+
2643
+ die = std::move (*die_or_err);
2632
2644
}
2633
2645
2634
2646
SymbolContextList sc_list;
0 commit comments