Skip to content

Commit 3557c7c

Browse files
committed
[libc++] Remove workarounds for [[nodebug]] not working properly on typedefs in older Clangs
Clang used to support [[nodebug]] everywhere except on typedefs. Since we don't support such old Clangs anymore, we can get rid of _LIBCPP_NODEBUG_TYPE in favour of always using _LIBCPP_NODEBUG. Differential Revision: https://reviews.llvm.org/D108996
1 parent 8f9cc3b commit 3557c7c

19 files changed

+164
-171
lines changed

libcxx/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ function(cxx_add_warning_flags target)
599599
-Wno-user-defined-literals
600600
-Wno-covered-switch-default
601601
-Wno-suggest-override
602-
-Wno-ignored-attributes # FIXME: Caused by _LIBCPP_NODEBUG_TYPE not being supported on older clangs
603602
)
604603
if (LIBCXX_TARGETING_CLANG_CL)
605604
target_add_compile_flags_if_supported(${target} PRIVATE

libcxx/include/__config

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,12 +1287,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
12871287
#define _LIBCPP_NODEBUG
12881288
#endif
12891289

1290-
#if __has_attribute(__nodebug__) && (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900)
1291-
# define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug))
1292-
#else
1293-
# define _LIBCPP_NODEBUG_TYPE
1294-
#endif
1295-
12961290
#if __has_attribute(__standalone_debug__)
12971291
#define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
12981292
#else

libcxx/include/__functional/function.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
127127
__compressed_pair<_Fp, _Ap> __f_;
128128

129129
public:
130-
typedef _LIBCPP_NODEBUG_TYPE _Fp _Target;
131-
typedef _LIBCPP_NODEBUG_TYPE _Ap _Alloc;
130+
typedef _LIBCPP_NODEBUG _Fp _Target;
131+
typedef _LIBCPP_NODEBUG _Ap _Alloc;
132132

133133
_LIBCPP_INLINE_VISIBILITY
134134
const _Target& __target() const { return __f_.first(); }
@@ -205,7 +205,7 @@ class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> {
205205
_Fp __f_;
206206

207207
public:
208-
typedef _LIBCPP_NODEBUG_TYPE _Fp _Target;
208+
typedef _LIBCPP_NODEBUG _Fp _Target;
209209

210210
_LIBCPP_INLINE_VISIBILITY
211211
const _Target& __target() const { return __f_; }

libcxx/include/__functional/hash.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -836,29 +836,29 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
836836

837837
#ifndef _LIBCPP_CXX03_LANG
838838
template <class _Key, class _Hash>
839-
using __check_hash_requirements _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
839+
using __check_hash_requirements _LIBCPP_NODEBUG = integral_constant<bool,
840840
is_copy_constructible<_Hash>::value &&
841841
is_move_constructible<_Hash>::value &&
842842
__invokable_r<size_t, _Hash, _Key const&>::value
843843
>;
844844

845845
template <class _Key, class _Hash = hash<_Key> >
846-
using __has_enabled_hash _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
846+
using __has_enabled_hash _LIBCPP_NODEBUG = integral_constant<bool,
847847
__check_hash_requirements<_Key, _Hash>::value &&
848848
is_default_constructible<_Hash>::value
849849
>;
850850

851851
#if _LIBCPP_STD_VER > 14
852852
template <class _Type, class>
853-
using __enable_hash_helper_imp _LIBCPP_NODEBUG_TYPE = _Type;
853+
using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type;
854854

855855
template <class _Type, class ..._Keys>
856-
using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = __enable_hash_helper_imp<_Type,
856+
using __enable_hash_helper _LIBCPP_NODEBUG = __enable_hash_helper_imp<_Type,
857857
typename enable_if<__all<__has_enabled_hash<_Keys>::value...>::value>::type
858858
>;
859859
#else
860860
template <class _Type, class ...>
861-
using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = _Type;
861+
using __enable_hash_helper _LIBCPP_NODEBUG = _Type;
862862
#endif
863863

864864
#endif // !_LIBCPP_CXX03_LANG

libcxx/include/__functional/unwrap_ref.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
_LIBCPP_BEGIN_NAMESPACE_STD
1919

2020
template <class _Tp>
21-
struct __unwrap_reference { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
21+
struct __unwrap_reference { typedef _LIBCPP_NODEBUG _Tp type; };
2222

2323
template <class _Tp>
2424
class reference_wrapper;
2525

2626
template <class _Tp>
27-
struct __unwrap_reference<reference_wrapper<_Tp> > { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; };
27+
struct __unwrap_reference<reference_wrapper<_Tp> > { typedef _LIBCPP_NODEBUG _Tp& type; };
2828

2929
template <class _Tp>
3030
struct decay;

libcxx/include/__functional/weak_result_type.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct __weak_result_type_imp // bool is true
8989
: public __maybe_derive_from_unary_function<_Tp>,
9090
public __maybe_derive_from_binary_function<_Tp>
9191
{
92-
typedef _LIBCPP_NODEBUG_TYPE typename _Tp::result_type result_type;
92+
typedef _LIBCPP_NODEBUG typename _Tp::result_type result_type;
9393
};
9494

9595
template <class _Tp>
@@ -110,19 +110,19 @@ struct __weak_result_type
110110
template <class _Rp>
111111
struct __weak_result_type<_Rp ()>
112112
{
113-
typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
113+
typedef _LIBCPP_NODEBUG _Rp result_type;
114114
};
115115

116116
template <class _Rp>
117117
struct __weak_result_type<_Rp (&)()>
118118
{
119-
typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
119+
typedef _LIBCPP_NODEBUG _Rp result_type;
120120
};
121121

122122
template <class _Rp>
123123
struct __weak_result_type<_Rp (*)()>
124124
{
125-
typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
125+
typedef _LIBCPP_NODEBUG _Rp result_type;
126126
};
127127

128128
// 1 argument case

libcxx/include/__memory/allocator_arg_t.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
3636
template <class _Tp, class _Alloc, class ..._Args>
3737
struct __uses_alloc_ctor_imp
3838
{
39-
typedef _LIBCPP_NODEBUG_TYPE typename __uncvref<_Alloc>::type _RawAlloc;
39+
typedef _LIBCPP_NODEBUG typename __uncvref<_Alloc>::type _RawAlloc;
4040
static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
4141
static const bool __ic =
4242
is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;

libcxx/include/__memory/allocator_traits.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,26 @@ template <class _Tp, class _Alloc,
3636
class _RawAlloc = typename remove_reference<_Alloc>::type,
3737
bool = __has_pointer<_RawAlloc>::value>
3838
struct __pointer {
39-
using type _LIBCPP_NODEBUG_TYPE = typename _RawAlloc::pointer;
39+
using type _LIBCPP_NODEBUG = typename _RawAlloc::pointer;
4040
};
4141
template <class _Tp, class _Alloc, class _RawAlloc>
4242
struct __pointer<_Tp, _Alloc, _RawAlloc, false> {
43-
using type _LIBCPP_NODEBUG_TYPE = _Tp*;
43+
using type _LIBCPP_NODEBUG = _Tp*;
4444
};
4545

4646
// __const_pointer
4747
_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer);
4848
template <class _Tp, class _Ptr, class _Alloc,
4949
bool = __has_const_pointer<_Alloc>::value>
5050
struct __const_pointer {
51-
using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::const_pointer;
51+
using type _LIBCPP_NODEBUG = typename _Alloc::const_pointer;
5252
};
5353
template <class _Tp, class _Ptr, class _Alloc>
5454
struct __const_pointer<_Tp, _Ptr, _Alloc, false> {
5555
#ifdef _LIBCPP_CXX03_LANG
5656
using type = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;
5757
#else
58-
using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<const _Tp>;
58+
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>;
5959
#endif
6060
};
6161

@@ -64,14 +64,14 @@ _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_void_pointer, void_pointer);
6464
template <class _Ptr, class _Alloc,
6565
bool = __has_void_pointer<_Alloc>::value>
6666
struct __void_pointer {
67-
using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::void_pointer;
67+
using type _LIBCPP_NODEBUG = typename _Alloc::void_pointer;
6868
};
6969
template <class _Ptr, class _Alloc>
7070
struct __void_pointer<_Ptr, _Alloc, false> {
7171
#ifdef _LIBCPP_CXX03_LANG
72-
using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<void>::other;
72+
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<void>::other;
7373
#else
74-
using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<void>;
74+
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<void>;
7575
#endif
7676
};
7777

@@ -80,14 +80,14 @@ _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_void_pointer, const_void_pointer);
8080
template <class _Ptr, class _Alloc,
8181
bool = __has_const_void_pointer<_Alloc>::value>
8282
struct __const_void_pointer {
83-
using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::const_void_pointer;
83+
using type _LIBCPP_NODEBUG = typename _Alloc::const_void_pointer;
8484
};
8585
template <class _Ptr, class _Alloc>
8686
struct __const_void_pointer<_Ptr, _Alloc, false> {
8787
#ifdef _LIBCPP_CXX03_LANG
88-
using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<const void>::other;
88+
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const void>::other;
8989
#else
90-
using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<const void>;
90+
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const void>;
9191
#endif
9292
};
9393

@@ -97,18 +97,18 @@ template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value>
9797
struct __size_type : make_unsigned<_DiffType> { };
9898
template <class _Alloc, class _DiffType>
9999
struct __size_type<_Alloc, _DiffType, true> {
100-
using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::size_type;
100+
using type _LIBCPP_NODEBUG = typename _Alloc::size_type;
101101
};
102102

103103
// __alloc_traits_difference_type
104104
_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type);
105105
template <class _Alloc, class _Ptr, bool = __has_alloc_traits_difference_type<_Alloc>::value>
106106
struct __alloc_traits_difference_type {
107-
using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::difference_type;
107+
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::difference_type;
108108
};
109109
template <class _Alloc, class _Ptr>
110110
struct __alloc_traits_difference_type<_Alloc, _Ptr, true> {
111-
using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::difference_type;
111+
using type _LIBCPP_NODEBUG = typename _Alloc::difference_type;
112112
};
113113

