[llvm-branch-commits] [libc++] Annotate classes with _LIBCPP_PFP to enable pointer field protection (PR #151652)

Peter Collingbourne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Apr 7 11:19:55 PDT 2026


https://github.com/pcc commented:

> IIUC, pointer field protection is now not applied implicitly by the compiler (to any type? or just to standard library types?). So this patch is almost the inverse of what it started as: instead of disabling PFP for several types, we now instead only opt-in those classes that we want to have PFP for.
>
> In Clang, how is the determination of whether a type is implicitly PFP made in the latest version of PFP?

It's applied implicitly to non-standard-layout types, and that's been the case since the beginning. In this change, I needed to opt in some types that are standard layout. Previously this was done with a trick involving base classes to force them to be non-standard layout, but at your request (in the libc++ RFC), I added an attribute for explicitly opting into PFP, and switched to using it here.

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


More information about the llvm-branch-commits mailing list