summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Collingbourne <pcc@google.com>2025-10-10 16:12:09 -0700
committerPeter Collingbourne <peter@pcc.me.uk>2025-10-10 16:12:09 -0700
commitf37ca5c8544df6232e1fcc782e549d1bdd9edf88 (patch)
treea59ef38579035646f0d8207d19015c88abf12feb
parenta7e4aee8e6e9550ae5e22b3956c6413f9a71282b (diff)
[𝘀𝗽𝗿] changes introduced through rebaseusers/pcc/spr/main.add-pointer-field-protection-feature
Created using spr 1.3.6-beta.1 [skip ci]
-rw-r--r--libcxx/CMakeLists.txt6
-rw-r--r--libcxx/docs/CodingGuidelines.rst11
-rw-r--r--libcxx/include/__config15
-rw-r--r--libcxx/include/string4
4 files changed, 14 insertions, 22 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index a119850cd808..3a87029b5298 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -201,7 +201,11 @@ set(LIBCXX_LIBRARY_VERSION "${LIBCXX_ABI_VERSION}.0" CACHE STRING
For example, -DLIBCXX_LIBRARY_VERSION=x.y will result in the library being named
libc++.x.y.dylib, along with the usual symlinks pointing to that. On Apple platforms,
this also controls the linker's 'current_version' property.")
-set(LIBCXX_ABI_NAMESPACE "__${LIBCXX_ABI_VERSION}" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.")
+set(default_abi_namespace "__${LIBCXX_ABI_VERSION}")
+if(NOT LIBCXX_PFP STREQUAL "none")
+ set(default_abi_namespace "${default_abi_namespace}_pfp_${LIBCXX_PFP}")
+endif()
+set(LIBCXX_ABI_NAMESPACE "${default_abi_namespace}" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.")
if (NOT LIBCXX_ABI_NAMESPACE MATCHES "__.*")
message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE must be a reserved identifier, got '${LIBCXX_ABI_NAMESPACE}'.")
endif()
diff --git a/libcxx/docs/CodingGuidelines.rst b/libcxx/docs/CodingGuidelines.rst
index 0a1ab136c460..9253456b7358 100644
--- a/libcxx/docs/CodingGuidelines.rst
+++ b/libcxx/docs/CodingGuidelines.rst
@@ -200,11 +200,12 @@ 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.
+<https://clang.llvm.org/docs/StructureProtection.html>`_ feature, commonly
+used vocabulary types, or internal base classes or fields thereof,
+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 and their internal base classes or fields should
+be marked with this attribute if they contain pointer fields.
For the time being, PFP is an experimental feature, so our criteria for
marking types with ``_LIBCPP_PFP`` may change.
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 933f5ff93161..4dd513e09276 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -484,21 +484,8 @@ typedef __char32_t char32_t;
# define _LIBCPP_EXCEPTIONS_SIG e
# endif
-# if !_LIBCPP_HAS_EXCEPTIONS
-# define _LIBCPP_EXCEPTIONS_SIG n
-# else
-# define _LIBCPP_EXCEPTIONS_SIG e
-# endif
-
-# if defined(__POINTER_FIELD_PROTECTION__)
-# define _LIBCPP_PFP_SIG p
-# else
-# define _LIBCPP_PFP_SIG
-# endif
-
# define _LIBCPP_ODR_SIGNATURE \
- _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_EXCEPTIONS_SIG), _LIBCPP_PFP_SIG), \
- _LIBCPP_VERSION)
+ _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_EXCEPTIONS_SIG), _LIBCPP_VERSION)
// This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
// on two levels:
diff --git a/libcxx/include/string b/libcxx/include/string
index 363f27a51648..fbed735829f7 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -825,7 +825,7 @@ private:
# ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
- struct __long {
+ struct _LIBCPP_PFP __long {
__long() = default;
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __long(__alloc_result __alloc, size_type __size)
@@ -879,7 +879,7 @@ private:
// previous definition that did not use bit fields. This is because on
// some platforms bit fields have a default size rather than the actual
// size used, e.g., it is 4 bytes on AIX. See D128285 for details.
- struct __long {
+ struct _LIBCPP_PFP __long {
__long() = default;
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __long(__alloc_result __alloc, size_type __size)