Skip to content

Commit 499a18a

Browse files
committed
[libc++] Move more attributes to the C++11 syntax
1 parent aad9630 commit 499a18a

File tree

19 files changed

+66
-65
lines changed

19 files changed

+66
-65
lines changed

libcxx/include/__algorithm/simd_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ template <class _Tp, size_t _Np>
126126
using __mask_vec = __simd_vector<bool, _Np>;
127127

128128
// This has MSan disabled du to https://github.com/llvm/llvm-project/issues/85876
129-
auto __impl = [&]<class _MaskT>(_MaskT) _LIBCPP_NO_SANITIZE("memory") noexcept {
129+
auto __impl = [&]<class _MaskT> _LIBCPP_NO_SANITIZE("memory") (_MaskT) noexcept {
130130
# if defined(_LIBCPP_BIG_ENDIAN)
131131
return std::min<size_t>(
132132
_Np, std::__countl_zero(__builtin_bit_cast(_MaskT, __builtin_convertvector(__vec, __mask_vec))));

libcxx/include/__config

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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,8 +431,8 @@ typedef __char32_t char32_t;
431431

432432
# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
433433

434-
# if __has_attribute(exclude_from_explicit_instantiation)
435-
# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
434+
# if __has_cpp_attribute(_Clang::__exclude_from_explicit_instantiation__)
435+
# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION [[_Clang::__exclude_from_explicit_instantiation__]]
436436
# else
437437
// Try to approximate the effect of exclude_from_explicit_instantiation
438438
// (which is that entities are not assumed to be provided by explicit
@@ -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

libcxx/include/__functional/function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class __value_func<_Rp(_ArgTypes...)> {
349349
typedef __base<_Rp(_ArgTypes...)> __func;
350350
__func* __f_;
351351

352-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI static __func* __as_base(void* __p) { return reinterpret_cast<__func*>(__p); }
352+
_LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI static __func* __as_base(void* __p) { return reinterpret_cast<__func*>(__p); }
353353

354354
public:
355355
_LIBCPP_HIDE_FROM_ABI __value_func() _NOEXCEPT : __f_(nullptr) {}

libcxx/include/__functional/hash.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct __murmur2_or_cityhash;
4646

4747
template <class _Size>
4848
struct __murmur2_or_cityhash<_Size, 32> {
49-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK _Size
49+
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK _LIBCPP_HIDE_FROM_ABI _Size
5050
operator()(const void* __key, _Size __len) const {
5151
// murmur2
5252
const _Size __m = 0x5bd1e995;
@@ -82,7 +82,7 @@ struct __murmur2_or_cityhash<_Size, 32> {
8282
template <class _Size>
8383
struct __murmur2_or_cityhash<_Size, 64> {
8484
// cityhash64
85-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK _Size
85+
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK _LIBCPP_HIDE_FROM_ABI _Size
8686
operator()(const void* __key, _Size __len) const {
8787
const char* __s = static_cast<const char*>(__key);
8888
if (__len <= 32) {
@@ -140,7 +140,7 @@ struct __murmur2_or_cityhash<_Size, 64> {
140140

141141
_LIBCPP_HIDE_FROM_ABI static _Size __shift_mix(_Size __val) { return __val ^ (__val >> 47); }
142142

143-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static _Size __hash_len_16(_Size __u, _Size __v) {
143+
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK _LIBCPP_HIDE_FROM_ABI static _Size __hash_len_16(_Size __u, _Size __v) {
144144
const _Size __mul = 0x9ddfea08eb382d69ULL;
145145
_Size __a = (__u ^ __v) * __mul;
146146
__a ^= (__a >> 47);
@@ -150,7 +150,7 @@ struct __murmur2_or_cityhash<_Size, 64> {
150150
return __b;
151151
}
152152

153-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static _Size
153+
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK _LIBCPP_HIDE_FROM_ABI static _Size
154154
__hash_len_0_to_16(const char* __s, _Size __len) {
155155
if (__len > 8) {
156156
const _Size __a = std::__loadword<_Size>(__s);
@@ -177,7 +177,7 @@ struct __murmur2_or_cityhash<_Size, 64> {
177177
return __k2;
178178
}
179179

180-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static _Size
180+
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK _LIBCPP_HIDE_FROM_ABI static _Size
181181
__hash_len_17_to_32(const char* __s, _Size __len) {
182182
const _Size __a = std::__loadword<_Size>(__s) * __k1;
183183
const _Size __b = std::__loadword<_Size>(__s + 8);
@@ -189,7 +189,7 @@ struct __murmur2_or_cityhash<_Size, 64> {
189189

190190
// Return a 16-byte hash for 48 bytes. Quick and dirty.
191191
// Callers do best to use "random-looking" values for a and b.
192-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static pair<_Size, _Size>
192+
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK _LIBCPP_HIDE_FROM_ABI static pair<_Size, _Size>
193193
__weak_hash_len_32_with_seeds(_Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) {
194194
__a += __w;
195195
__b = __rotate(__b + __a + __z, 21);
@@ -201,7 +201,7 @@ struct __murmur2_or_cityhash<_Size, 64> {
201201
}
202202

203203
// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
204-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static pair<_Size, _Size>
204+
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK _LIBCPP_HIDE_FROM_ABI static pair<_Size, _Size>
205205
__weak_hash_len_32_with_seeds(const char* __s, _Size __a, _Size __b) {
206206
return __weak_hash_len_32_with_seeds(
207207
std::__loadword<_Size>(__s),
@@ -213,7 +213,7 @@ struct __murmur2_or_cityhash<_Size, 64> {
213213
}
214214

215215
// Return an 8-byte hash for 33 to 64 bytes.
216-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static _Size
216+
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK _LIBCPP_HIDE_FROM_ABI static _Size
217217
__hash_len_33_to_64(const char* __s, size_t __len) {
218218
_Size __z = std::__loadword<_Size>(__s + 24);
219219
_Size __a = std::__loadword<_Size>(__s) + (__len + std::__loadword<_Size>(__s + __len - 16)) * __k0;

libcxx/include/__hash_table

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,7 @@ _LIBCPP_HIDE_FROM_ABI void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_hand
17071707

17081708
template <class _Tp, class _Hash, class _Equal, class _Alloc>
17091709
template <bool _UniqueKeys>
1710-
void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK {
1710+
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) {
17111711
if (__n == 1)
17121712
__n = 2;
17131713
else if (__n & (__n - 1))

libcxx/include/__memory/addressof.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
_LIBCPP_BEGIN_NAMESPACE_STD
2020

2121
template <class _Tp>
22-
inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* addressof(_Tp& __x) _NOEXCEPT {
22+
_LIBCPP_NO_CFI inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI _Tp* addressof(_Tp& __x) _NOEXCEPT {
2323
return __builtin_addressof(__x);
2424
}
2525

libcxx/include/__memory/shared_ptr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ struct __shared_ptr_emplace : __shared_weak_count {
208208
return std::addressof(reinterpret_cast<_Data*>(__buffer_)->__alloc_);
209209
}
210210

211-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI __value_type* __get_elem() _NOEXCEPT {
211+
_LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI __value_type* __get_elem() _NOEXCEPT {
212212
return std::addressof(reinterpret_cast<_Data*>(__buffer_)->__elem_);
213213
}
214214
};

libcxx/include/__memory/temp_value.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct __temp_value {
4545
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& get() { return *__addr(); }
4646

4747
template <class... _Args>
48-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_CONSTEXPR_SINCE_CXX20 __temp_value(_Alloc& __alloc, _Args&&... __args)
48+
_LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __temp_value(_Alloc& __alloc, _Args&&... __args)
4949
: __a(__alloc) {
5050
_Traits::construct(__a, __addr(), std::forward<_Args>(__args)...);
5151
}

libcxx/include/__memory/unique_temporary_buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ template <class _Tp>
4848
using __unique_temporary_buffer _LIBCPP_NODEBUG = unique_ptr<_Tp, __temporary_buffer_deleter<_Tp> >;
4949

5050
template <class _Tp>
51-
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_CONSTEXPR_SINCE_CXX23 __unique_temporary_buffer<_Tp>
51+
_LIBCPP_NO_CFI inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __unique_temporary_buffer<_Tp>
5252
__allocate_unique_temporary_buffer(ptrdiff_t __count) {
5353
using __deleter_type = __temporary_buffer_deleter<_Tp>;
5454
using __unique_buffer_type = __unique_temporary_buffer<_Tp>;

libcxx/include/__new/allocate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ _LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) _NOEXCEPT {
5050
}
5151

5252
template <class _Tp>
53-
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp*
53+
_LIBCPP_NO_CFI inline _LIBCPP_HIDE_FROM_ABI _Tp*
5454
__libcpp_allocate(__element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) {
5555
size_t __size = static_cast<size_t>(__n) * sizeof(_Tp);
5656
#if _LIBCPP_HAS_ALIGNED_ALLOCATION

0 commit comments

Comments
 (0)