Skip to content

Commit b716bcb

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

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

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

Lines changed: 20 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,30 @@ 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+
}
2536+
// TODO: only do this for constructors.
2537+
else if (structor_variant == 1)
2538+
// On Linux the C1 constructor variant is often an alias
2539+
// to C2 (and C1 is never actually emitted into the object file).
2540+
if (auto it = variant_to_die.find(2); it != variant_to_die.end())
2541+
die = it->getSecond();
2542+
}
2543+
25272544
if (!die.IsValid())
25282545
return llvm::createStringError(
25292546
llvm::formatv("failed to find definition DIE for [lookup_name={0}] "

0 commit comments

Comments
 (0)