Skip to content

Commit f695852

Browse files
authored
[libc++] Put _LIBCPP_NODEBUG on all internal aliases (#118710)
This significantly reduces the amount of debug information generated for codebases using libc++, without hurting the debugging experience.
1 parent 4751f47 commit f695852

File tree

156 files changed

+599
-504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+599
-504
lines changed

libcxx/include/__algorithm/comp_ref_type.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ struct __debug_less {
5656
// Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference.
5757
#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
5858
template <class _Comp>
59-
using __comp_ref_type = __debug_less<_Comp>;
59+
using __comp_ref_type _LIBCPP_NODEBUG = __debug_less<_Comp>;
6060
#else
6161
template <class _Comp>
62-
using __comp_ref_type = _Comp&;
62+
using __comp_ref_type _LIBCPP_NODEBUG = _Comp&;
6363
#endif
6464

6565
_LIBCPP_END_NAMESPACE_STD

libcxx/include/__algorithm/copy.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct __copy_impl {
4747

4848
template <class _InIter, class _OutIter>
4949
struct _CopySegment {
50-
using _Traits = __segmented_iterator_traits<_InIter>;
50+
using _Traits _LIBCPP_NODEBUG = __segmented_iterator_traits<_InIter>;
5151

5252
_OutIter& __result_;
5353

libcxx/include/__algorithm/iterator_operations.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ struct _RangeAlgPolicy {};
4848
template <>
4949
struct _IterOps<_RangeAlgPolicy> {
5050
template <class _Iter>
51-
using __value_type = iter_value_t<_Iter>;
51+
using __value_type _LIBCPP_NODEBUG = iter_value_t<_Iter>;
5252

5353
template <class _Iter>
54-
using __iterator_category = ranges::__iterator_concept<_Iter>;
54+
using __iterator_category _LIBCPP_NODEBUG = ranges::__iterator_concept<_Iter>;
5555

5656
template <class _Iter>
57-
using __difference_type = iter_difference_t<_Iter>;
57+
using __difference_type _LIBCPP_NODEBUG = iter_difference_t<_Iter>;
5858

5959
static constexpr auto advance = ranges::advance;
6060
static constexpr auto distance = ranges::distance;
@@ -72,13 +72,13 @@ struct _ClassicAlgPolicy {};
7272
template <>
7373
struct _IterOps<_ClassicAlgPolicy> {
7474
template <class _Iter>
75-
using __value_type = typename iterator_traits<_Iter>::value_type;
75+
using __value_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::value_type;
7676

7777
template <class _Iter>
78-
using __iterator_category = typename iterator_traits<_Iter>::iterator_category;
78+
using __iterator_category _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::iterator_category;
7979

8080
template <class _Iter>
81-
using __difference_type = typename iterator_traits<_Iter>::difference_type;
81+
using __difference_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::difference_type;
8282

8383
// advance
8484
template <class _Iter, class _Distance>
@@ -94,10 +94,10 @@ struct _IterOps<_ClassicAlgPolicy> {
9494
}
9595

9696
template <class _Iter>
97-
using __deref_t = decltype(*std::declval<_Iter&>());
97+
using __deref_t _LIBCPP_NODEBUG = decltype(*std::declval<_Iter&>());
9898

9999
template <class _Iter>
100-
using __move_t = decltype(std::move(*std::declval<_Iter&>()));
100+
using __move_t _LIBCPP_NODEBUG = decltype(std::move(*std::declval<_Iter&>()));
101101

102102
template <class _Iter>
103103
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static void __validate_iter_reference() {
@@ -217,7 +217,7 @@ struct _IterOps<_ClassicAlgPolicy> {
217217
};
218218

219219
template <class _AlgPolicy, class _Iter>
220-
using __policy_iter_diff_t = typename _IterOps<_AlgPolicy>::template __difference_type<_Iter>;
220+
using __policy_iter_diff_t _LIBCPP_NODEBUG = typename _IterOps<_AlgPolicy>::template __difference_type<_Iter>;
221221

222222
_LIBCPP_END_NAMESPACE_STD
223223

libcxx/include/__algorithm/move.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct __move_impl {
5050

5151
template <class _InIter, class _OutIter>
5252
struct _MoveSegment {
53-
using _Traits = __segmented_iterator_traits<_InIter>;
53+
using _Traits _LIBCPP_NODEBUG = __segmented_iterator_traits<_InIter>;
5454

5555
_OutIter& __result_;
5656

libcxx/include/__algorithm/ranges_iterator_concept.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ consteval auto __get_iterator_concept() {
4444
}
4545

4646
template <class _Iter>
47-
using __iterator_concept = decltype(__get_iterator_concept<_Iter>());
47+
using __iterator_concept _LIBCPP_NODEBUG = decltype(__get_iterator_concept<_Iter>());
4848

4949
} // namespace ranges
5050
_LIBCPP_END_NAMESPACE_STD

libcxx/include/__algorithm/ranges_unique_copy.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct __unique_copy {
6060
}
6161

6262
template <class _InIter, class _OutIter>
63-
using __algo_tag_t = decltype(__get_algo_tag<_InIter, _OutIter>());
63+
using __algo_tag_t _LIBCPP_NODEBUG = decltype(__get_algo_tag<_InIter, _OutIter>());
6464

6565
template <input_iterator _InIter,
6666
sentinel_for<_InIter> _Sent,

libcxx/include/__algorithm/simd_utils.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct __get_as_integer_type_impl<8> {
7070
};
7171

7272
template <class _Tp>
73-
using __get_as_integer_type_t = typename __get_as_integer_type_impl<sizeof(_Tp)>::type;
73+
using __get_as_integer_type_t _LIBCPP_NODEBUG = typename __get_as_integer_type_impl<sizeof(_Tp)>::type;
7474

7575
// This isn't specialized for 64 byte vectors on purpose. They have the potential to significantly reduce performance
7676
// in mixed simd/non-simd workloads and don't provide any performance improvement for currently vectorized algorithms
@@ -90,7 +90,7 @@ inline constexpr size_t __native_vector_size = 1;
9090
# endif
9191

9292
template <class _ArithmeticT, size_t _Np>
93-
using __simd_vector __attribute__((__ext_vector_type__(_Np))) = _ArithmeticT;
93+
using __simd_vector __attribute__((__ext_vector_type__(_Np))) _LIBCPP_NODEBUG = _ArithmeticT;
9494

9595
template <class _VecT>
9696
inline constexpr size_t __simd_vector_size_v = []<bool _False = false>() -> size_t {
@@ -106,7 +106,7 @@ _LIBCPP_HIDE_FROM_ABI _Tp __simd_vector_underlying_type_impl(__simd_vector<_Tp,
106106
}
107107

108108
template <class _VecT>
109-
using __simd_vector_underlying_type_t = decltype(std::__simd_vector_underlying_type_impl(_VecT{}));
109+
using __simd_vector_underlying_type_t _LIBCPP_NODEBUG = decltype(std::__simd_vector_underlying_type_impl(_VecT{}));
110110

111111
// This isn't inlined without always_inline when loading chars.
112112
template <class _VecT, class _Iter>

libcxx/include/__algorithm/sort.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -890,10 +890,10 @@ __sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
890890
}
891891

892892
template <class _Type, class... _Options>
893-
using __is_any_of = _Or<is_same<_Type, _Options>...>;
893+
using __is_any_of _LIBCPP_NODEBUG = _Or<is_same<_Type, _Options>...>;
894894

895895
template <class _Type>
896-
using __sort_is_specialized_in_library = __is_any_of<
896+
using __sort_is_specialized_in_library _LIBCPP_NODEBUG = __is_any_of<
897897
_Type,
898898
char,
899899
#if _LIBCPP_HAS_WIDE_CHARACTERS

libcxx/include/__algorithm/three_way_comp_ref_type.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ struct __debug_three_way_comp {
6161
// Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference.
6262
# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
6363
template <class _Comp>
64-
using __three_way_comp_ref_type = __debug_three_way_comp<_Comp>;
64+
using __three_way_comp_ref_type _LIBCPP_NODEBUG = __debug_three_way_comp<_Comp>;
6565
# else
6666
template <class _Comp>
67-
using __three_way_comp_ref_type = _Comp&;
67+
using __three_way_comp_ref_type _LIBCPP_NODEBUG = _Comp&;
6868
# endif
6969

7070
#endif // _LIBCPP_STD_VER >= 20

libcxx/include/__algorithm/unwrap_iter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct __unwrap_iter_impl {
4646
// It's a contiguous iterator, so we can use a raw pointer instead
4747
template <class _Iter>
4848
struct __unwrap_iter_impl<_Iter, true> {
49-
using _ToAddressT = decltype(std::__to_address(std::declval<_Iter>()));
49+
using _ToAddressT _LIBCPP_NODEBUG = decltype(std::__to_address(std::declval<_Iter>()));
5050

5151
static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap(_Iter __orig_iter, _ToAddressT __unwrapped_iter) {
5252
return __orig_iter + (__unwrapped_iter - std::__to_address(__orig_iter));

libcxx/include/__atomic/aliases.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,19 @@ using atomic_uintmax_t = atomic<uintmax_t>;
8484
// C++20 atomic_{signed,unsigned}_lock_free: prefer the contention type most highly, then the largest lock-free type
8585
#if _LIBCPP_STD_VER >= 20
8686
# if ATOMIC_LLONG_LOCK_FREE == 2
87-
using __largest_lock_free_type = long long;
87+
using __largest_lock_free_type _LIBCPP_NODEBUG = long long;
8888
# elif ATOMIC_INT_LOCK_FREE == 2
89-
using __largest_lock_free_type = int;
89+
using __largest_lock_free_type _LIBCPP_NODEBUG = int;
9090
# elif ATOMIC_SHORT_LOCK_FREE == 2
91-
using __largest_lock_free_type = short;
91+
using __largest_lock_free_type _LIBCPP_NODEBUG = short;
9292
# elif ATOMIC_CHAR_LOCK_FREE == 2
93-
using __largest_lock_free_type = char;
93+
using __largest_lock_free_type _LIBCPP_NODEBUG = char;
9494
# else
9595
# define _LIBCPP_NO_LOCK_FREE_TYPES // There are no lockfree types (this can happen on unusual platforms)
9696
# endif
9797

9898
# ifndef _LIBCPP_NO_LOCK_FREE_TYPES
99-
using __contention_t_or_largest =
99+
using __contention_t_or_largest _LIBCPP_NODEBUG =
100100
__conditional_t<__libcpp_is_always_lock_free<__cxx_contention_t>::__value,
101101
__cxx_contention_t,
102102
__largest_lock_free_type>;

libcxx/include/__atomic/atomic.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ struct __atomic_base // false
143143

144144
template <class _Tp>
145145
struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> {
146-
using __base = __atomic_base<_Tp, false>;
146+
using __base _LIBCPP_NODEBUG = __atomic_base<_Tp, false>;
147147

148148
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __atomic_base() _NOEXCEPT = default;
149149

@@ -228,9 +228,9 @@ struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > {
228228

229229
template <class _Tp>
230230
struct atomic : public __atomic_base<_Tp> {
231-
using __base = __atomic_base<_Tp>;
232-
using value_type = _Tp;
233-
using difference_type = value_type;
231+
using __base _LIBCPP_NODEBUG = __atomic_base<_Tp>;
232+
using value_type = _Tp;
233+
using difference_type = value_type;
234234

235235
#if _LIBCPP_STD_VER >= 20
236236
_LIBCPP_HIDE_FROM_ABI atomic() = default;
@@ -257,9 +257,9 @@ struct atomic : public __atomic_base<_Tp> {
257257

258258
template <class _Tp>
259259
struct atomic<_Tp*> : public __atomic_base<_Tp*> {
260-
using __base = __atomic_base<_Tp*>;
261-
using value_type = _Tp*;
262-
using difference_type = ptrdiff_t;
260+
using __base _LIBCPP_NODEBUG = __atomic_base<_Tp*>;
261+
using value_type = _Tp*;
262+
using difference_type = ptrdiff_t;
263263

264264
_LIBCPP_HIDE_FROM_ABI atomic() _NOEXCEPT = default;
265265

@@ -389,9 +389,9 @@ struct atomic<_Tp> : __atomic_base<_Tp> {
389389
}
390390

391391
public:
392-
using __base = __atomic_base<_Tp>;
393-
using value_type = _Tp;
394-
using difference_type = value_type;
392+
using __base _LIBCPP_NODEBUG = __atomic_base<_Tp>;
393+
using value_type = _Tp;
394+
using difference_type = value_type;
395395

396396
_LIBCPP_HIDE_FROM_ABI constexpr atomic() noexcept = default;
397397
_LIBCPP_HIDE_FROM_ABI constexpr atomic(_Tp __d) noexcept : __base(__d) {}

libcxx/include/__atomic/atomic_ref.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ struct __atomic_ref_base {
221221
_LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { std::__atomic_notify_all(*this); }
222222

223223
protected:
224-
using _Aligned_Tp [[__gnu__::__aligned__(required_alignment)]] = _Tp;
224+
using _Aligned_Tp [[__gnu__::__aligned__(required_alignment), __gnu__::__nodebug__]] = _Tp;
225225
_Aligned_Tp* __ptr_;
226226

227227
_LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : __ptr_(std::addressof(__obj)) {}
@@ -241,7 +241,7 @@ template <class _Tp>
241241
struct atomic_ref : public __atomic_ref_base<_Tp> {
242242
static_assert(is_trivially_copyable_v<_Tp>, "std::atomic_ref<T> requires that 'T' be a trivially copyable type");
243243

244-
using __base = __atomic_ref_base<_Tp>;
244+
using __base _LIBCPP_NODEBUG = __atomic_ref_base<_Tp>;
245245

246246
_LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) {
247247
_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
@@ -259,7 +259,7 @@ struct atomic_ref : public __atomic_ref_base<_Tp> {
259259
template <class _Tp>
260260
requires(std::integral<_Tp> && !std::same_as<bool, _Tp>)
261261
struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {
262-
using __base = __atomic_ref_base<_Tp>;
262+
using __base _LIBCPP_NODEBUG = __atomic_ref_base<_Tp>;
263263

264264
using difference_type = __base::value_type;
265265

@@ -305,7 +305,7 @@ struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {
305305
template <class _Tp>
306306
requires std::floating_point<_Tp>
307307
struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {
308-
using __base = __atomic_ref_base<_Tp>;
308+
using __base _LIBCPP_NODEBUG = __atomic_ref_base<_Tp>;
309309

310310
using difference_type = __base::value_type;
311311

@@ -344,7 +344,7 @@ struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {
344344

345345
template <class _Tp>
346346
struct atomic_ref<_Tp*> : public __atomic_ref_base<_Tp*> {
347-
using __base = __atomic_ref_base<_Tp*>;
347+
using __base _LIBCPP_NODEBUG = __atomic_ref_base<_Tp*>;
348348

349349
using difference_type = ptrdiff_t;
350350

libcxx/include/__atomic/atomic_sync.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct __atomic_wait_backoff_impl {
8181
_Poll __poll_;
8282
memory_order __order_;
8383

84-
using __waitable_traits = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >;
84+
using __waitable_traits _LIBCPP_NODEBUG = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >;
8585

8686
_LIBCPP_AVAILABILITY_SYNC
8787
_LIBCPP_HIDE_FROM_ABI bool

libcxx/include/__atomic/contention_t.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
_LIBCPP_BEGIN_NAMESPACE_STD
2121

2222
#if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__))
23-
using __cxx_contention_t = int32_t;
23+
using __cxx_contention_t _LIBCPP_NODEBUG = int32_t;
2424
#else
25-
using __cxx_contention_t = int64_t;
25+
using __cxx_contention_t _LIBCPP_NODEBUG = int64_t;
2626
#endif // __linux__ || (_AIX && !__64BIT__)
2727

28-
using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;
28+
using __cxx_atomic_contention_t _LIBCPP_NODEBUG = __cxx_atomic_impl<__cxx_contention_t>;
2929

3030
_LIBCPP_END_NAMESPACE_STD
3131

libcxx/include/__atomic/memory_order.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424
// to pin the underlying type in C++20.
2525
enum __legacy_memory_order { __mo_relaxed, __mo_consume, __mo_acquire, __mo_release, __mo_acq_rel, __mo_seq_cst };
2626

27-
using __memory_order_underlying_t = underlying_type<__legacy_memory_order>::type;
27+
using __memory_order_underlying_t _LIBCPP_NODEBUG = underlying_type<__legacy_memory_order>::type;
2828

2929
#if _LIBCPP_STD_VER >= 20
3030

libcxx/include/__bit_reference

+12-12
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ struct __has_storage_type {
4343

4444
template <class _Cp, bool = __has_storage_type<_Cp>::value>
4545
class __bit_reference {
46-
using __storage_type = typename _Cp::__storage_type;
47-
using __storage_pointer = typename _Cp::__storage_pointer;
46+
using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type;
47+
using __storage_pointer _LIBCPP_NODEBUG = typename _Cp::__storage_pointer;
4848

4949
__storage_pointer __seg_;
5050
__storage_type __mask_;
@@ -55,7 +55,7 @@ class __bit_reference {
5555
friend class __bit_iterator<_Cp, false>;
5656

5757
public:
58-
using __container = typename _Cp::__self;
58+
using __container _LIBCPP_NODEBUG = typename _Cp::__self;
5959

6060
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_reference(const __bit_reference&) = default;
6161

@@ -135,8 +135,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(bool& __x,
135135

136136
template <class _Cp>
137137
class __bit_const_reference {
138-
using __storage_type = typename _Cp::__storage_type;
139-
using __storage_pointer = typename _Cp::__const_storage_pointer;
138+
using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type;
139+
using __storage_pointer _LIBCPP_NODEBUG = typename _Cp::__const_storage_pointer;
140140

141141
__storage_pointer __seg_;
142142
__storage_type __mask_;
@@ -145,7 +145,7 @@ class __bit_const_reference {
145145
friend class __bit_iterator<_Cp, true>;
146146

147147
public:
148-
using __container = typename _Cp::__self;
148+
using __container _LIBCPP_NODEBUG = typename _Cp::__self;
149149

150150
_LIBCPP_HIDE_FROM_ABI __bit_const_reference(const __bit_const_reference&) = default;
151151
__bit_const_reference& operator=(const __bit_const_reference&) = delete;
@@ -587,10 +587,10 @@ inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> swap_ranges(
587587

588588
template <class _Cp>
589589
struct __bit_array {
590-
using difference_type = typename _Cp::difference_type;
591-
using __storage_type = typename _Cp::__storage_type;
592-
using __storage_pointer = typename _Cp::__storage_pointer;
593-
using iterator = typename _Cp::iterator;
590+
using difference_type _LIBCPP_NODEBUG = typename _Cp::difference_type;
591+
using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type;
592+
using __storage_pointer _LIBCPP_NODEBUG = typename _Cp::__storage_pointer;
593+
using iterator _LIBCPP_NODEBUG = typename _Cp::iterator;
594594

595595
static const unsigned __bits_per_word = _Cp::__bits_per_word;
596596
static const unsigned _Np = 4;
@@ -790,8 +790,8 @@ public:
790790
using iterator_category = random_access_iterator_tag;
791791

792792
private:
793-
using __storage_type = typename _Cp::__storage_type;
794-
using __storage_pointer =
793+
using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type;
794+
using __storage_pointer _LIBCPP_NODEBUG =
795795
__conditional_t<_IsConst, typename _Cp::__const_storage_pointer, typename _Cp::__storage_pointer>;
796796

797797
static const unsigned __bits_per_word = _Cp::__bits_per_word;

0 commit comments

Comments
 (0)