[llvm-branch-commits] [clang] [Clang] Add pointer field protection feature. (PR #172119)
Peter Collingbourne via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jan 12 19:34:56 PST 2026
================
@@ -905,6 +906,29 @@ bool ConstStructBuilder::Build(const APValue &Val, const RecordDecl *RD,
if (!EltInit)
return false;
+ if (CGM.getContext().isPFPField(*Field)) {
+ llvm::ConstantInt *Disc;
+ llvm::Constant *AddrDisc;
+ if (CGM.getContext().arePFPFieldsTriviallyCopyable(RD)) {
+ uint64_t FieldSignature =
+ llvm::getPointerAuthStableSipHash(CGM.getPFPFieldName(*Field));
+ Disc = llvm::ConstantInt::get(CGM.Int64Ty, FieldSignature);
+ AddrDisc = llvm::ConstantPointerNull::get(CGM.VoidPtrTy);
+ } else if (Emitter.isAbstract()) {
----------------
pcc wrote:
`isAbstract` means that we don't know the global's address. Since we can only form a pointer without knowing the address if the fields are trivially copyable, I think this is the right place for the condition.
https://github.com/llvm/llvm-project/pull/172119
More information about the llvm-branch-commits
mailing list