[llvm-branch-commits] [libc++] Annotate classes with _LIBCPP_PFP to enable pointer field protection (PR #151652)
Louis Dionne via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Apr 7 06:55:19 PDT 2026
================
@@ -210,3 +210,17 @@ 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
----------------
ldionne wrote:
I don't think we have much precedent for codifying support for an extension like this in our coding guidelines. I think it's a good idea to do it if we're going to try to support it, but I'd like to capture something about this being done on a best effort basis. Otherwise, the implication is that a patch could be e.g. reverted or blocked because the attribute hasn't been applied properly, which would now contradict our coding guidelines.
Another path forward, which I like even more, would be that if we can actually capture those rules into something systematic, we can add a clang-tidy check that catches when we forget to apply the attribute, and then that becomes a solid guarantee that these annotations are going to be added when they are needed (and it requires even less thinking from contributors). WDYT?
https://github.com/llvm/llvm-project/pull/151652
More information about the llvm-branch-commits
mailing list