[clang] [PAC][clang] Implement address/type discrimination for VTT vtable pointers (PR #205808)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 26 00:21:09 PDT 2026


================
@@ -92,10 +91,26 @@ CodeGenVTables::EmitVTTDefinition(llvm::GlobalVariable *VTT,
          VTable->getValueType(), VTable, Idxs, /*InBounds=*/true, InRange);
 
      if (const auto &Schema =
-             CGM.getCodeGenOpts().PointerAuth.CXXVTTVTablePointers)
-       Init = CGM.getConstantSignedPointer(Init, Schema, nullptr, GlobalDecl(),
-                                           QualType());
-
+             CGM.getCodeGenOpts().PointerAuth.CXXVTTVTablePointers) {
+       llvm::Constant *AddressDesc =
+           Schema.isAddressDiscriminated()
+               ? llvm::ConstantExpr::getGetElementPtr(
+                     VTT->getType(), VTT,
+                     llvm::ConstantInt::get(CGM.Int32Ty, Idx))
+               : nullptr;
+       if (Schema.getOtherDiscrimination() ==
----------------
ojhunt wrote:

I need to think about this a bit more - I feel there should be a way to do it more cleanly, but that might just be wishful thinking.

Mostly I would rather it shared the logic with the vtable method slots

https://github.com/llvm/llvm-project/pull/205808


More information about the cfe-commits mailing list