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

Kristina Bessonova via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 26 02:12:28 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() ==
----------------
chbessonova wrote:

I agree it may be a bit too straightforward, but I couldn't come up with a cleaner approach. Did you have something specific in mind?

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


More information about the cfe-commits mailing list