[clang] [lldb] [lldb] Support arm64e C++ vtable pointer signing (PR #187611)
Michael Buch via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 20 05:50:44 PDT 2026
================
@@ -62,8 +63,21 @@ CodeGenModule::getPointerAuthDeclDiscriminator(GlobalDecl Declaration) {
uint16_t &EntityHash = PtrAuthDiscriminatorHashes[Declaration];
if (EntityHash == 0) {
- StringRef Name = getMangledName(Declaration);
- EntityHash = llvm::getPointerAuthStableSipHash(Name);
+ const auto *ND = cast<NamedDecl>(Declaration.getDecl());
+ // If the declaration has an AsmLabelAttr (e.g., LLDB expression evaluator
+ // attaches one to map imported decls to debuggee symbols), the asm label
+ // would be used as the mangled name, producing a wrong discriminator.
+ // Compute the real C++ mangled name instead so the discriminator matches
+ // what the original translation unit used.
+ if (ND->hasAttr<AsmLabelAttr>()) {
+ SmallString<256> Buffer;
+ llvm::raw_svector_ostream Out(Buffer);
+ getCXXABI().getMangleContext().mangleCXXName(Declaration, Out);
+ EntityHash = llvm::getPointerAuthStableSipHash(Out.str());
+ } else {
+ StringRef Name = getMangledName(Declaration);
+ EntityHash = llvm::getPointerAuthStableSipHash(Name);
+ }
----------------
Michael137 wrote:
There's always the `DebuggerSupport` language option that all decls created by LLDB from DWARF carry
We considered a dedicated debugger specific clang attribute, but i didnt like the idea of having all the places that handle AsmLabelAttr also handle that new attribute.
We should just check the lldb mangling prefix (as mentioned in my comment above we already do so in ItaniumMangle)
https://github.com/llvm/llvm-project/pull/187611
More information about the cfe-commits
mailing list