[clang] [llvm] [PAC] Fix address discrimination for type info vtable pointers (PR #102199)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 6 13:32:11 PDT 2024
================
@@ -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
More information about the cfe-commits
mailing list