From 3557c7c1226fa222499a2b9d4cbc36dfeda6f53c Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Tue, 31 Aug 2021 10:32:11 -0400 Subject: [PATCH] [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 --- libcxx/CMakeLists.txt | 1 - libcxx/include/__config | 6 -- libcxx/include/__functional/function.h | 6 +- libcxx/include/__functional/hash.h | 10 +- libcxx/include/__functional/unwrap_ref.h | 4 +- .../include/__functional/weak_result_type.h | 8 +- libcxx/include/__memory/allocator_arg_t.h | 2 +- libcxx/include/__memory/allocator_traits.h | 42 ++++---- libcxx/include/__memory/compressed_pair.h | 4 +- libcxx/include/__memory/pointer_traits.h | 18 ++-- libcxx/include/__memory/shared_ptr.h | 6 +- libcxx/include/__memory/unique_ptr.h | 36 +++---- libcxx/include/__tuple | 42 ++++---- libcxx/include/__utility/integer_sequence.h | 8 +- libcxx/include/__utility/move.h | 2 +- libcxx/include/__utility/pair.h | 8 +- libcxx/include/tuple | 22 ++-- libcxx/include/type_traits | 102 +++++++++--------- libcxx/include/variant | 8 +- 19 files changed, 164 insertions(+), 171 deletions(-) diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 0f4c886604c5..c85caa52318f 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -599,7 +599,6 @@ function(cxx_add_warning_flags target) -Wno-user-defined-literals -Wno-covered-switch-default -Wno-suggest-override - -Wno-ignored-attributes # FIXME: Caused by _LIBCPP_NODEBUG_TYPE not being supported on older clangs ) if (LIBCXX_TARGETING_CLANG_CL) target_add_compile_flags_if_supported(${target} PRIVATE diff --git a/libcxx/include/__config b/libcxx/include/__config index 1b56dc59c4c0..78c8a70cef7e 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1287,12 +1287,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( #define _LIBCPP_NODEBUG #endif -#if __has_attribute(__nodebug__) && (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900) -# define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug)) -#else -# define _LIBCPP_NODEBUG_TYPE -#endif - #if __has_attribute(__standalone_debug__) #define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) #else diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h index 386f8aaf075d..dff44fc674d5 100644 --- a/libcxx/include/__functional/function.h +++ b/libcxx/include/__functional/function.h @@ -127,8 +127,8 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> __compressed_pair<_Fp, _Ap> __f_; public: - typedef _LIBCPP_NODEBUG_TYPE _Fp _Target; - typedef _LIBCPP_NODEBUG_TYPE _Ap _Alloc; + typedef _LIBCPP_NODEBUG _Fp _Target; + typedef _LIBCPP_NODEBUG _Ap _Alloc; _LIBCPP_INLINE_VISIBILITY const _Target& __target() const { return __f_.first(); } @@ -205,7 +205,7 @@ class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> { _Fp __f_; public: - typedef _LIBCPP_NODEBUG_TYPE _Fp _Target; + typedef _LIBCPP_NODEBUG _Fp _Target; _LIBCPP_INLINE_VISIBILITY const _Target& __target() const { return __f_; } diff --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h index 95605b3856e8..f8bcda014a5d 100644 --- a/libcxx/include/__functional/hash.h +++ b/libcxx/include/__functional/hash.h @@ -836,29 +836,29 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP #ifndef _LIBCPP_CXX03_LANG template -using __check_hash_requirements _LIBCPP_NODEBUG_TYPE = integral_constant::value && is_move_constructible<_Hash>::value && __invokable_r::value >; template > -using __has_enabled_hash _LIBCPP_NODEBUG_TYPE = integral_constant::value && is_default_constructible<_Hash>::value >; #if _LIBCPP_STD_VER > 14 template -using __enable_hash_helper_imp _LIBCPP_NODEBUG_TYPE = _Type; +using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type; template -using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = __enable_hash_helper_imp<_Type, +using __enable_hash_helper _LIBCPP_NODEBUG = __enable_hash_helper_imp<_Type, typename enable_if<__all<__has_enabled_hash<_Keys>::value...>::value>::type >; #else template -using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = _Type; +using __enable_hash_helper _LIBCPP_NODEBUG = _Type; #endif #endif // !_LIBCPP_CXX03_LANG diff --git a/libcxx/include/__functional/unwrap_ref.h b/libcxx/include/__functional/unwrap_ref.h index e49adec5f8c1..dc309add90df 100644 --- a/libcxx/include/__functional/unwrap_ref.h +++ b/libcxx/include/__functional/unwrap_ref.h @@ -18,13 +18,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD template -struct __unwrap_reference { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; +struct __unwrap_reference { typedef _LIBCPP_NODEBUG _Tp type; }; template class reference_wrapper; template -struct __unwrap_reference > { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; }; +struct __unwrap_reference > { typedef _LIBCPP_NODEBUG _Tp& type; }; template struct decay; diff --git a/libcxx/include/__functional/weak_result_type.h b/libcxx/include/__functional/weak_result_type.h index 2ee85acf1ef4..32b1e0b1c6c4 100644 --- a/libcxx/include/__functional/weak_result_type.h +++ b/libcxx/include/__functional/weak_result_type.h @@ -89,7 +89,7 @@ struct __weak_result_type_imp // bool is true : public __maybe_derive_from_unary_function<_Tp>, public __maybe_derive_from_binary_function<_Tp> { - typedef _LIBCPP_NODEBUG_TYPE typename _Tp::result_type result_type; + typedef _LIBCPP_NODEBUG typename _Tp::result_type result_type; }; template @@ -110,19 +110,19 @@ struct __weak_result_type template struct __weak_result_type<_Rp ()> { - typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; + typedef _LIBCPP_NODEBUG _Rp result_type; }; template struct __weak_result_type<_Rp (&)()> { - typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; + typedef _LIBCPP_NODEBUG _Rp result_type; }; template struct __weak_result_type<_Rp (*)()> { - typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; + typedef _LIBCPP_NODEBUG _Rp result_type; }; // 1 argument case diff --git a/libcxx/include/__memory/allocator_arg_t.h b/libcxx/include/__memory/allocator_arg_t.h index 830c6b8148eb..fb98c5bfa00c 100644 --- a/libcxx/include/__memory/allocator_arg_t.h +++ b/libcxx/include/__memory/allocator_arg_t.h @@ -36,7 +36,7 @@ extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg; template struct __uses_alloc_ctor_imp { - typedef _LIBCPP_NODEBUG_TYPE typename __uncvref<_Alloc>::type _RawAlloc; + typedef _LIBCPP_NODEBUG typename __uncvref<_Alloc>::type _RawAlloc; static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value; static const bool __ic = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h index a02af0deafc9..a558d37a0098 100644 --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -36,11 +36,11 @@ template ::type, bool = __has_pointer<_RawAlloc>::value> struct __pointer { - using type _LIBCPP_NODEBUG_TYPE = typename _RawAlloc::pointer; + using type _LIBCPP_NODEBUG = typename _RawAlloc::pointer; }; template struct __pointer<_Tp, _Alloc, _RawAlloc, false> { - using type _LIBCPP_NODEBUG_TYPE = _Tp*; + using type _LIBCPP_NODEBUG = _Tp*; }; // __const_pointer @@ -48,14 +48,14 @@ _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer); template ::value> struct __const_pointer { - using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::const_pointer; + using type _LIBCPP_NODEBUG = typename _Alloc::const_pointer; }; template struct __const_pointer<_Tp, _Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG using type = typename pointer_traits<_Ptr>::template rebind::other; #else - using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind; + using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; #endif }; @@ -64,14 +64,14 @@ _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_void_pointer, void_pointer); template ::value> struct __void_pointer { - using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::void_pointer; + using type _LIBCPP_NODEBUG = typename _Alloc::void_pointer; }; template struct __void_pointer<_Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG - using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind::other; + using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind::other; #else - using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind; + using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; #endif }; @@ -80,14 +80,14 @@ _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_void_pointer, const_void_pointer); template ::value> struct __const_void_pointer { - using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::const_void_pointer; + using type _LIBCPP_NODEBUG = typename _Alloc::const_void_pointer; }; template struct __const_void_pointer<_Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG - using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind::other; + using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind::other; #else - using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind; + using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; #endif }; @@ -97,18 +97,18 @@ template ::value> struct __size_type : make_unsigned<_DiffType> { }; template struct __size_type<_Alloc, _DiffType, true> { - using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::size_type; + using type _LIBCPP_NODEBUG = typename _Alloc::size_type; }; // __alloc_traits_difference_type _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type); template ::value> struct __alloc_traits_difference_type { - using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::difference_type; + using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::difference_type; }; template struct __alloc_traits_difference_type<_Alloc, _Ptr, true> { - using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::difference_type; + using type _LIBCPP_NODEBUG = typename _Alloc::difference_type; }; // __propagate_on_container_copy_assignment @@ -117,7 +117,7 @@ template struct __propagate_on_container_copy_assignment<_Alloc, true> { - using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_copy_assignment; + using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_copy_assignment; }; // __propagate_on_container_move_assignment @@ -126,7 +126,7 @@ template struct __propagate_on_container_move_assignment<_Alloc, true> { - using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_move_assignment; + using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_move_assignment; }; // __propagate_on_container_swap @@ -135,7 +135,7 @@ template ::value> struct __propagate_on_container_swap : false_type { }; template struct __propagate_on_container_swap<_Alloc, true> { - using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_swap; + using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_swap; }; // __is_always_equal @@ -144,7 +144,7 @@ template ::value> struct __is_always_equal : is_empty<_Alloc> { }; template struct __is_always_equal<_Alloc, true> { - using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::is_always_equal; + using type _LIBCPP_NODEBUG = typename _Alloc::is_always_equal; }; // __allocator_traits_rebind @@ -158,15 +158,15 @@ struct __has_rebind_other<_Tp, _Up, typename __void_t< template ::value> struct __allocator_traits_rebind { - using type _LIBCPP_NODEBUG_TYPE = typename _Tp::template rebind<_Up>::other; + using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other; }; template