Skip to content

Commit a139a9e

Browse files
committed
fixup! fix constructor aliasing
1 parent 4e242f8 commit a139a9e

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,6 +2488,7 @@ llvm::Error SymbolFileDWARF::FindAndResolveFunction(
24882488
lldb::eFunctionNameTypeMethod,
24892489
lldb::eLanguageTypeUnknown);
24902490

2491+
llvm::DenseMap<uint8_t, DWARFDIE> variant_to_die;
24912492
m_index->GetFunctions(info, *this, {}, [&](DWARFDIE entry) {
24922493
if (entry.GetAttributeValueAsUnsigned(llvm::dwarf::DW_AT_declaration, 0))
24932494
return true;
@@ -2516,14 +2517,28 @@ llvm::Error SymbolFileDWARF::FindAndResolveFunction(
25162517
if (D.partialDemangle(mangled))
25172518
return true;
25182519

2519-
if (D.getCtorOrDtorVariant() != structor_variant)
2520+
auto maybe_variant = D.getCtorOrDtorVariant();
2521+
if (!maybe_variant)
25202522
return true;
25212523

2522-
die = entry;
2524+
assert(!variant_to_die.contains(*maybe_variant));
25232525

2524-
return false;
2526+
variant_to_die[*maybe_variant] = entry;
2527+
2528+
return true;
25252529
});
25262530

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+
} else if (!lookup_name.starts_with("~") && structor_variant == 1)
2536+
// On Linux the C1 constructor variant is often an alias
2537+
// to C2 (and C1 is never actually emitted into the object file).
2538+
if (auto it = variant_to_die.find(2); it != variant_to_die.end())
2539+
die = it->getSecond();
2540+
}
2541+
25272542
if (!die.IsValid())
25282543
return llvm::createStringError(
25292544
llvm::formatv("failed to find definition DIE for [lookup_name={0}] "

0 commit comments

Comments
 (0)