[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
Fri Oct 10 16:13:02 PDT 2025
================
@@ -195,3 +195,16 @@ prevent compilers from generating said debug information. Aliases inside type tr
should be annotated for the same reason.
This is enforced by the clang-tidy check ``libcpp-nodebug-on-aliases``.
+
+Pointer field protection
+========================
+
+To improve the effectiveness of Clang's `pointer field protection
+<https://clang.llvm.org/docs/StructureProtection.html>`_ feature,
+commonly used vocabulary types with pointer fields are marked with the
+``_LIBCPP_PFP`` attribute, to give Clang permission to use PFP to protect
+their pointer fields. Newly added vocabulary types should be marked with
+this attribute if they contain pointer fields.
----------------
pcc wrote:
That was an oversight; now added.
Technically, `basic_string::__long` is the type that needs to be annotated because that's the one with a pointer field, so that's what I did. I also improved the wording here to clarify that internal base classes and fields need the annotations if they have pointer fields.
https://github.com/llvm/llvm-project/pull/151652
More information about the llvm-branch-commits
mailing list