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

Florian Mayer via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jan 13 08:30:16 PST 2026


================
@@ -236,6 +236,22 @@ static bool IsEligibleForReplacement(Sema &SemaRef, const CXXRecordDecl *D) {
   return !D->hasDeletedDestructor();
 }
 
+static bool IsImplementationDefinedNonRelocatable(Sema &SemaRef,
+                                                  const CXXRecordDecl *D) {
+  // The implementation-defined carveout only exists for polymorphic types.
+  if (!D->isPolymorphic())
+    return false;
+
+  std::vector<PFPField> pfpFields;
+  SemaRef.Context.findPFPFields(SemaRef.Context.getCanonicalTagType(D),
+                                CharUnits::Zero(), pfpFields, true);
+  for (PFPField f : pfpFields)
----------------
fmayer wrote:

personal preference, optional:

```cc
any_of(PFPFields, [](const PFPField &f) { return f.isWithinUnion; })
```

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


More information about the llvm-branch-commits mailing list