[llvm-branch-commits] [clang] [Clang] Add pointer field protection feature. (PR #133538)

Peter Collingbourne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Dec 5 19:43:16 PST 2025


================
@@ -1310,21 +1310,91 @@ static llvm::Value *CoerceIntOrPtrToIntOrPtr(llvm::Value *Val, llvm::Type *Ty,
   return Val;
 }
 
+static std::vector<PFPField> findPFPCoercedFields(CodeGenFunction &CGF,
+                                                  QualType SrcFETy) {
+  // Coercion directly through memory does not work if the structure has pointer
+  // field protection because the struct in registers has a different bit
+  // pattern to the struct in memory, so we must read the elements one by one
+  // and use them to form the coerced structure.
+  std::vector<PFPField> PFPFields;
+  CGF.getContext().findPFPFields(SrcFETy, CharUnits::Zero(), PFPFields, true);
----------------
pcc wrote:

That fourth argument is `IncludeVBases` again, so `isWithinUnion` should be correct.

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


More information about the llvm-branch-commits mailing list