From 09b144cd4db08100a27278cfa4d04c1153621500 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Thu, 5 Dec 2024 09:16:37 -0800 Subject: [PATCH 1/9] [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. --- libcxx/include/__memory/allocator_traits.h | 93 ++++++++++++++-------- libcxx/include/__memory/unique_ptr.h | 2 +- libcxx/include/__type_traits/detected_or.h | 7 +- 3 files changed, 64 insertions(+), 38 deletions(-) diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h index 62b454c922752..f56982e865bd9 100644 --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -44,10 +44,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD // __pointer template -using __pointer_member = typename _Tp::pointer; +using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer; template -using __pointer = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >; +using __pointer _LIBCPP_NODEBUG = + __detected_or_t<_Tp *, __pointer_member, + __libcpp_remove_reference_t<_Alloc>>; // __const_pointer _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer); @@ -58,7 +60,8 @@ struct __const_pointer { template struct __const_pointer<_Tp, _Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG - using type = typename pointer_traits<_Ptr>::template rebind::other; + using type _LIBCPP_NODEBUG = + typename pointer_traits<_Ptr>::template rebind::other; #else using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; #endif @@ -96,10 +99,11 @@ struct __const_void_pointer<_Ptr, _Alloc, false> { // __size_type template -using __size_type_member = typename _Tp::size_type; +using __size_type_member _LIBCPP_NODEBUG = typename _Tp::size_type; template -using __size_type = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>; +using __size_type _LIBCPP_NODEBUG = + __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>; // __alloc_traits_difference_type _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type); @@ -114,33 +118,41 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true> { // __propagate_on_container_copy_assignment template -using __propagate_on_container_copy_assignment_member = typename _Tp::propagate_on_container_copy_assignment; +using __propagate_on_container_copy_assignment_member _LIBCPP_NODEBUG = + typename _Tp::propagate_on_container_copy_assignment; template -using __propagate_on_container_copy_assignment = - __detected_or_t; +using __propagate_on_container_copy_assignment _LIBCPP_NODEBUG = + __detected_or_t; // __propagate_on_container_move_assignment template -using __propagate_on_container_move_assignment_member = typename _Tp::propagate_on_container_move_assignment; +using __propagate_on_container_move_assignment_member _LIBCPP_NODEBUG = + typename _Tp::propagate_on_container_move_assignment; template -using __propagate_on_container_move_assignment = - __detected_or_t; +using __propagate_on_container_move_assignment _LIBCPP_NODEBUG = + __detected_or_t; // __propagate_on_container_swap template -using __propagate_on_container_swap_member = typename _Tp::propagate_on_container_swap; +using __propagate_on_container_swap_member _LIBCPP_NODEBUG = + typename _Tp::propagate_on_container_swap; template -using __propagate_on_container_swap = __detected_or_t; +using __propagate_on_container_swap _LIBCPP_NODEBUG = + __detected_or_t; // __is_always_equal template -using __is_always_equal_member = typename _Tp::is_always_equal; +using __is_always_equal_member _LIBCPP_NODEBUG = typename _Tp::is_always_equal; template -using __is_always_equal = __detected_or_t::type, __is_always_equal_member, _Alloc>; +using __is_always_equal _LIBCPP_NODEBUG = + __detected_or_t::type, __is_always_equal_member, + _Alloc>; // __allocator_traits_rebind _LIBCPP_SUPPRESS_DEPRECATED_PUSH @@ -165,7 +177,8 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> { _LIBCPP_SUPPRESS_DEPRECATED_POP template -using __allocator_traits_rebind_t = typename __allocator_traits_rebind<_Alloc, _Tp>::type; +using __allocator_traits_rebind_t _LIBCPP_NODEBUG = + typename __allocator_traits_rebind<_Alloc, _Tp>::type; _LIBCPP_SUPPRESS_DEPRECATED_PUSH @@ -232,32 +245,43 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result); template struct _LIBCPP_TEMPLATE_VIS allocator_traits { - using allocator_type = _Alloc; - using value_type = typename allocator_type::value_type; - using pointer = __pointer; - using const_pointer = typename __const_pointer::type; - using void_pointer = typename __void_pointer::type; - using const_void_pointer = typename __const_void_pointer::type; - using difference_type = typename __alloc_traits_difference_type::type; - using size_type = __size_type; - using propagate_on_container_copy_assignment = __propagate_on_container_copy_assignment; - using propagate_on_container_move_assignment = __propagate_on_container_move_assignment; - using propagate_on_container_swap = __propagate_on_container_swap; - using is_always_equal = __is_always_equal; + using allocator_type _LIBCPP_NODEBUG = _Alloc; + using value_type _LIBCPP_NODEBUG = typename allocator_type::value_type; + using pointer _LIBCPP_NODEBUG = __pointer; + using const_pointer _LIBCPP_NODEBUG = + typename __const_pointer::type; + using void_pointer _LIBCPP_NODEBUG = + typename __void_pointer::type; + using const_void_pointer _LIBCPP_NODEBUG = + typename __const_void_pointer::type; + using difference_type _LIBCPP_NODEBUG = + typename __alloc_traits_difference_type::type; + using size_type _LIBCPP_NODEBUG = + __size_type; + using propagate_on_container_copy_assignment _LIBCPP_NODEBUG = + __propagate_on_container_copy_assignment; + using propagate_on_container_move_assignment _LIBCPP_NODEBUG = + __propagate_on_container_move_assignment; + using propagate_on_container_swap _LIBCPP_NODEBUG = + __propagate_on_container_swap; + using is_always_equal _LIBCPP_NODEBUG = __is_always_equal; #ifndef _LIBCPP_CXX03_LANG template - using rebind_alloc = __allocator_traits_rebind_t; + using rebind_alloc _LIBCPP_NODEBUG = + __allocator_traits_rebind_t; template - using rebind_traits = allocator_traits >; + using rebind_traits _LIBCPP_NODEBUG = allocator_traits>; #else // _LIBCPP_CXX03_LANG template struct rebind_alloc { - using other = __allocator_traits_rebind_t; + using other _LIBCPP_NODEBUG = + __allocator_traits_rebind_t; }; template struct rebind_traits { - using other = allocator_traits::other>; + using other _LIBCPP_NODEBUG = + allocator_traits::other>; }; #endif // _LIBCPP_CXX03_LANG @@ -355,12 +379,13 @@ template using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>; #else template -using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>::other; +using __rebind_alloc _LIBCPP_NODEBUG = + typename _Traits::template rebind_alloc<_Tp>::other; #endif template struct __check_valid_allocator : true_type { - using _Traits = std::allocator_traits<_Alloc>; + using _Traits _LIBCPP_NODEBUG = std::allocator_traits<_Alloc>; static_assert(is_same<_Alloc, __rebind_alloc<_Traits, typename _Traits::value_type> >::value, "[allocator.requirements] states that rebinding an allocator to the same type should result in the " "original allocator"); diff --git a/libcxx/include/__memory/unique_ptr.h b/libcxx/include/__memory/unique_ptr.h index 9526255583dd5..fd11ddcc7844b 100644 --- a/libcxx/include/__memory/unique_ptr.h +++ b/libcxx/include/__memory/unique_ptr.h @@ -410,7 +410,7 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> public: typedef _Tp element_type; typedef _Dp deleter_type; - using pointer = __pointer<_Tp, deleter_type>; + using pointer _LIBCPP_NODEBUG = __pointer<_Tp, deleter_type>; // A unique_ptr contains the following members which may be trivially relocatable: // - pointer: this may be trivially relocatable, so it's checked diff --git a/libcxx/include/__type_traits/detected_or.h b/libcxx/include/__type_traits/detected_or.h index 390f368411471..f939a85842d69 100644 --- a/libcxx/include/__type_traits/detected_or.h +++ b/libcxx/include/__type_traits/detected_or.h @@ -20,16 +20,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD template class _Op, class... _Args> struct __detector { - using type = _Default; + using type _LIBCPP_NODEBUG = _Default; }; template class _Op, class... _Args> struct __detector<_Default, __void_t<_Op<_Args...> >, _Op, _Args...> { - using type = _Op<_Args...>; + using type _LIBCPP_NODEBUG = _Op<_Args...>; }; template class _Op, class... _Args> -using __detected_or_t = typename __detector<_Default, void, _Op, _Args...>::type; +using __detected_or_t _LIBCPP_NODEBUG = + typename __detector<_Default, void, _Op, _Args...>::type; _LIBCPP_END_NAMESPACE_STD From 473760f6d770f99b0ded24ca028c2302f607f311 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Thu, 5 Dec 2024 09:34:32 -0800 Subject: [PATCH 2/9] Fix clang format issues. --- libcxx/include/__memory/allocator_traits.h | 81 ++++++++-------------- libcxx/include/__type_traits/detected_or.h | 3 +- 2 files changed, 28 insertions(+), 56 deletions(-) diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h index f56982e865bd9..c779701bbf1ad 100644 --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -47,9 +47,7 @@ template using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer; template -using __pointer _LIBCPP_NODEBUG = - __detected_or_t<_Tp *, __pointer_member, - __libcpp_remove_reference_t<_Alloc>>; +using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp *, __pointer_member, __libcpp_remove_reference_t<_Alloc>>; // __const_pointer _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer); @@ -60,8 +58,7 @@ struct __const_pointer { template struct __const_pointer<_Tp, _Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG - using type _LIBCPP_NODEBUG = - typename pointer_traits<_Ptr>::template rebind::other; + using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind::other; #else using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; #endif @@ -102,8 +99,7 @@ template using __size_type_member _LIBCPP_NODEBUG = typename _Tp::size_type; template -using __size_type _LIBCPP_NODEBUG = - __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>; +using __size_type _LIBCPP_NODEBUG = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>; // __alloc_traits_difference_type _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type); @@ -118,41 +114,31 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true> { // __propagate_on_container_copy_assignment template -using __propagate_on_container_copy_assignment_member _LIBCPP_NODEBUG = - typename _Tp::propagate_on_container_copy_assignment; +using __propagate_on_container_copy_assignment_member _LIBCPP_NODEBUG = typename _Tp::propagate_on_container_copy_assignment; template -using __propagate_on_container_copy_assignment _LIBCPP_NODEBUG = - __detected_or_t; +using __propagate_on_container_copy_assignment _LIBCPP_NODEBUG = __detected_or_t; // __propagate_on_container_move_assignment template -using __propagate_on_container_move_assignment_member _LIBCPP_NODEBUG = - typename _Tp::propagate_on_container_move_assignment; +using __propagate_on_container_move_assignment_member _LIBCPP_NODEBUG = typename _Tp::propagate_on_container_move_assignment; template -using __propagate_on_container_move_assignment _LIBCPP_NODEBUG = - __detected_or_t; +using __propagate_on_container_move_assignment _LIBCPP_NODEBUG = __detected_or_t; // __propagate_on_container_swap template -using __propagate_on_container_swap_member _LIBCPP_NODEBUG = - typename _Tp::propagate_on_container_swap; +using __propagate_on_container_swap_member _LIBCPP_NODEBUG = typename _Tp::propagate_on_container_swap; template -using __propagate_on_container_swap _LIBCPP_NODEBUG = - __detected_or_t; +using __propagate_on_container_swap _LIBCPP_NODEBUG = __detected_or_t; // __is_always_equal template using __is_always_equal_member _LIBCPP_NODEBUG = typename _Tp::is_always_equal; template -using __is_always_equal _LIBCPP_NODEBUG = - __detected_or_t::type, __is_always_equal_member, - _Alloc>; +using __is_always_equal _LIBCPP_NODEBUG = __detected_or_t::type, __is_always_equal_member, _Alloc>; // __allocator_traits_rebind _LIBCPP_SUPPRESS_DEPRECATED_PUSH @@ -177,8 +163,7 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> { _LIBCPP_SUPPRESS_DEPRECATED_POP template -using __allocator_traits_rebind_t _LIBCPP_NODEBUG = - typename __allocator_traits_rebind<_Alloc, _Tp>::type; +using __allocator_traits_rebind_t _LIBCPP_NODEBUG = typename __allocator_traits_rebind<_Alloc, _Tp>::type; _LIBCPP_SUPPRESS_DEPRECATED_PUSH @@ -245,43 +230,32 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result); template struct _LIBCPP_TEMPLATE_VIS allocator_traits { - using allocator_type _LIBCPP_NODEBUG = _Alloc; - using value_type _LIBCPP_NODEBUG = typename allocator_type::value_type; - using pointer _LIBCPP_NODEBUG = __pointer; - using const_pointer _LIBCPP_NODEBUG = - typename __const_pointer::type; - using void_pointer _LIBCPP_NODEBUG = - typename __void_pointer::type; - using const_void_pointer _LIBCPP_NODEBUG = - typename __const_void_pointer::type; - using difference_type _LIBCPP_NODEBUG = - typename __alloc_traits_difference_type::type; - using size_type _LIBCPP_NODEBUG = - __size_type; - using propagate_on_container_copy_assignment _LIBCPP_NODEBUG = - __propagate_on_container_copy_assignment; - using propagate_on_container_move_assignment _LIBCPP_NODEBUG = - __propagate_on_container_move_assignment; - using propagate_on_container_swap _LIBCPP_NODEBUG = - __propagate_on_container_swap; - using is_always_equal _LIBCPP_NODEBUG = __is_always_equal; + using allocator_type _LIBCPP_NODEBUG = _Alloc; + using value_type _LIBCPP_NODEBUG = typename allocator_type::value_type; + using pointer _LIBCPP_NODEBUG = __pointer; + using const_pointer _LIBCPP_NODEBUG = typename __const_pointer::type; + using void_pointer _LIBCPP_NODEBUG = typename __void_pointer::type; + using const_void_pointer _LIBCPP_NODEBUG = typename __const_void_pointer::type; + using difference_type _LIBCPP_NODEBUG = typename __alloc_traits_difference_type::type; + using size_type _LIBCPP_NODEBUG = __size_type; + using propagate_on_container_copy_assignment _LIBCPP_NODEBUG = __propagate_on_container_copy_assignment; + using propagate_on_container_move_assignment _LIBCPP_NODEBUG = __propagate_on_container_move_assignment; + using propagate_on_container_swap _LIBCPP_NODEBUG = __propagate_on_container_swap; + using is_always_equal _LIBCPP_NODEBUG = __is_always_equal; #ifndef _LIBCPP_CXX03_LANG template - using rebind_alloc _LIBCPP_NODEBUG = - __allocator_traits_rebind_t; + using rebind_alloc _LIBCPP_NODEBUG = __allocator_traits_rebind_t; template using rebind_traits _LIBCPP_NODEBUG = allocator_traits>; #else // _LIBCPP_CXX03_LANG template struct rebind_alloc { - using other _LIBCPP_NODEBUG = - __allocator_traits_rebind_t; + using other _LIBCPP_NODEBUG = __allocator_traits_rebind_t; }; template struct rebind_traits { - using other _LIBCPP_NODEBUG = - allocator_traits::other>; + using other _LIBCPP_NODEBUG = allocator_traits::other>; }; #endif // _LIBCPP_CXX03_LANG @@ -379,8 +353,7 @@ template using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>; #else template -using __rebind_alloc _LIBCPP_NODEBUG = - typename _Traits::template rebind_alloc<_Tp>::other; +using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>::other; #endif template diff --git a/libcxx/include/__type_traits/detected_or.h b/libcxx/include/__type_traits/detected_or.h index f939a85842d69..49c0c7111aebf 100644 --- a/libcxx/include/__type_traits/detected_or.h +++ b/libcxx/include/__type_traits/detected_or.h @@ -29,8 +29,7 @@ struct __detector<_Default, __void_t<_Op<_Args...> >, _Op, _Args...> { }; template class _Op, class... _Args> -using __detected_or_t _LIBCPP_NODEBUG = - typename __detector<_Default, void, _Op, _Args...>::type; +using __detected_or_t _LIBCPP_NODEBUG = typename __detector<_Default, void, _Op, _Args...>::type; _LIBCPP_END_NAMESPACE_STD From 6a9ab4df76782583b3de8d08f398656eef61832e Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Thu, 5 Dec 2024 09:49:42 -0800 Subject: [PATCH 3/9] Remove _LIBCPP_NODEBUG from aliases for Cxx03. --- libcxx/include/__memory/allocator_traits.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h index c779701bbf1ad..f3b282343556b 100644 --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -58,7 +58,7 @@ struct __const_pointer { template struct __const_pointer<_Tp, _Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG - using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind::other; + using type = typename pointer_traits<_Ptr>::template rebind::other; #else using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; #endif @@ -73,7 +73,7 @@ struct __void_pointer { template struct __void_pointer<_Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG - using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind::other; + using type = typename pointer_traits<_Ptr>::template rebind::other; #else using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; #endif @@ -88,7 +88,7 @@ struct __const_void_pointer { template struct __const_void_pointer<_Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG - using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind::other; + using type = typename pointer_traits<_Ptr>::template rebind::other; #else using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; #endif @@ -245,9 +245,9 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { #ifndef _LIBCPP_CXX03_LANG template - using rebind_alloc _LIBCPP_NODEBUG = __allocator_traits_rebind_t; + using rebind_alloc = __allocator_traits_rebind_t; template - using rebind_traits _LIBCPP_NODEBUG = allocator_traits>; + using rebind_traits = allocator_traits>; #else // _LIBCPP_CXX03_LANG template struct rebind_alloc { @@ -350,7 +350,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { #ifndef _LIBCPP_CXX03_LANG template -using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>; +using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>; #else template using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>::other; From 188cb11acd07f68ac1e297c4e49588f780f5f3ee Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Thu, 5 Dec 2024 10:18:40 -0800 Subject: [PATCH 4/9] Change ">>" to "> >" in templates in allocator_traits.h --- libcxx/include/__memory/allocator_traits.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h index f3b282343556b..0473e74a72b9b 100644 --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -47,7 +47,7 @@ template using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer; template -using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp *, __pointer_member, __libcpp_remove_reference_t<_Alloc>>; +using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp *, __pointer_member, __libcpp_remove_reference_t<_Alloc> >; // __const_pointer _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer); @@ -247,7 +247,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { template using rebind_alloc = __allocator_traits_rebind_t; template - using rebind_traits = allocator_traits>; + using rebind_traits = allocator_traits >; #else // _LIBCPP_CXX03_LANG template struct rebind_alloc { From 7989aad1bfb0d4622a426a3af776ab1384760659 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 5 Dec 2024 15:24:32 -0500 Subject: [PATCH 5/9] Fix formatting --- libcxx/include/__memory/allocator_traits.h | 46 +++++++++++++--------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h index 0473e74a72b9b..7db737fc95561 100644 --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -47,7 +47,7 @@ template using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer; template -using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp *, __pointer_member, __libcpp_remove_reference_t<_Alloc> >; +using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >; // __const_pointer _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer); @@ -114,31 +114,37 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true> { // __propagate_on_container_copy_assignment template -using __propagate_on_container_copy_assignment_member _LIBCPP_NODEBUG = typename _Tp::propagate_on_container_copy_assignment; +using __propagate_on_container_copy_assignment_member _LIBCPP_NODEBUG = + typename _Tp::propagate_on_container_copy_assignment; template -using __propagate_on_container_copy_assignment _LIBCPP_NODEBUG = __detected_or_t; +using __propagate_on_container_copy_assignment _LIBCPP_NODEBUG = + __detected_or_t; // __propagate_on_container_move_assignment template -using __propagate_on_container_move_assignment_member _LIBCPP_NODEBUG = typename _Tp::propagate_on_container_move_assignment; +using __propagate_on_container_move_assignment_member _LIBCPP_NODEBUG = + typename _Tp::propagate_on_container_move_assignment; template -using __propagate_on_container_move_assignment _LIBCPP_NODEBUG = __detected_or_t; +using __propagate_on_container_move_assignment _LIBCPP_NODEBUG = + __detected_or_t; // __propagate_on_container_swap template using __propagate_on_container_swap_member _LIBCPP_NODEBUG = typename _Tp::propagate_on_container_swap; template -using __propagate_on_container_swap _LIBCPP_NODEBUG = __detected_or_t; +using __propagate_on_container_swap _LIBCPP_NODEBUG = + __detected_or_t; // __is_always_equal template using __is_always_equal_member _LIBCPP_NODEBUG = typename _Tp::is_always_equal; template -using __is_always_equal _LIBCPP_NODEBUG = __detected_or_t::type, __is_always_equal_member, _Alloc>; +using __is_always_equal _LIBCPP_NODEBUG = + __detected_or_t::type, __is_always_equal_member, _Alloc>; // __allocator_traits_rebind _LIBCPP_SUPPRESS_DEPRECATED_PUSH @@ -230,18 +236,20 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result); template struct _LIBCPP_TEMPLATE_VIS allocator_traits { - using allocator_type _LIBCPP_NODEBUG = _Alloc; - using value_type _LIBCPP_NODEBUG = typename allocator_type::value_type; - using pointer _LIBCPP_NODEBUG = __pointer; - using const_pointer _LIBCPP_NODEBUG = typename __const_pointer::type; - using void_pointer _LIBCPP_NODEBUG = typename __void_pointer::type; - using const_void_pointer _LIBCPP_NODEBUG = typename __const_void_pointer::type; - using difference_type _LIBCPP_NODEBUG = typename __alloc_traits_difference_type::type; - using size_type _LIBCPP_NODEBUG = __size_type; - using propagate_on_container_copy_assignment _LIBCPP_NODEBUG = __propagate_on_container_copy_assignment; - using propagate_on_container_move_assignment _LIBCPP_NODEBUG = __propagate_on_container_move_assignment; - using propagate_on_container_swap _LIBCPP_NODEBUG = __propagate_on_container_swap; - using is_always_equal _LIBCPP_NODEBUG = __is_always_equal; + using allocator_type _LIBCPP_NODEBUG = _Alloc; + using value_type _LIBCPP_NODEBUG = typename allocator_type::value_type; + using pointer _LIBCPP_NODEBUG = __pointer; + using const_pointer _LIBCPP_NODEBUG = typename __const_pointer::type; + using void_pointer _LIBCPP_NODEBUG = typename __void_pointer::type; + using const_void_pointer _LIBCPP_NODEBUG = typename __const_void_pointer::type; + using difference_type _LIBCPP_NODEBUG = typename __alloc_traits_difference_type::type; + using size_type _LIBCPP_NODEBUG = __size_type; + using propagate_on_container_copy_assignment _LIBCPP_NODEBUG = + __propagate_on_container_copy_assignment; + using propagate_on_container_move_assignment _LIBCPP_NODEBUG = + __propagate_on_container_move_assignment; + using propagate_on_container_swap _LIBCPP_NODEBUG = __propagate_on_container_swap; + using is_always_equal _LIBCPP_NODEBUG = __is_always_equal; #ifndef _LIBCPP_CXX03_LANG template From 291808e8cb27f4ebb04aa8fe1759152edc6457eb Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Thu, 5 Dec 2024 12:37:42 -0800 Subject: [PATCH 6/9] Restore _LIBCPP_NODEBUG to the CXX03 aliases. --- libcxx/include/__memory/allocator_traits.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h index 7db737fc95561..a9f9fc9ac1305 100644 --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -58,7 +58,7 @@ struct __const_pointer { template struct __const_pointer<_Tp, _Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG - using type = typename pointer_traits<_Ptr>::template rebind::other; + using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind::other; #else using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; #endif @@ -88,7 +88,7 @@ struct __const_void_pointer { template struct __const_void_pointer<_Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG - using type = typename pointer_traits<_Ptr>::template rebind::other; + using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind::other; #else using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; #endif @@ -253,9 +253,9 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { #ifndef _LIBCPP_CXX03_LANG template - using rebind_alloc = __allocator_traits_rebind_t; + using rebind_alloc _LIBCPP_NODEBUG = __allocator_traits_rebind_t; template - using rebind_traits = allocator_traits >; + using rebind_traits _LIBCPP_NODEBUG = allocator_traits >; #else // _LIBCPP_CXX03_LANG template struct rebind_alloc { @@ -358,7 +358,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { #ifndef _LIBCPP_CXX03_LANG template -using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>; +using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>; #else template using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>::other; From 05b2257d3c64e55ccd3aa45a2882decf30688e7b Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Thu, 5 Dec 2024 12:53:41 -0800 Subject: [PATCH 7/9] Fix one more CXX03 alias that I missed. --- libcxx/include/__memory/allocator_traits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h index a9f9fc9ac1305..1f7f986e1a3f5 100644 --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -73,7 +73,7 @@ struct __void_pointer { template struct __void_pointer<_Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG - using type = typename pointer_traits<_Ptr>::template rebind::other; + using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind::other; #else using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; #endif From 43482348b94ce29bd436bb7466eab3195e26f343 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Thu, 5 Dec 2024 13:06:37 -0800 Subject: [PATCH 8/9] Remove _LIBCPP_NODEBUG from the public API aliases. --- libcxx/include/__memory/allocator_traits.h | 32 +++++++++++----------- libcxx/include/__memory/unique_ptr.h | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h index 1f7f986e1a3f5..f0bd91316135d 100644 --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -236,34 +236,34 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result); template struct _LIBCPP_TEMPLATE_VIS allocator_traits { - using allocator_type _LIBCPP_NODEBUG = _Alloc; - using value_type _LIBCPP_NODEBUG = typename allocator_type::value_type; - using pointer _LIBCPP_NODEBUG = __pointer; - using const_pointer _LIBCPP_NODEBUG = typename __const_pointer::type; - using void_pointer _LIBCPP_NODEBUG = typename __void_pointer::type; - using const_void_pointer _LIBCPP_NODEBUG = typename __const_void_pointer::type; - using difference_type _LIBCPP_NODEBUG = typename __alloc_traits_difference_type::type; - using size_type _LIBCPP_NODEBUG = __size_type; - using propagate_on_container_copy_assignment _LIBCPP_NODEBUG = + using allocator_type = _Alloc; + using value_type = typename allocator_type::value_type; + using pointer = __pointer; + using const_pointer = typename __const_pointer::type; + using void_pointer = typename __void_pointer::type; + using const_void_pointer = typename __const_void_pointer::type; + using difference_type = typename __alloc_traits_difference_type::type; + using size_type = __size_type; + using propagate_on_container_copy_assignment = __propagate_on_container_copy_assignment; - using propagate_on_container_move_assignment _LIBCPP_NODEBUG = + using propagate_on_container_move_assignment = __propagate_on_container_move_assignment; - using propagate_on_container_swap _LIBCPP_NODEBUG = __propagate_on_container_swap; - using is_always_equal _LIBCPP_NODEBUG = __is_always_equal; + using propagate_on_container_swap = __propagate_on_container_swap; + using is_always_equal = __is_always_equal; #ifndef _LIBCPP_CXX03_LANG template - using rebind_alloc _LIBCPP_NODEBUG = __allocator_traits_rebind_t; + using rebind_alloc = __allocator_traits_rebind_t; template - using rebind_traits _LIBCPP_NODEBUG = allocator_traits >; + using rebind_traits = allocator_traits >; #else // _LIBCPP_CXX03_LANG template struct rebind_alloc { - using other _LIBCPP_NODEBUG = __allocator_traits_rebind_t; + using other = __allocator_traits_rebind_t; }; template struct rebind_traits { - using other _LIBCPP_NODEBUG = allocator_traits::other>; + using other = allocator_traits::other>; }; #endif // _LIBCPP_CXX03_LANG diff --git a/libcxx/include/__memory/unique_ptr.h b/libcxx/include/__memory/unique_ptr.h index fd11ddcc7844b..9526255583dd5 100644 --- a/libcxx/include/__memory/unique_ptr.h +++ b/libcxx/include/__memory/unique_ptr.h @@ -410,7 +410,7 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> public: typedef _Tp element_type; typedef _Dp deleter_type; - using pointer _LIBCPP_NODEBUG = __pointer<_Tp, deleter_type>; + using pointer = __pointer<_Tp, deleter_type>; // A unique_ptr contains the following members which may be trivially relocatable: // - pointer: this may be trivially relocatable, so it's checked From 725340a6aad0ec3b221967ca2edb56f8d480fc40 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 5 Dec 2024 16:10:44 -0500 Subject: [PATCH 9/9] Formatting --- libcxx/include/__memory/allocator_traits.h | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h index f0bd91316135d..2d9ab847e9f25 100644 --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -236,20 +236,18 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result); template struct _LIBCPP_TEMPLATE_VIS allocator_traits { - using allocator_type = _Alloc; - using value_type = typename allocator_type::value_type; - using pointer = __pointer; - using const_pointer = typename __const_pointer::type; - using void_pointer = typename __void_pointer::type; - using const_void_pointer = typename __const_void_pointer::type; - using difference_type = typename __alloc_traits_difference_type::type; - using size_type = __size_type; - using propagate_on_container_copy_assignment = - __propagate_on_container_copy_assignment; - using propagate_on_container_move_assignment = - __propagate_on_container_move_assignment; - using propagate_on_container_swap = __propagate_on_container_swap; - using is_always_equal = __is_always_equal; + using allocator_type = _Alloc; + using value_type = typename allocator_type::value_type; + using pointer = __pointer; + using const_pointer = typename __const_pointer::type; + using void_pointer = typename __void_pointer::type; + using const_void_pointer = typename __const_void_pointer::type; + using difference_type = typename __alloc_traits_difference_type::type; + using size_type = __size_type; + using propagate_on_container_copy_assignment = __propagate_on_container_copy_assignment; + using propagate_on_container_move_assignment = __propagate_on_container_move_assignment; + using propagate_on_container_swap = __propagate_on_container_swap; + using is_always_equal = __is_always_equal; #ifndef _LIBCPP_CXX03_LANG template