Skip to content

Commit 3b8faee

Browse files
authored
[libc++] Switch _LIBCPP_NODEBUG to [[gnu::nodebug]] (llvm#120720)
This makes the placement of the attribute more consistent. This also avoids clang dropping the attribute silently (see llvm#120722).
1 parent bc23ef3 commit 3b8faee

22 files changed

+70
-75
lines changed

libcxx/include/__config

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,11 +1170,7 @@ typedef __char32_t char32_t;
11701170
# define _LIBCPP_NOESCAPE
11711171
# endif
11721172

1173-
# if __has_attribute(__nodebug__)
1174-
# define _LIBCPP_NODEBUG __attribute__((__nodebug__))
1175-
# else
1176-
# define _LIBCPP_NODEBUG
1177-
# endif
1173+
# define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]]
11781174

11791175
# if __has_attribute(__standalone_debug__)
11801176
# define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))

libcxx/include/__functional/function.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> {
146146
_LIBCPP_COMPRESSED_PAIR(_Fp, __func_, _Ap, __alloc_);
147147

148148
public:
149-
typedef _LIBCPP_NODEBUG _Fp _Target;
150-
typedef _LIBCPP_NODEBUG _Ap _Alloc;
149+
using _Target _LIBCPP_NODEBUG = _Fp;
150+
using _Alloc _LIBCPP_NODEBUG = _Ap;
151151

152152
_LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __func_; }
153153

@@ -198,7 +198,7 @@ class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> {
198198
_Fp __f_;
199199

200200
public:
201-
typedef _LIBCPP_NODEBUG _Fp _Target;
201+
using _Target _LIBCPP_NODEBUG = _Fp;
202202

203203
_LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __f_; }
204204

libcxx/include/__memory/allocator_arg_t.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ constexpr allocator_arg_t allocator_arg = allocator_arg_t();
3939

4040
template <class _Tp, class _Alloc, class... _Args>
4141
struct __uses_alloc_ctor_imp {
42-
typedef _LIBCPP_NODEBUG __remove_cvref_t<_Alloc> _RawAlloc;
43-
static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
44-
static const bool __ic = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
45-
static const int value = __ua ? 2 - __ic : 0;
42+
using _RawAlloc _LIBCPP_NODEBUG = __remove_cvref_t<_Alloc>;
43+
static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
44+
static const bool __ic = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
45+
static const int value = __ua ? 2 - __ic : 0;
4646
};
4747

4848
template <class _Tp, class _Alloc, class... _Args>

libcxx/include/__memory/allocator_destructor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020

2121
template <class _Alloc>
2222
class __allocator_destructor {
23-
typedef _LIBCPP_NODEBUG allocator_traits<_Alloc> __alloc_traits;
23+
using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<_Alloc>;
2424

2525
public:
26-
typedef _LIBCPP_NODEBUG typename __alloc_traits::pointer pointer;
27-
typedef _LIBCPP_NODEBUG typename __alloc_traits::size_type size_type;
26+
using pointer _LIBCPP_NODEBUG = typename __alloc_traits::pointer;
27+
using size_type _LIBCPP_NODEBUG = typename __alloc_traits::size_type;
2828

2929
private:
3030
_Alloc& __alloc_;

libcxx/include/__memory/pointer_traits.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ struct __pointer_traits_element_type {};
5050

5151
template <class _Ptr>
5252
struct __pointer_traits_element_type<_Ptr, true> {
53-
typedef _LIBCPP_NODEBUG typename _Ptr::element_type type;
53+
using type _LIBCPP_NODEBUG = typename _Ptr::element_type;
5454
};
5555

5656
template <template <class, class...> class _Sp, class _Tp, class... _Args>
5757
struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> {
58-
typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::element_type type;
58+
using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::element_type;
5959
};
6060

6161
template <template <class, class...> class _Sp, class _Tp, class... _Args>
6262
struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> {
63-
typedef _LIBCPP_NODEBUG _Tp type;
63+
using type _LIBCPP_NODEBUG = _Tp;
6464
};
6565

6666
template <class _Tp, class = void>
@@ -71,12 +71,12 @@ struct __has_difference_type<_Tp, __void_t<typename _Tp::difference_type> > : tr
7171

7272
template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
7373
struct __pointer_traits_difference_type {
74-
typedef _LIBCPP_NODEBUG ptrdiff_t type;
74+
using type _LIBCPP_NODEBUG = ptrdiff_t;
7575
};
7676

7777
template <class _Ptr>
7878
struct __pointer_traits_difference_type<_Ptr, true> {
79-
typedef _LIBCPP_NODEBUG typename _Ptr::difference_type type;
79+
using type _LIBCPP_NODEBUG = typename _Ptr::difference_type;
8080
};
8181

8282
template <class _Tp, class _Up>
@@ -96,18 +96,18 @@ struct __has_rebind {
9696
template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
9797
struct __pointer_traits_rebind {
9898
#ifndef _LIBCPP_CXX03_LANG
99-
typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up> type;
99+
using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>;
100100
#else
101-
typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up>::other type;
101+
using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other;
102102
#endif
103103
};
104104

105105
template <template <class, class...> class _Sp, class _Tp, class... _Args, class _Up>
106106
struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> {
107107
#ifndef _LIBCPP_CXX03_LANG
108-
typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
108+
using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::template rebind<_Up>;
109109
#else
110-
typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
110+
using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::template rebind<_Up>::other;
111111
#endif
112112
};
113113

libcxx/include/__memory/unique_ptr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
161161
private:
162162
_LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);
163163

164-
typedef _LIBCPP_NODEBUG __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
164+
using _DeleterSFINAE _LIBCPP_NODEBUG = __unique_ptr_deleter_sfinae<_Dp>;
165165

166166
template <bool _Dummy>
167167
using _LValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;

libcxx/include/__ranges/join_view.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ template <class _JoinViewIterator>
377377
__has_random_access_iterator_category<typename _JoinViewIterator::_Outer>::value &&
378378
__has_random_access_iterator_category<typename _JoinViewIterator::_Inner>::value)
379379
struct __segmented_iterator_traits<_JoinViewIterator> {
380-
using __segment_iterator =
381-
_LIBCPP_NODEBUG __iterator_with_data<typename _JoinViewIterator::_Outer, typename _JoinViewIterator::_Parent*>;
380+
using __segment_iterator _LIBCPP_NODEBUG =
381+
__iterator_with_data<typename _JoinViewIterator::_Outer, typename _JoinViewIterator::_Parent*>;
382382
using __local_iterator = typename _JoinViewIterator::_Inner;
383383

384384
// TODO: Would it make sense to enable the optimization for other iterator types?

libcxx/include/__tuple/make_tuple_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ struct __make_tuple_types {
6565

6666
template <class... _Types, size_t _Ep>
6767
struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
68-
typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;
68+
using type _LIBCPP_NODEBUG = __tuple_types<_Types...>;
6969
};
7070

7171
template <class... _Types, size_t _Ep>
7272
struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
73-
typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;
73+
using type _LIBCPP_NODEBUG = __tuple_types<_Types...>;
7474
};
7575

7676
_LIBCPP_END_NAMESPACE_STD

libcxx/include/__tuple/sfinae_helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct __tuple_constructible<_Tp, _Up, true, true>
5959

6060
template <size_t _Ip, class... _Tp>
6161
struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > {
62-
typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
62+
using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, __tuple_types<_Tp...> >::type;
6363
};
6464

6565
struct _LIBCPP_EXPORTED_FROM_ABI __check_tuple_constructor_fail {

libcxx/include/__tuple/tuple_element.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element;
2525

2626
template <size_t _Ip, class _Tp>
2727
struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> {
28-
typedef _LIBCPP_NODEBUG const typename tuple_element<_Ip, _Tp>::type type;
28+
using type _LIBCPP_NODEBUG = const typename tuple_element<_Ip, _Tp>::type;
2929
};
3030

3131
template <size_t _Ip, class _Tp>
3232
struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> {
33-
typedef _LIBCPP_NODEBUG volatile typename tuple_element<_Ip, _Tp>::type type;
33+
using type _LIBCPP_NODEBUG = volatile typename tuple_element<_Ip, _Tp>::type;
3434
};
3535

3636
template <size_t _Ip, class _Tp>
3737
struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> {
38-
typedef _LIBCPP_NODEBUG const volatile typename tuple_element<_Ip, _Tp>::type type;
38+
using type _LIBCPP_NODEBUG = const volatile typename tuple_element<_Ip, _Tp>::type;
3939
};
4040

4141
#ifndef _LIBCPP_CXX03_LANG
4242

4343
template <size_t _Ip, class... _Types>
4444
struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > {
4545
static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
46-
typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;
46+
using type _LIBCPP_NODEBUG = __type_pack_element<_Ip, _Types...>;
4747
};
4848

4949
# if _LIBCPP_STD_VER >= 14

0 commit comments

Comments
 (0)