Skip to content

Commit ce75a0a

Browse files
committed
fixup! clean up error handling
1 parent 6507359 commit ce75a0a

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,8 +2535,9 @@ GetItaniumCtorDtorVariant(llvm::StringRef discriminator) {
25352535
return ClangToItaniumDtorKind(static_cast<clang::CXXDtorType>(structor_kind));
25362536
}
25372537

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) {
25402541
DWARFDIE definition;
25412542
llvm::DenseMap<int, DWARFDIE> structor_variant_to_die;
25422543

@@ -2570,6 +2571,8 @@ DWARFDIE SymbolFileDWARF::FindFunctionDefinition(const FunctionCallLabel &label,
25702571
if (!mangled)
25712572
return IterationAction::Continue;
25722573

2574+
// FIXME: we should make DWARF encode the structor variant instead of
2575+
// needing to re-demangle.
25732576
llvm::ItaniumPartialDemangler D;
25742577
if (D.partialDemangle(mangled))
25752578
return IterationAction::Continue;
@@ -2594,7 +2597,9 @@ DWARFDIE SymbolFileDWARF::FindFunctionDefinition(const FunctionCallLabel &label,
25942597

25952598
auto label_variant = GetItaniumCtorDtorVariant(label.discriminator);
25962599
if (!label_variant)
2597-
return {};
2600+
return llvm::createStringError(
2601+
llvm::formatv("failed to retrieve structor variant from label: {0}",
2602+
label.discriminator));
25982603

25992604
auto it = structor_variant_to_die.find(*label_variant);
26002605

@@ -2604,13 +2609,16 @@ DWARFDIE SymbolFileDWARF::FindFunctionDefinition(const FunctionCallLabel &label,
26042609

26052610
// We need a C1 constructor. If debug-info only contains a DIE for C2,
26062611
// assume C1 was aliased to C2.
2612+
//
2613+
// FIXME: can DWARF encode this information for us?
26072614
if (!label.lookup_name.starts_with("~") && label_variant == 1) {
26082615
if (auto it = structor_variant_to_die.find(2);
26092616
it != structor_variant_to_die.end())
26102617
return it->getSecond();
26112618
}
26122619

2613-
return {};
2620+
return llvm::createStringError(llvm::formatv(
2621+
"failed to find structor variant DIE for label: {0}", label));
26142622
}
26152623

26162624
llvm::Expected<SymbolContext>
@@ -2625,20 +2633,21 @@ SymbolFileDWARF::ResolveFunctionCallLabel(const FunctionCallLabel &label) {
26252633
// Label was created using a declaration DIE. Need to fetch the definition
26262634
// to resolve the function call.
26272635
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;
26322643
}
26332644

26342645
SymbolContextList sc_list;
26352646
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");
26382648

26392649
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");
26422651

26432652
assert(sc_list.GetSize() == 1);
26442653

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,9 @@ class SymbolFileDWARF : public SymbolFileCommon {
373373
DWARFIndex *getIndex() { return m_index.get(); }
374374

375375
private:
376-
DWARFDIE FindFunctionDefinition(const FunctionCallLabel &label,
377-
const DWARFDIE &declaration);
376+
llvm::Expected<DWARFDIE>
377+
FindFunctionDefinition(const FunctionCallLabel &label,
378+
const DWARFDIE &declaration);
378379

379380
protected:
380381
SymbolFileDWARF(const SymbolFileDWARF &) = delete;

0 commit comments

Comments
 (0)