[libcxx-commits] [libcxx] [libc++][NFC] Move attribute macros out of __config into a detail header (PR #176903)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 20 03:42:15 PST 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions ,h -- libcxx/include/__configuration/attributes.h libcxx/include/__config --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/__configuration/attributes.h b/libcxx/include/__configuration/attributes.h
index de35c1d5f..94b391836 100644
--- a/libcxx/include/__configuration/attributes.h
+++ b/libcxx/include/__configuration/attributes.h
@@ -19,135 +19,135 @@
// Attributes relevant for layout ABI
// ----------------------------------
-# if __has_cpp_attribute(msvc::no_unique_address)
+#if __has_cpp_attribute(msvc::no_unique_address)
// MSVC implements [[no_unique_address]] as a silent no-op currently.
// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
// However, MSVC implements [[msvc::no_unique_address]] which does what
// [[no_unique_address]] is supposed to do, in general.
-# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
-# else
-# define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
-# endif
+# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
+#else
+# define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
+#endif
#define _LIBCPP_PACKED __attribute__((__packed__))
// Attributes affecting overload resolution
// ----------------------------------------
-# if __has_attribute(__enable_if__)
-# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
-# endif
+#if __has_attribute(__enable_if__)
+# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
+#endif
// Visibility attributes
// ---------------------
-# if defined(_LIBCPP_OBJECT_FORMAT_COFF)
+#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
-# ifdef _DLL
-# define _LIBCPP_CRT_FUNC __declspec(dllimport)
-# else
-# define _LIBCPP_CRT_FUNC
-# endif
+# ifdef _DLL
+# define _LIBCPP_CRT_FUNC __declspec(dllimport)
+# else
+# define _LIBCPP_CRT_FUNC
+# endif
-# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS
+# define _LIBCPP_EXPORTED_FROM_ABI
+# elif defined(_LIBCPP_BUILDING_LIBRARY)
+# if defined(__MINGW32__)
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllexport)
# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-# define _LIBCPP_OVERRIDABLE_FUNC_VIS
-# define _LIBCPP_EXPORTED_FROM_ABI
-# elif defined(_LIBCPP_BUILDING_LIBRARY)
-# if defined(__MINGW32__)
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllexport)
-# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-# else
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __declspec(dllexport)
-# endif
-# define _LIBCPP_OVERRIDABLE_FUNC_VIS __declspec(dllexport)
-# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
# else
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllimport)
-# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-# define _LIBCPP_OVERRIDABLE_FUNC_VIS
-# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __declspec(dllexport)
# endif
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS __declspec(dllexport)
+# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
+# else
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllimport)
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS
+# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
+# endif
-# define _LIBCPP_HIDDEN
-# define _LIBCPP_TEMPLATE_DATA_VIS
-# define _LIBCPP_NAMESPACE_VISIBILITY
+# define _LIBCPP_HIDDEN
+# define _LIBCPP_TEMPLATE_DATA_VIS
+# define _LIBCPP_NAMESPACE_VISIBILITY
-# else
+#else
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
-# else
-# define _LIBCPP_VISIBILITY(vis)
-# endif
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
+# else
+# define _LIBCPP_VISIBILITY(vis)
+# endif
-# define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
-# define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
-# define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
-# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+# define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
+# define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
+# define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
// TODO: Make this a proper customization point or remove the option to override it.
-# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
-# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
-# endif
+# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
+# endif
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
-# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__type_visibility__("default")))
-# elif !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__visibility__("default")))
-# else
-# define _LIBCPP_NAMESPACE_VISIBILITY
-# endif
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
+# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__type_visibility__("default")))
+# elif !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__visibility__("default")))
+# else
+# define _LIBCPP_NAMESPACE_VISIBILITY
+# endif
-# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
+#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
// hide_from_abi
// -------------
-# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
+#define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
-# if __has_attribute(exclude_from_explicit_instantiation)
-# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
-# else
+#if __has_attribute(exclude_from_explicit_instantiation)
+# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
+#else
// Try to approximate the effect of exclude_from_explicit_instantiation
// (which is that entities are not assumed to be provided by explicit
// template instantiations in the dylib) by always inlining those entities.
-# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
-# endif
+# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
+#endif
-# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
-# define _LIBCPP_HARDENING_SIG f
-# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
-# define _LIBCPP_HARDENING_SIG s
-# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
-# define _LIBCPP_HARDENING_SIG d
-# else
-# define _LIBCPP_HARDENING_SIG n // "none"
-# endif
+#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
+# define _LIBCPP_HARDENING_SIG f
+#elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
+# define _LIBCPP_HARDENING_SIG s
+#elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
+# define _LIBCPP_HARDENING_SIG d
+#else
+# define _LIBCPP_HARDENING_SIG n // "none"
+#endif
-# if _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_OBSERVE
-# define _LIBCPP_ASSERTION_SEMANTIC_SIG o
-# elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE
-# define _LIBCPP_ASSERTION_SEMANTIC_SIG q
-# elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_ENFORCE
-# define _LIBCPP_ASSERTION_SEMANTIC_SIG e
-# else
-# define _LIBCPP_ASSERTION_SEMANTIC_SIG i // `ignore`
-# endif
+#if _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_OBSERVE
+# define _LIBCPP_ASSERTION_SEMANTIC_SIG o
+#elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE
+# define _LIBCPP_ASSERTION_SEMANTIC_SIG q
+#elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_ENFORCE
+# define _LIBCPP_ASSERTION_SEMANTIC_SIG e
+#else
+# define _LIBCPP_ASSERTION_SEMANTIC_SIG i // `ignore`
+#endif
-# if !_LIBCPP_HAS_EXCEPTIONS
-# define _LIBCPP_EXCEPTIONS_SIG n
-# else
-# define _LIBCPP_EXCEPTIONS_SIG e
-# endif
+#if !_LIBCPP_HAS_EXCEPTIONS
+# define _LIBCPP_EXCEPTIONS_SIG n
+#else
+# define _LIBCPP_EXCEPTIONS_SIG e
+#endif
-# define _LIBCPP_ODR_SIGNATURE \
- _LIBCPP_CONCAT( \
- _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_ASSERTION_SEMANTIC_SIG), _LIBCPP_EXCEPTIONS_SIG), \
- _LIBCPP_VERSION)
+#define _LIBCPP_ODR_SIGNATURE \
+ _LIBCPP_CONCAT( \
+ _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_ASSERTION_SEMANTIC_SIG), _LIBCPP_EXCEPTIONS_SIG), \
+ _LIBCPP_VERSION)
// This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
// on two levels:
@@ -200,14 +200,14 @@
// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
-# ifndef _LIBCPP_NO_ABI_TAG
-# define _LIBCPP_HIDE_FROM_ABI \
- _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
- __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))))
-# else
-# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
-# endif
-# define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
+#ifndef _LIBCPP_NO_ABI_TAG
+# define _LIBCPP_HIDE_FROM_ABI \
+ _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
+ __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))))
+#else
+# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
+#endif
+#define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
// Optional attributes
// -------------------
@@ -345,11 +345,11 @@
# define _LIBCPP_REQUIRES_CAPABILITY(...)
#endif
-# if __has_cpp_attribute(_Clang::__no_thread_safety_analysis__)
-# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS [[_Clang::__no_thread_safety_analysis__]]
-# else
-# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
-# endif
+#if __has_cpp_attribute(_Clang::__no_thread_safety_analysis__)
+# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS [[_Clang::__no_thread_safety_analysis__]]
+#else
+# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+#endif
#if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
@@ -370,7 +370,7 @@
# define _LIBCPP_DIAGNOSE_NULLPTR
#endif
-# if defined(__CUDACC__) || defined(__CUDA_ARCH__) || defined(__CUDA_LIBDEVICE__)
+#if defined(__CUDACC__) || defined(__CUDA_ARCH__) || defined(__CUDA_LIBDEVICE__)
// The CUDA SDK contains an unfortunate definition for the __noinline__ macro,
// which breaks the regular __attribute__((__noinline__)) syntax. Therefore,
// when compiling for CUDA we use the non-underscored version of the noinline
@@ -380,32 +380,32 @@
// this issue properly in the SDK headers.
//
// See https://github.com/llvm/llvm-project/pull/73838 for more details.
-# define _LIBCPP_NOINLINE __attribute__((noinline))
-# elif __has_attribute(__noinline__)
-# define _LIBCPP_NOINLINE __attribute__((__noinline__))
-# else
-# define _LIBCPP_NOINLINE
-# endif
+# define _LIBCPP_NOINLINE __attribute__((noinline))
+#elif __has_attribute(__noinline__)
+# define _LIBCPP_NOINLINE __attribute__((__noinline__))
+#else
+# define _LIBCPP_NOINLINE
+#endif
// Deprecation macros
// ------------------
// Deprecations warnings are always enabled, except when users explicitly opt-out
// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
-# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
-# if __has_attribute(__deprecated__)
-# define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
-# define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
-# elif _LIBCPP_STD_VER >= 14
-# define _LIBCPP_DEPRECATED [[deprecated]]
-# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
-# else
-# define _LIBCPP_DEPRECATED
-# define _LIBCPP_DEPRECATED_(m)
-# endif
+#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+# if __has_attribute(__deprecated__)
+# define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
+# define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
+# elif _LIBCPP_STD_VER >= 14
+# define _LIBCPP_DEPRECATED [[deprecated]]
+# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
# else
# define _LIBCPP_DEPRECATED
# define _LIBCPP_DEPRECATED_(m)
# endif
+#else
+# define _LIBCPP_DEPRECATED
+# define _LIBCPP_DEPRECATED_(m)
+#endif
#endif // _LIBCPP___CONFIGURATION_ATTRIBUTES_H
``````````
</details>
https://github.com/llvm/llvm-project/pull/176903
More information about the libcxx-commits
mailing list