Skip to content

Commit 384e69a

Browse files
authored
[libc++] Add _LIBCPP_NODEBUG on internal allocator trait aliases (llvm#118835)
Put _LIBCPP_NODEBUG on the new allocator trait aliases introduced in llvm#115654. This prevents a large increase in the gdb_index size that was introduced by that PR.
1 parent ae73bc8 commit 384e69a

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

libcxx/include/__memory/allocator_traits.h

+20-16
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4444

4545
// __pointer
4646
template <class _Tp>
47-
using __pointer_member = typename _Tp::pointer;
47+
using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer;
4848

4949
template <class _Tp, class _Alloc>
50-
using __pointer = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >;
50+
using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >;
5151

5252
// __const_pointer
5353
_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer);
@@ -58,7 +58,7 @@ struct __const_pointer {
5858
template <class _Tp, class _Ptr, class _Alloc>
5959
struct __const_pointer<_Tp, _Ptr, _Alloc, false> {
6060
#ifdef _LIBCPP_CXX03_LANG
61-
using type = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;
61+
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;
6262
#else
6363
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>;
6464
#endif
@@ -96,10 +96,10 @@ struct __const_void_pointer<_Ptr, _Alloc, false> {
9696

9797
// __size_type
9898
template <class _Tp>
99-
using __size_type_member = typename _Tp::size_type;
99+
using __size_type_member _LIBCPP_NODEBUG = typename _Tp::size_type;
100100

101101
template <class _Alloc, class _DiffType>
102-
using __size_type = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>;
102+
using __size_type _LIBCPP_NODEBUG = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>;
103103

104104
// __alloc_traits_difference_type
105105
_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type);
@@ -114,33 +114,37 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true> {
114114

115115
// __propagate_on_container_copy_assignment
116116
template <class _Tp>
117-
using __propagate_on_container_copy_assignment_member = typename _Tp::propagate_on_container_copy_assignment;
117+
using __propagate_on_container_copy_assignment_member _LIBCPP_NODEBUG =
118+
typename _Tp::propagate_on_container_copy_assignment;
118119

119120
template <class _Alloc>
120-
using __propagate_on_container_copy_assignment =
121+
using __propagate_on_container_copy_assignment _LIBCPP_NODEBUG =
121122
__detected_or_t<false_type, __propagate_on_container_copy_assignment_member, _Alloc>;
122123

123124
// __propagate_on_container_move_assignment
124125
template <class _Tp>
125-
using __propagate_on_container_move_assignment_member = typename _Tp::propagate_on_container_move_assignment;
126+
using __propagate_on_container_move_assignment_member _LIBCPP_NODEBUG =
127+
typename _Tp::propagate_on_container_move_assignment;
126128

127129
template <class _Alloc>
128-
using __propagate_on_container_move_assignment =
130+
using __propagate_on_container_move_assignment _LIBCPP_NODEBUG =
129131
__detected_or_t<false_type, __propagate_on_container_move_assignment_member, _Alloc>;
130132

131133
// __propagate_on_container_swap
132134
template <class _Tp>
133-
using __propagate_on_container_swap_member = typename _Tp::propagate_on_container_swap;
135+
using __propagate_on_container_swap_member _LIBCPP_NODEBUG = typename _Tp::propagate_on_container_swap;
134136

135137
template <class _Alloc>
136-
using __propagate_on_container_swap = __detected_or_t<false_type, __propagate_on_container_swap_member, _Alloc>;
138+
using __propagate_on_container_swap _LIBCPP_NODEBUG =
139+
__detected_or_t<false_type, __propagate_on_container_swap_member, _Alloc>;
137140

138141
// __is_always_equal
139142
template <class _Tp>
140-
using __is_always_equal_member = typename _Tp::is_always_equal;
143+
using __is_always_equal_member _LIBCPP_NODEBUG = typename _Tp::is_always_equal;
141144

142145
template <class _Alloc>
143-
using __is_always_equal = __detected_or_t<typename is_empty<_Alloc>::type, __is_always_equal_member, _Alloc>;
146+
using __is_always_equal _LIBCPP_NODEBUG =
147+
__detected_or_t<typename is_empty<_Alloc>::type, __is_always_equal_member, _Alloc>;
144148

145149
// __allocator_traits_rebind
146150
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
@@ -165,7 +169,7 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> {
165169
_LIBCPP_SUPPRESS_DEPRECATED_POP
166170

167171
template <class _Alloc, class _Tp>
168-
using __allocator_traits_rebind_t = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
172+
using __allocator_traits_rebind_t _LIBCPP_NODEBUG = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
169173

170174
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
171175

@@ -355,12 +359,12 @@ template <class _Traits, class _Tp>
355359
using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>;
356360
#else
357361
template <class _Traits, class _Tp>
358-
using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>::other;
362+
using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>::other;
359363
#endif
360364

361365
template <class _Alloc>
362366
struct __check_valid_allocator : true_type {
363-
using _Traits = std::allocator_traits<_Alloc>;
367+
using _Traits _LIBCPP_NODEBUG = std::allocator_traits<_Alloc>;
364368
static_assert(is_same<_Alloc, __rebind_alloc<_Traits, typename _Traits::value_type> >::value,
365369
"[allocator.requirements] states that rebinding an allocator to the same type should result in the "
366370
"original allocator");

libcxx/include/__type_traits/detected_or.h

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

2121
template <class _Default, class _Void, template <class...> class _Op, class... _Args>
2222
struct __detector {
23-
using type = _Default;
23+
using type _LIBCPP_NODEBUG = _Default;
2424
};
2525

2626
template <class _Default, template <class...> class _Op, class... _Args>
2727
struct __detector<_Default, __void_t<_Op<_Args...> >, _Op, _Args...> {
28-
using type = _Op<_Args...>;
28+
using type _LIBCPP_NODEBUG = _Op<_Args...>;
2929
};
3030

3131
template <class _Default, template <class...> class _Op, class... _Args>
32-
using __detected_or_t = typename __detector<_Default, void, _Op, _Args...>::type;
32+
using __detected_or_t _LIBCPP_NODEBUG = typename __detector<_Default, void, _Op, _Args...>::type;
3333

3434
_LIBCPP_END_NAMESPACE_STD
3535

0 commit comments

Comments
 (0)