114114
// __propagate_on_container_copy_assignment
@@ -117,7 +117,7 @@ template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_All
117117
struct __propagate_on_container_copy_assignment : false_type { };
118118
template <class _Alloc>
119119
struct __propagate_on_container_copy_assignment<_Alloc, true> {
120-
using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_copy_assignment;
120+
using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_copy_assignment;
121121
};
122122

123123
// __propagate_on_container_move_assignment
@@ -126,7 +126,7 @@ template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_All
126126
struct __propagate_on_container_move_assignment : false_type { };
127127
template <class _Alloc>
128128
struct __propagate_on_container_move_assignment<_Alloc, true> {
129-
using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_move_assignment;
129+
using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_move_assignment;
130130
};
131131

132132
// __propagate_on_container_swap
@@ -135,7 +135,7 @@ template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value>
135135
struct __propagate_on_container_swap : false_type { };
136136
template <class _Alloc>
137137
struct __propagate_on_container_swap<_Alloc, true> {
138-
using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_swap;
138+
using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_swap;
139139
};
140140

141141
// __is_always_equal
@@ -144,7 +144,7 @@ template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value>
144144
struct __is_always_equal : is_empty<_Alloc> { };
145145
template <class _Alloc>
146146
struct __is_always_equal<_Alloc, true> {
147-
using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::is_always_equal;
147+
using type _LIBCPP_NODEBUG = typename _Alloc::is_always_equal;
148148
};
149149

