Skip to content

Commit afe5c2a

Browse files
committed
fixup! clean up error handling
1 parent 5fa2d53 commit afe5c2a

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

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

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

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

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

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

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

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

@@ -2605,13 +2610,16 @@ DWARFDIE SymbolFileDWARF::FindFunctionDefinition(const FunctionCallLabel &label,
26052610

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

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

26172625
llvm::Expected<SymbolContext>
@@ -2626,9 +2634,13 @@ SymbolFileDWARF::ResolveFunctionCallLabel(const FunctionCallLabel &label) {
26262634
// Label was created using a declaration DIE. Need to fetch the definition
26272635
// to resolve the function call.
26282636
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);
26322644
}
26332645

26342646
SymbolContextList sc_list;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,9 @@ class SymbolFileDWARF : public SymbolFileCommon {
378378
/// SymbolFile.
379379
///
380380
/// \returns A valid definition DIE on success.
381-
DWARFDIE FindFunctionDefinition(const FunctionCallLabel &label,
382-
const DWARFDIE &declaration);
381+
llvm::Expected<DWARFDIE>
382+
FindFunctionDefinition(const FunctionCallLabel &label,
383+
const DWARFDIE &declaration);
383384

384385
protected:
385386
SymbolFileDWARF(const SymbolFileDWARF &) = delete;

0 commit comments

Comments
 (0)