================
@@ -3955,9 +3955,23 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type 
*Ty) {
                                                           VTable, Two);
   }
 
-  if (auto &Schema = CGM.getCodeGenOpts().PointerAuth.CXXTypeInfoVTablePointer)
-    VTable = CGM.getConstantSignedPointer(VTable, Schema, nullptr, 
GlobalDecl(),
-                                          QualType(Ty, 0));
+  if (const auto &Schema =
+          CGM.getCodeGenOpts().PointerAuth.CXXTypeInfoVTablePointer) {
+    llvm::PointerType *PtrTy = llvm::PointerType::get(
+        CGM.getLLVMContext(),
+        CGM.getModule().getDataLayout().getProgramAddressSpace());
+    llvm::Constant *StorageAddress =
----------------
ojhunt wrote:

I'd prefer this be structured rather than using ?:

llvm::Constant *StorageAddress = nullptr;
if (Schema.isAddressDescriminated()) {
  StorageAddress = llvm::ConstantExpr::getIntToPtr(
                   llvm::ConstantInt::get(
                       CGM.IntPtrTy,
                       llvm::ConstantPtrAuth::
                           AddrDiscriminator_CXXTypeInfoVTablePointer),
                   PtrTy);
}

This bug does make me wonder if `getConstantSignedPointer(..)` etc should use a 
std::optional<&> rather than a pointer as that might have made it more obvious 
that the address was not being used in this code (obviously this is not a thing 
we should be changing in this PR)

https://github.com/llvm/llvm-project/pull/102199
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to