150150
// __allocator_traits_rebind
@@ -158,15 +158,15 @@ struct __has_rebind_other<_Tp, _Up, typename __void_t<
158158

159159
template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
160160
struct __allocator_traits_rebind {
161-
using type _LIBCPP_NODEBUG_TYPE = typename _Tp::template rebind<_Up>::other;
161+
using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other;
162162
};
163163
template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
164164
struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> {
165-
using type _LIBCPP_NODEBUG_TYPE = typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other;
165+
using type _LIBCPP_NODEBUG = typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other;
166166
};
167167
template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
168168
struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> {
169-
using type _LIBCPP_NODEBUG_TYPE = _Alloc<_Up, _Args...>;
169+
using type _LIBCPP_NODEBUG = _Alloc<_Up, _Args...>;
170170
};
171171
_LIBCPP_SUPPRESS_DEPRECATED_POP
172172

@@ -352,7 +352,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
352352
template <class _Traits, class _Tp>
353353
struct __rebind_alloc_helper {
354354
#ifndef _LIBCPP_CXX03_LANG
355-
using type _LIBCPP_NODEBUG_TYPE = typename _Traits::template rebind_alloc<_Tp>;
355+
using type _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>;
356356
#else
357357
using type = typename _Traits::template rebind_alloc<_Tp>::other;
358358
#endif

libcxx/include/__memory/compressed_pair.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>,
115115
"The current implementation is NOT ABI-compatible with the previous "
116116
"implementation for this configuration");
117117

