@@ -303,8 +303,8 @@ _LIBCPP_HARDENING_MODE_DEBUG
303303# else
304304
305305# define _LIBCPP_ALIGNOF (_Tp ) _Alignof (_Tp)
306- # define _ALIGNAS_TYPE (x ) __attribute__(( __aligned__(_LIBCPP_ALIGNOF(x))))
307- # define _ALIGNAS (x ) __attribute__(( __aligned__(x)))
306+ # define _ALIGNAS_TYPE (x ) [[__gnu__:: __aligned__(_LIBCPP_ALIGNOF(x))]]
307+ # define _ALIGNAS (x ) [[__gnu__:: __aligned__(x)]]
308308# define nullptr __nullptr
309309# define _NOEXCEPT throw ()
310310# define _NOEXCEPT_ (...)
@@ -431,7 +431,7 @@ typedef __char32_t char32_t;
431431
432432# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
433433
434- # if __has_attribute(exclude_from_explicit_instantiation )
434+ # if __has_cpp_attribute(_Clang::__exclude_from_explicit_instantiation__ )
435435# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
436436# else
437437// Try to approximate the effect of exclude_from_explicit_instantiation
@@ -817,7 +817,7 @@ typedef __char32_t char32_t;
817817# endif
818818
819819# ifndef _LIBCPP_WEAK
820- # define _LIBCPP_WEAK __attribute__ (( __weak__))
820+ # define _LIBCPP_WEAK [[__gnu__:: __weak__]]
821821# endif
822822
823823// Thread API
@@ -969,24 +969,24 @@ typedef __char32_t char32_t;
969969# if _LIBCPP_STD_VER >= 20
970970# define _LIBCPP_CONSTINIT constinit
971971# elif __has_attribute(__require_constant_initialization__)
972- # define _LIBCPP_CONSTINIT __attribute__ (( __require_constant_initialization__))
972+ # define _LIBCPP_CONSTINIT [[_Clang:: __require_constant_initialization__]]
973973# else
974974# define _LIBCPP_CONSTINIT
975975# endif
976976
977977# if defined(__CUDACC__) || defined(__CUDA_ARCH__) || defined(__CUDA_LIBDEVICE__)
978978// The CUDA SDK contains an unfortunate definition for the __noinline__ macro,
979- // which breaks the regular __attribute__(( __noinline__)) syntax. Therefore,
979+ // which breaks the regular [[__gnu__:: __noinline__]] syntax. Therefore,
980980// when compiling for CUDA we use the non-underscored version of the noinline
981981// attribute.
982982//
983983// This is a temporary workaround and we still expect the CUDA SDK team to solve
984984// this issue properly in the SDK headers.
985985//
986986// See https://github.com/llvm/llvm-project/pull/73838 for more details.
987- # define _LIBCPP_NOINLINE __attribute__ (( noinline))
987+ # define _LIBCPP_NOINLINE [[__gnu__:: noinline]]
988988# elif __has_attribute(__noinline__)
989- # define _LIBCPP_NOINLINE __attribute__ (( __noinline__))
989+ # define _LIBCPP_NOINLINE [[__gnu__:: __noinline__]]
990990# else
991991# define _LIBCPP_NOINLINE
992992# endif
@@ -1131,19 +1131,19 @@ typedef __char32_t char32_t;
11311131
11321132// Optional attributes - these are useful for a better QoI, but not required to be available
11331133
1134- # define _LIBCPP_NOALIAS __attribute__ (( __malloc__))
1134+ # define _LIBCPP_NOALIAS [[__gnu__:: __malloc__]]
11351135# define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]]
11361136# define _LIBCPP_NO_SANITIZE (...) __attribute__((__no_sanitize__(__VA_ARGS__)))
1137- # define _LIBCPP_INIT_PRIORITY_MAX __attribute__ (( __init_priority__(100 )))
1137+ # define _LIBCPP_INIT_PRIORITY_MAX [[__gnu__:: __init_priority__(100 )]]
11381138# define _LIBCPP_ATTRIBUTE_FORMAT (archetype, format_string_index, first_format_arg_index ) \
11391139 __attribute__ ((__format__(archetype, format_string_index, first_format_arg_index)))
1140- # define _LIBCPP_PACKED __attribute__ (( __packed__))
1140+ # define _LIBCPP_PACKED [[__gnu__:: __packed__]]
11411141
11421142// Use a function like macro to imply that it must be followed by a semicolon
11431143# define _LIBCPP_FALLTHROUGH () [[fallthrough]]
11441144
1145- # if __has_attribute( __no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC )
1146- # define _LIBCPP_NO_CFI __attribute__ (( __no_sanitize__(" cfi" )))
1145+ # if __has_cpp_attribute(_Clang:: __no_sanitize__)
1146+ # define _LIBCPP_NO_CFI [[_Clang:: __no_sanitize__(" cfi" )]]
11471147# else
11481148# define _LIBCPP_NO_CFI
11491149# endif
@@ -1204,8 +1204,8 @@ typedef __char32_t char32_t;
12041204# endif
12051205
12061206// Allow for build-time disabling of unsigned integer sanitization
1207- # if __has_attribute(no_sanitize) && !defined(_LIBCPP_COMPILER_GCC )
1208- # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__ (( __no_sanitize__(" unsigned-integer-overflow" )))
1207+ # if __has_cpp_attribute(_Clang::__no_sanitize__ )
1208+ # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK [[_Clang:: __no_sanitize__(" unsigned-integer-overflow" )]]
12091209# else
12101210# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
12111211# endif
0 commit comments