Skip to content

Commit 09b144c

Browse files
committed
[libc++] Put _LIBCPP_NODEBUG on allocator trait aliases.
Put _LIBCPP_NODEBUG on the new allocator trait aliases introduced in libcxx/include/__memory/allocator_traits.h. The prevents a large increase in the gdb_index size that was introduced by that PR.
1 parent 2fea1cc commit 09b144c

File tree

3 files changed

+64
-38
lines changed

3 files changed

+64
-38
lines changed

libcxx/include/__memory/allocator_traits.h

Lines changed: 59 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ _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 =
51+
__detected_or_t<_Tp *, __pointer_member,
52+
__libcpp_remove_reference_t<_Alloc>>;
5153

5254
// __const_pointer
5355
_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer);
@@ -58,7 +60,8 @@ struct __const_pointer {
5860
template <class _Tp, class _Ptr, class _Alloc>
5961
struct __const_pointer<_Tp, _Ptr, _Alloc, false> {
6062
#ifdef _LIBCPP_CXX03_LANG
61-
using type = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;
63+
using type _LIBCPP_NODEBUG =
64+
typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;
6265
#else
6366
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>;
6467
#endif
@@ -96,10 +99,11 @@ struct __const_void_pointer<_Ptr, _Alloc, false> {
9699

97100
// __size_type
98101
template <class _Tp>
99-
using __size_type_member = typename _Tp::size_type;
102+
using __size_type_member _LIBCPP_NODEBUG = typename _Tp::size_type;
100103

101104
template <class _Alloc, class _DiffType>
102-
using __size_type = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>;
105+
using __size_type _LIBCPP_NODEBUG =
106+
__detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>;
103107

104108
// __alloc_traits_difference_type
105109
_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type);
@@ -114,33 +118,41 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true> {
114118

115119
// __propagate_on_container_copy_assignment
116120
template <class _Tp>
117-
using __propagate_on_container_copy_assignment_member = typename _Tp::propagate_on_container_copy_assignment;
121+
using __propagate_on_container_copy_assignment_member _LIBCPP_NODEBUG =
122+
typename _Tp::propagate_on_container_copy_assignment;
118123

119124
template <class _Alloc>
120-
using __propagate_on_container_copy_assignment =
121-
__detected_or_t<false_type, __propagate_on_container_copy_assignment_member, _Alloc>;
125+
using __propagate_on_container_copy_assignment _LIBCPP_NODEBUG =
126+
__detected_or_t<false_type, __propagate_on_container_copy_assignment_member,
127+
_Alloc>;
122128

123129
// __propagate_on_container_move_assignment
124130
template <class _Tp>
125-
using __propagate_on_container_move_assignment_member = typename _Tp::propagate_on_container_move_assignment;
131+
using __propagate_on_container_move_assignment_member _LIBCPP_NODEBUG =
132+
typename _Tp::propagate_on_container_move_assignment;
126133

127134
template <class _Alloc>
128-
using __propagate_on_container_move_assignment =
129-
__detected_or_t<false_type, __propagate_on_container_move_assignment_member, _Alloc>;
135+
using __propagate_on_container_move_assignment _LIBCPP_NODEBUG =
136+
__detected_or_t<false_type, __propagate_on_container_move_assignment_member,
137+
_Alloc>;
130138

131139
// __propagate_on_container_swap
132140
template <class _Tp>
133-
using __propagate_on_container_swap_member = typename _Tp::propagate_on_container_swap;
141+
using __propagate_on_container_swap_member _LIBCPP_NODEBUG =
142+
typename _Tp::propagate_on_container_swap;
134143

135144
template <class _Alloc>
136-
using __propagate_on_container_swap = __detected_or_t<false_type, __propagate_on_container_swap_member, _Alloc>;
145+
using __propagate_on_container_swap _LIBCPP_NODEBUG =
146+
__detected_or_t<false_type, __propagate_on_container_swap_member, _Alloc>;
137147

138148
// __is_always_equal
139149
template <class _Tp>
140-
using __is_always_equal_member = typename _Tp::is_always_equal;
150+
using __is_always_equal_member _LIBCPP_NODEBUG = typename _Tp::is_always_equal;
141151

142152
template <class _Alloc>
143-
using __is_always_equal = __detected_or_t<typename is_empty<_Alloc>::type, __is_always_equal_member, _Alloc>;
153+
using __is_always_equal _LIBCPP_NODEBUG =
154+
__detected_or_t<typename is_empty<_Alloc>::type, __is_always_equal_member,
155+
_Alloc>;
144156

145157
// __allocator_traits_rebind
146158
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
@@ -165,7 +177,8 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> {
165177
_LIBCPP_SUPPRESS_DEPRECATED_POP
166178

167179
template <class _Alloc, class _Tp>
168-
using __allocator_traits_rebind_t = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
180+
using __allocator_traits_rebind_t _LIBCPP_NODEBUG =
181+
typename __allocator_traits_rebind<_Alloc, _Tp>::type;
169182

170183
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
171184

@@ -232,32 +245,43 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);
232245

233246
template <class _Alloc>
234247
struct _LIBCPP_TEMPLATE_VIS allocator_traits {
235-
using allocator_type = _Alloc;
236-
using value_type = typename allocator_type::value_type;
237-
using pointer = __pointer<value_type, allocator_type>;
238-
using const_pointer = typename __const_pointer<value_type, pointer, allocator_type>::type;
239-
using void_pointer = typename __void_pointer<pointer, allocator_type>::type;
240-
using const_void_pointer = typename __const_void_pointer<pointer, allocator_type>::type;
241-
using difference_type = typename __alloc_traits_difference_type<allocator_type, pointer>::type;
242-
using size_type = __size_type<allocator_type, difference_type>;
243-
using propagate_on_container_copy_assignment = __propagate_on_container_copy_assignment<allocator_type>;
244-
using propagate_on_container_move_assignment = __propagate_on_container_move_assignment<allocator_type>;
245-
using propagate_on_container_swap = __propagate_on_container_swap<allocator_type>;
246-
using is_always_equal = __is_always_equal<allocator_type>;
248+
using allocator_type _LIBCPP_NODEBUG = _Alloc;
249+
using value_type _LIBCPP_NODEBUG = typename allocator_type::value_type;
250+
using pointer _LIBCPP_NODEBUG = __pointer<value_type, allocator_type>;
251+
using const_pointer _LIBCPP_NODEBUG =
252+
typename __const_pointer<value_type, pointer, allocator_type>::type;
253+
using void_pointer _LIBCPP_NODEBUG =
254+
typename __void_pointer<pointer, allocator_type>::type;
255+
using const_void_pointer _LIBCPP_NODEBUG =
256+
typename __const_void_pointer<pointer, allocator_type>::type;
257+
using difference_type _LIBCPP_NODEBUG =
258+
typename __alloc_traits_difference_type<allocator_type, pointer>::type;
259+
using size_type _LIBCPP_NODEBUG =
260+
__size_type<allocator_type, difference_type>;
261+
using propagate_on_container_copy_assignment _LIBCPP_NODEBUG =
262+
__propagate_on_container_copy_assignment<allocator_type>;
263+
using propagate_on_container_move_assignment _LIBCPP_NODEBUG =
264+
__propagate_on_container_move_assignment<allocator_type>;
265+
using propagate_on_container_swap _LIBCPP_NODEBUG =
266+
__propagate_on_container_swap<allocator_type>;
267+
using is_always_equal _LIBCPP_NODEBUG = __is_always_equal<allocator_type>;
247268

248269
#ifndef _LIBCPP_CXX03_LANG
249270
template <class _Tp>
250-
using rebind_alloc = __allocator_traits_rebind_t<allocator_type, _Tp>;
271+
using rebind_alloc _LIBCPP_NODEBUG =
272+
__allocator_traits_rebind_t<allocator_type, _Tp>;
251273
template <class _Tp>
252-
using rebind_traits = allocator_traits<rebind_alloc<_Tp> >;
274+
using rebind_traits _LIBCPP_NODEBUG = allocator_traits<rebind_alloc<_Tp>>;
253275
#else // _LIBCPP_CXX03_LANG
254276
template <class _Tp>
255277
struct rebind_alloc {
256-
using other = __allocator_traits_rebind_t<allocator_type, _Tp>;
278+
using other _LIBCPP_NODEBUG =
279+
__allocator_traits_rebind_t<allocator_type, _Tp>;
257280
};
258281
template <class _Tp>
259282
struct rebind_traits {
260-
using other = allocator_traits<typename rebind_alloc<_Tp>::other>;
283+
using other _LIBCPP_NODEBUG =
284+
allocator_traits<typename rebind_alloc<_Tp>::other>;
261285
};
262286
#endif // _LIBCPP_CXX03_LANG
263287

@@ -355,12 +379,13 @@ template <class _Traits, class _Tp>
355379
using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>;
356380
#else
357381
template <class _Traits, class _Tp>
358-
using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>::other;
382+
using __rebind_alloc _LIBCPP_NODEBUG =
383+
typename _Traits::template rebind_alloc<_Tp>::other;
359384
#endif
360385

361386
template <class _Alloc>
362387
struct __check_valid_allocator : true_type {
363-
using _Traits = std::allocator_traits<_Alloc>;
388+
using _Traits _LIBCPP_NODEBUG = std::allocator_traits<_Alloc>;
364389
static_assert(is_same<_Alloc, __rebind_alloc<_Traits, typename _Traits::value_type> >::value,
365390
"[allocator.requirements] states that rebinding an allocator to the same type should result in the "
366391
"original allocator");

libcxx/include/__memory/unique_ptr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp>
410410
public:
411411
typedef _Tp element_type;
412412
typedef _Dp deleter_type;
413-
using pointer = __pointer<_Tp, deleter_type>;
413+
using pointer _LIBCPP_NODEBUG = __pointer<_Tp, deleter_type>;
414414

415415
// A unique_ptr contains the following members which may be trivially relocatable:
416416
// - pointer: this may be trivially relocatable, so it's checked

libcxx/include/__type_traits/detected_or.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ _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 =
33+
typename __detector<_Default, void, _Op, _Args...>::type;
3334

3435
_LIBCPP_END_NAMESPACE_STD
3536

0 commit comments

Comments
 (0)