118-
typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T1, 0> _Base1;
119-
typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T2, 1> _Base2;
118+
typedef _LIBCPP_NODEBUG __compressed_pair_elem<_T1, 0> _Base1;
119+
typedef _LIBCPP_NODEBUG __compressed_pair_elem<_T2, 1> _Base2;
120120

121121
template <bool _Dummy = true,
122122
class = typename enable_if<

libcxx/include/__memory/pointer_traits.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ struct __pointer_traits_element_type;
3333
template <class _Ptr>
3434
struct __pointer_traits_element_type<_Ptr, true>
3535
{
36-
typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::element_type type;
36+
typedef _LIBCPP_NODEBUG typename _Ptr::element_type type;
3737
};
3838

3939
template <template <class, class...> class _Sp, class _Tp, class ..._Args>
4040
struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true>
4141
{
42-
typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::element_type type;
42+
typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::element_type type;
4343
};
4444

4545
template <template <class, class...> class _Sp, class _Tp, class ..._Args>
4646
struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false>
4747
{
48-
typedef _LIBCPP_NODEBUG_TYPE _Tp type;
48+
typedef _LIBCPP_NODEBUG _Tp type;
4949
};
5050

5151
template <class _Tp, class = void>
@@ -58,13 +58,13 @@ struct __has_difference_type<_Tp,
5858
template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
5959
struct __pointer_traits_difference_type
6060
{
61-
typedef _LIBCPP_NODEBUG_TYPE ptrdiff_t type;
61+
typedef _LIBCPP_NODEBUG ptrdiff_t type;
6262
};
6363

6464
template <class _Ptr>
6565
struct __pointer_traits_difference_type<_Ptr, true>
6666
{
67-
typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::difference_type type;
67+
typedef _LIBCPP_NODEBUG typename _Ptr::difference_type type;
6868
};
6969

7070
template <class _Tp, class _Up>
@@ -84,19 +84,19 @@ template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
8484
struct __pointer_traits_rebind
8585
{
8686
#ifndef _LIBCPP_CXX03_LANG
87-
typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up> type;
87+
typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up> type;
8888
#else
89-
typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type;
89+
typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up>::other type;
9090
#endif
9191
};
9292

9393
template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
9494
struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true>
9595
{
9696
#ifndef _LIBCPP_CXX03_LANG
97-
typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
97+
typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
9898
#else
99-
typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
99+
typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
100100
#endif
101101
};
102102

libcxx/include/__memory/shared_ptr.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4848
template <class _Alloc>
4949
class __allocator_destructor
5050
{
51-
typedef _LIBCPP_NODEBUG_TYPE allocator_traits<_Alloc> __alloc_traits;
51+
typedef _LIBCPP_NODEBUG allocator_traits<_Alloc> __alloc_traits;
5252
public:
53-
typedef _LIBCPP_NODEBUG_TYPE typename __alloc_traits::pointer pointer;
54-
typedef _LIBCPP_NODEBUG_TYPE typename __alloc_traits::size_type size_type;
53+
typedef _LIBCPP_NODEBUG typename __alloc_traits::pointer pointer;
54+
typedef _LIBCPP_NODEBUG typename __alloc_traits::size_type size_type;
5555
private:
5656
_Alloc& __alloc_;
5757
size_type __s_;

0 commit comments

Comments
 (0)