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