[libcxx-commits] [libcxx] [libc++] Introduce ABI sensitive areas to avoid requiring _LIBCPP_HIDE_FROM_ABI everywhere (PR #131156)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 13 09:19:46 PDT 2025
================
@@ -577,12 +577,25 @@ typedef __char32_t char32_t;
# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS
# endif
-// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
// clang-format off
-# define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \
- namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
+# define _LIBCPP_BEGIN_HIDE_FROM_ABI \
+ _LIBCPP_DIAGNOSTIC_PUSH \
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wpragma-clang-attribute") \
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wignored-attributes") \
+ _Pragma(_LIBCPP_TOSTRING(clang attribute _LibcxxHideFromABI.push(__attribute__(( \
+ __exclude_from_explicit_instantiation__, __abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE)))), \
+ apply_to = function))) \
+ _LIBCPP_DIAGNOSTIC_POP
+# define _LIBCPP_END_HIDE_FROM_ABI _Pragma("clang attribute _LibcxxHideFromABI.pop")
+
+# define _LIBCPP_BEGIN_ABI_SENSITIVE _LIBCPP_END_HIDE_FROM_ABI
+# define _LIBCPP_END_ABI_SENSITIVE _LIBCPP_BEGIN_HIDE_FROM_ABI
+
+// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
+# define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS _LIBCPP_BEGIN_HIDE_FROM_ABI \
+ namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT _LIBCPP_HIDDEN std { \
----------------
ldionne wrote:
Why is `_LIBCPP_HIDDEN` required here? That seems surprising.
Answer: that's because we can't apply visibility attributes with the pragma push/pop, so we need to do it by applying the visibility attribute on the namespace.
https://github.com/llvm/llvm-project/pull/131156
More information about the libcxx-commits
mailing list