diff --git a/libcxx/include/__config b/libcxx/include/__config index 6a1e0f577391..ef2795b483a5 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1272,12 +1272,21 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( # define _LIBCPP_FALLTHROUGH() ((void)0) #endif -#if defined(_LIBCPP_COMPILER_CLANG) || defined(_LIBCPP_COMPILER_GCC) -#define _LIBCPP_NODEBUG __attribute__((nodebug)) +#if __has_attribute(__nodebug__) +#define _LIBCPP_NODEBUG __attribute__((__nodebug__)) #else #define _LIBCPP_NODEBUG #endif +#ifndef _LIBCPP_NODEBUG_TYPE +#if __has_attribute(__nodebug__) && \ + (defined(_LIBCPP_COMPILER_CLANG) && _LIBCPP_CLANG_VER >= 900) +#define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug)) +#else +#define _LIBCPP_NODEBUG_TYPE +#endif +#endif // !defined(_LIBCPP_NODEBUG_TYPE) + #if defined(_LIBCPP_ABI_MICROSOFT) && \ (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) diff --git a/libcxx/include/__functional_base b/libcxx/include/__functional_base index 8da8324545e0..9587d7ab15a1 100644 --- a/libcxx/include/__functional_base +++ b/libcxx/include/__functional_base @@ -125,7 +125,7 @@ struct __weak_result_type_imp // bool is true : public __maybe_derive_from_unary_function<_Tp>, public __maybe_derive_from_binary_function<_Tp> { - typedef typename _Tp::result_type result_type; + typedef _LIBCPP_NODEBUG_TYPE typename _Tp::result_type result_type; }; template @@ -146,19 +146,19 @@ struct __weak_result_type template struct __weak_result_type<_Rp ()> { - typedef _Rp result_type; + typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; }; template struct __weak_result_type<_Rp (&)()> { - typedef _Rp result_type; + typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; }; template struct __weak_result_type<_Rp (*)()> { - typedef _Rp result_type; + typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; }; // 1 argument case @@ -610,7 +610,7 @@ _LIBCPP_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Allo template struct __uses_alloc_ctor_imp { - typedef typename __uncvref<_Alloc>::type _RawAlloc; + typedef _LIBCPP_NODEBUG_TYPE 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/__tuple b/libcxx/include/__tuple index 0381031babf1..8f2e72d6d1c4 100644 --- a/libcxx/include/__tuple +++ b/libcxx/include/__tuple @@ -58,19 +58,19 @@ template struct _LIBCPP_TEMPLATE_VIS tuple_element; template struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> { - typedef typename add_const::type>::type type; + typedef _LIBCPP_NODEBUG_TYPE typename add_const::type>::type type; }; template struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> { - typedef typename add_volatile::type>::type type; + typedef _LIBCPP_NODEBUG_TYPE typename add_volatile::type>::type type; }; template struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> { - typedef typename add_cv::type>::type type; + typedef _LIBCPP_NODEBUG_TYPE typename add_cv::type>::type type; }; template struct __tuple_like : false_type {}; @@ -99,7 +99,7 @@ namespace __detail { template struct __repeat; template struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> { - typedef __integer_sequence<_Tp, + typedef _LIBCPP_NODEBUG_TYPE __integer_sequence<_Tp, _Np..., sizeof...(_Np) + _Np..., 2 * sizeof...(_Np) + _Np..., @@ -253,7 +253,7 @@ template struct __tuple_types {}; namespace __indexer_detail { template -struct __indexed { using type = _Tp; }; +struct __indexed { using type _LIBCPP_NODEBUG_TYPE = _Tp; }; template struct __indexer; @@ -268,7 +268,7 @@ __indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&); } // namespace __indexer_detail template -using __type_pack_element = typename decltype( +using __type_pack_element _LIBCPP_NODEBUG_TYPE = typename decltype( __indexer_detail::__at_index<_Idx>( __indexer_detail::__indexer< __tuple_types<_Types...>, @@ -281,7 +281,7 @@ template struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>> { static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range"); - typedef __type_pack_element<_Ip, _Types...> type; + typedef _LIBCPP_NODEBUG_TYPE __type_pack_element<_Ip, _Types...> type; }; @@ -301,34 +301,34 @@ struct __apply_cv_mf { }; template <> struct __apply_cv_mf { - template using __apply = const _Tp; + template using __apply _LIBCPP_NODEBUG_TYPE = const _Tp; }; template <> struct __apply_cv_mf { - template using __apply = volatile _Tp; + template using __apply _LIBCPP_NODEBUG_TYPE = volatile _Tp; }; template <> struct __apply_cv_mf { - template using __apply = const volatile _Tp; + template using __apply _LIBCPP_NODEBUG_TYPE = const volatile _Tp; }; template <> struct __apply_cv_mf { - template using __apply = _Tp&; + template using __apply _LIBCPP_NODEBUG_TYPE = _Tp&; }; template <> struct __apply_cv_mf { - template using __apply = const _Tp&; + template using __apply _LIBCPP_NODEBUG_TYPE = const _Tp&; }; template <> struct __apply_cv_mf { - template using __apply = volatile _Tp&; + template using __apply _LIBCPP_NODEBUG_TYPE = volatile _Tp&; }; template <> struct __apply_cv_mf { - template using __apply = const volatile _Tp&; + template using __apply _LIBCPP_NODEBUG_TYPE = const volatile _Tp&; }; template ::type> -using __apply_cv_t = __apply_cv_mf< +using __apply_cv_t _LIBCPP_NODEBUG_TYPE = __apply_cv_mf< is_lvalue_reference<_Tp>::value, is_const<_RawTp>::value, is_volatile<_RawTp>::value>; @@ -347,7 +347,7 @@ template