diff --git a/libcxx/include/__algorithm/comp_ref_type.h b/libcxx/include/__algorithm/comp_ref_type.h --- a/libcxx/include/__algorithm/comp_ref_type.h +++ b/libcxx/include/__algorithm/comp_ref_type.h @@ -49,8 +49,8 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX14 inline _LIBCPP_INLINE_VISIBILITY - decltype((void)declval<_Compare&>()( - declval<_LHS &>(), declval<_RHS &>())) + decltype((void)std::declval<_Compare&>()( + std::declval<_LHS &>(), std::declval<_RHS &>())) __do_compare_assert(int, _LHS & __l, _RHS & __r) { _LIBCPP_DEBUG_ASSERT(!__comp_(__l, __r), "Comparator does not induce a strict weak ordering"); diff --git a/libcxx/include/__algorithm/iter_swap.h b/libcxx/include/__algorithm/iter_swap.h --- a/libcxx/include/__algorithm/iter_swap.h +++ b/libcxx/include/__algorithm/iter_swap.h @@ -23,7 +23,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) - _NOEXCEPT_(_NOEXCEPT_(swap(*declval<_ForwardIterator1>(), *declval<_ForwardIterator2>()))) { + _NOEXCEPT_(_NOEXCEPT_(swap(*std::declval<_ForwardIterator1>(), *std::declval<_ForwardIterator2>()))) { swap(*__a, *__b); } diff --git a/libcxx/include/__compare/compare_three_way_result.h b/libcxx/include/__compare/compare_three_way_result.h --- a/libcxx/include/__compare/compare_three_way_result.h +++ b/libcxx/include/__compare/compare_three_way_result.h @@ -26,9 +26,9 @@ template struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<_Tp, _Up, decltype( - declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>(), void() + std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>(), void() )> { - using type = decltype(declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>()); + using type = decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>()); }; template diff --git a/libcxx/include/__compare/synth_three_way.h b/libcxx/include/__compare/synth_three_way.h --- a/libcxx/include/__compare/synth_three_way.h +++ b/libcxx/include/__compare/synth_three_way.h @@ -42,7 +42,7 @@ }; template -using __synth_three_way_result = decltype(std::__synth_three_way(declval<_Tp&>(), declval<_Up&>())); +using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>())); #endif // _LIBCPP_STD_VER > 17 diff --git a/libcxx/include/__concepts/common_with.h b/libcxx/include/__concepts/common_with.h --- a/libcxx/include/__concepts/common_with.h +++ b/libcxx/include/__concepts/common_with.h @@ -31,8 +31,8 @@ concept common_with = same_as, common_type_t<_Up, _Tp>> && requires { - static_cast>(declval<_Tp>()); - static_cast>(declval<_Up>()); + static_cast>(std::declval<_Tp>()); + static_cast>(std::declval<_Up>()); } && common_reference_with< add_lvalue_reference_t, diff --git a/libcxx/include/__concepts/convertible_to.h b/libcxx/include/__concepts/convertible_to.h --- a/libcxx/include/__concepts/convertible_to.h +++ b/libcxx/include/__concepts/convertible_to.h @@ -27,7 +27,7 @@ concept convertible_to = is_convertible_v<_From, _To> && requires { - static_cast<_To>(declval<_From>()); + static_cast<_To>(std::declval<_From>()); }; #endif // _LIBCPP_STD_VER > 17 diff --git a/libcxx/include/__format/format_arg.h b/libcxx/include/__format/format_arg.h --- a/libcxx/include/__format/format_arg.h +++ b/libcxx/include/__format/format_arg.h @@ -161,7 +161,7 @@ using _Dp = remove_cvref_t<_Tp>; using _Formatter = typename _Context::template formatter_type<_Dp>; constexpr bool __const_formattable = - requires { _Formatter().format(declval(), declval<_Context&>()); }; + requires { _Formatter().format(std::declval(), std::declval<_Context&>()); }; using _Qp = conditional_t<__const_formattable, const _Dp, _Dp>; static_assert(__const_formattable || !is_const_v>, "Mandated by [format.arg]/18"); diff --git a/libcxx/include/__functional/invoke.h b/libcxx/include/__functional/invoke.h --- a/libcxx/include/__functional/invoke.h +++ b/libcxx/include/__functional/invoke.h @@ -398,7 +398,7 @@ struct __invokable_r { template - static decltype(std::__invoke(declval<_XFp>(), declval<_XArgs>()...)) __try_call(int); + static decltype(std::__invoke(std::declval<_XFp>(), std::declval<_XArgs>()...)) __try_call(int); template static __nat __try_call(...); @@ -432,7 +432,7 @@ static const bool value = false; #else static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>( - _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...))); + _VSTD::__invoke(std::declval<_Fp>(), std::declval<_Args>()...))); #endif }; @@ -443,7 +443,7 @@ static const bool value = false; #else static const bool value = noexcept( - _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)); + _VSTD::__invoke(std::declval<_Fp>(), std::declval<_Args>()...)); #endif }; diff --git a/libcxx/include/__functional/reference_wrapper.h b/libcxx/include/__functional/reference_wrapper.h --- a/libcxx/include/__functional/reference_wrapper.h +++ b/libcxx/include/__functional/reference_wrapper.h @@ -38,9 +38,9 @@ static void __fun(_Tp&&) = delete; public: - template ::value, decltype(__fun(declval<_Up>())) > > + template ::value, decltype(__fun(std::declval<_Up>())) > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(declval<_Up>()))) { + reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) { type& __f = static_cast<_Up&&>(__u); __f_ = _VSTD::addressof(__f); } diff --git a/libcxx/include/__functional/weak_result_type.h b/libcxx/include/__functional/weak_result_type.h --- a/libcxx/include/__functional/weak_result_type.h +++ b/libcxx/include/__functional/weak_result_type.h @@ -286,7 +286,7 @@ template struct __invoke_return { - typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type; + typedef decltype(_VSTD::__invoke(std::declval<_Tp>(), std::declval<_Args>()...)) type; }; _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__iterator/advance.h b/libcxx/include/__iterator/advance.h --- a/libcxx/include/__iterator/advance.h +++ b/libcxx/include/__iterator/advance.h @@ -58,7 +58,7 @@ template < class _InputIter, class _Distance, - class _IntegralDistance = decltype(_VSTD::__convert_to_integral(declval<_Distance>())), + class _IntegralDistance = decltype(_VSTD::__convert_to_integral(std::declval<_Distance>())), class = __enable_if_t::value> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i, _Distance __orig_n) { diff --git a/libcxx/include/__iterator/common_iterator.h b/libcxx/include/__iterator/common_iterator.h --- a/libcxx/include/__iterator/common_iterator.h +++ b/libcxx/include/__iterator/common_iterator.h @@ -217,7 +217,7 @@ } _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i) - noexcept(noexcept(ranges::iter_move(declval()))) + noexcept(noexcept(ranges::iter_move(std::declval()))) requires input_iterator<_Iter> { _LIBCPP_ASSERT(std::holds_alternative<_Iter>(__i.__hold_), "Attempted to iter_move a non-dereferenceable common_iterator"); @@ -226,7 +226,7 @@ template _I2, class _S2> _LIBCPP_HIDE_FROM_ABI friend constexpr void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) - noexcept(noexcept(ranges::iter_swap(declval(), declval()))) + noexcept(noexcept(ranges::iter_swap(std::declval(), std::declval()))) { _LIBCPP_ASSERT(std::holds_alternative<_Iter>(__x.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator"); _LIBCPP_ASSERT(std::holds_alternative<_I2>(__y.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator"); @@ -257,7 +257,7 @@ template requires __common_iter_has_ptr_op<_Iter, _Sent> struct __arrow_type_or_void<_Iter, _Sent> { - using type = decltype(declval&>().operator->()); + using type = decltype(std::declval&>().operator->()); }; template diff --git a/libcxx/include/__iterator/incrementable_traits.h b/libcxx/include/__iterator/incrementable_traits.h --- a/libcxx/include/__iterator/incrementable_traits.h +++ b/libcxx/include/__iterator/incrementable_traits.h @@ -57,7 +57,7 @@ template<__has_integral_minus _Tp> requires (!__has_member_difference_type<_Tp>) struct incrementable_traits<_Tp> { - using difference_type = make_signed_t() - declval<_Tp>())>; + using difference_type = make_signed_t() - std::declval<_Tp>())>; }; template diff --git a/libcxx/include/__iterator/iter_move.h b/libcxx/include/__iterator/iter_move.h --- a/libcxx/include/__iterator/iter_move.h +++ b/libcxx/include/__iterator/iter_move.h @@ -95,7 +95,7 @@ template<__dereferenceable _Tp> requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __can_reference; } -using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>())); +using iter_rvalue_reference_t = decltype(ranges::iter_move(std::declval<_Tp&>())); #endif // _LIBCPP_STD_VER > 17 diff --git a/libcxx/include/__iterator/iter_swap.h b/libcxx/include/__iterator/iter_swap.h --- a/libcxx/include/__iterator/iter_swap.h +++ b/libcxx/include/__iterator/iter_swap.h @@ -82,7 +82,7 @@ constexpr void operator()(_T1&& __x, _T2&& __y) const noexcept(noexcept(iter_value_t<_T2>(ranges::iter_move(__y))) && noexcept(*__y = ranges::iter_move(__x)) && - noexcept(*_VSTD::forward<_T1>(__x) = declval>())) + noexcept(*_VSTD::forward<_T1>(__x) = std::declval>())) { iter_value_t<_T2> __old(ranges::iter_move(__y)); *__y = ranges::iter_move(__x); diff --git a/libcxx/include/__iterator/iterator_traits.h b/libcxx/include/__iterator/iterator_traits.h --- a/libcxx/include/__iterator/iterator_traits.h +++ b/libcxx/include/__iterator/iterator_traits.h @@ -60,7 +60,7 @@ // [iterator.traits] template<__dereferenceable _Tp> -using iter_reference_t = decltype(*declval<_Tp&>()); +using iter_reference_t = decltype(*std::declval<_Tp&>()); #endif // _LIBCPP_STD_VER > 17 @@ -273,7 +273,7 @@ template requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>) struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { - using type = decltype(declval<_Ip&>().operator->()); + using type = decltype(std::declval<_Ip&>().operator->()); }; // Otherwise, `reference` names `iter-reference-t`. diff --git a/libcxx/include/__iterator/move_iterator.h b/libcxx/include/__iterator/move_iterator.h --- a/libcxx/include/__iterator/move_iterator.h +++ b/libcxx/include/__iterator/move_iterator.h @@ -53,7 +53,7 @@ template concept __move_iter_comparable = requires { - { declval() == declval<_Sent>() } -> convertible_to; + { std::declval() == std::declval<_Sent>() } -> convertible_to; }; #endif // _LIBCPP_STD_VER > 17 diff --git a/libcxx/include/__iterator/reverse_iterator.h b/libcxx/include/__iterator/reverse_iterator.h --- a/libcxx/include/__iterator/reverse_iterator.h +++ b/libcxx/include/__iterator/reverse_iterator.h @@ -184,7 +184,7 @@ _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i) noexcept(is_nothrow_copy_constructible_v<_Iter> && - noexcept(ranges::iter_move(--declval<_Iter&>()))) { + noexcept(ranges::iter_move(--std::declval<_Iter&>()))) { auto __tmp = __i.base(); return ranges::iter_move(--__tmp); } @@ -194,7 +194,7 @@ void iter_swap(const reverse_iterator& __x, const reverse_iterator<_Iter2>& __y) noexcept(is_nothrow_copy_constructible_v<_Iter> && is_nothrow_copy_constructible_v<_Iter2> && - noexcept(ranges::iter_swap(--declval<_Iter&>(), --declval<_Iter2&>()))) { + noexcept(ranges::iter_swap(--std::declval<_Iter&>(), --std::declval<_Iter2&>()))) { auto __xtmp = __x.base(); auto __ytmp = __y.base(); ranges::iter_swap(--__xtmp, --__ytmp); @@ -401,7 +401,7 @@ _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const __unconstrained_reverse_iterator& __i) noexcept(is_nothrow_copy_constructible_v<_Iter> && - noexcept(ranges::iter_move(--declval<_Iter&>()))) { + noexcept(ranges::iter_move(--std::declval<_Iter&>()))) { auto __tmp = __i.base(); return ranges::iter_move(--__tmp); } diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -187,7 +187,7 @@ template struct __has_allocate_hint<_Alloc, _SizeType, _ConstVoidPtr, decltype( - (void)declval<_Alloc>().allocate(declval<_SizeType>(), declval<_ConstVoidPtr>()) + (void)std::declval<_Alloc>().allocate(std::declval<_SizeType>(), std::declval<_ConstVoidPtr>()) )> : true_type { }; // __has_construct @@ -196,7 +196,7 @@ template struct __has_construct_impl().construct(declval<_Args>()...) + (void)std::declval<_Alloc>().construct(std::declval<_Args>()...) ), _Alloc, _Args...> : true_type { }; template @@ -208,7 +208,7 @@ template struct __has_destroy<_Alloc, _Pointer, decltype( - (void)declval<_Alloc>().destroy(declval<_Pointer>()) + (void)std::declval<_Alloc>().destroy(std::declval<_Pointer>()) )> : true_type { }; // __has_max_size @@ -217,7 +217,7 @@ template struct __has_max_size<_Alloc, decltype( - (void)declval<_Alloc&>().max_size() + (void)std::declval<_Alloc&>().max_size() )> : true_type { }; // __has_select_on_container_copy_construction @@ -226,7 +226,7 @@ template struct __has_select_on_container_copy_construction<_Alloc, decltype( - (void)declval<_Alloc>().select_on_container_copy_construction() + (void)std::declval<_Alloc>().select_on_container_copy_construction() )> : true_type { }; _LIBCPP_SUPPRESS_DEPRECATED_POP diff --git a/libcxx/include/__memory/construct_at.h b/libcxx/include/__memory/construct_at.h --- a/libcxx/include/__memory/construct_at.h +++ b/libcxx/include/__memory/construct_at.h @@ -32,7 +32,7 @@ #if _LIBCPP_STD_VER > 17 -template ()) _Tp(declval<_Args>()...))> +template ()) _Tp(std::declval<_Args>()...))> _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) { _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"); return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...); @@ -40,7 +40,7 @@ #endif -template ()) _Tp(declval<_Args>()...))> +template ()) _Tp(std::declval<_Args>()...))> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) { #if _LIBCPP_STD_VER > 17 return std::construct_at(__location, std::forward<_Args>(__args)...); diff --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h --- a/libcxx/include/__memory/pointer_traits.h +++ b/libcxx/include/__memory/pointer_traits.h @@ -179,7 +179,7 @@ template struct _HasToAddress<_Pointer, - decltype((void)pointer_traits<_Pointer>::to_address(declval())) + decltype((void)pointer_traits<_Pointer>::to_address(std::declval())) > : true_type {}; template @@ -187,7 +187,7 @@ template struct _HasArrow<_Pointer, - decltype((void)declval().operator->()) + decltype((void)std::declval().operator->()) > : true_type {}; template @@ -200,7 +200,7 @@ _And, _IsFancyPointer<_Pointer> >::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename decay::__call(declval()))>::type +typename decay::__call(std::declval()))>::type __to_address(const _Pointer& __p) _NOEXCEPT { return __to_address_helper<_Pointer>::__call(__p); } @@ -208,16 +208,16 @@ template struct __to_address_helper { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - static decltype(_VSTD::__to_address(declval().operator->())) + static decltype(_VSTD::__to_address(std::declval().operator->())) __call(const _Pointer& __p) _NOEXCEPT { return _VSTD::__to_address(__p.operator->()); } }; template -struct __to_address_helper<_Pointer, decltype((void)pointer_traits<_Pointer>::to_address(declval()))> { +struct __to_address_helper<_Pointer, decltype((void)pointer_traits<_Pointer>::to_address(std::declval()))> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - static decltype(pointer_traits<_Pointer>::to_address(declval())) + static decltype(pointer_traits<_Pointer>::to_address(std::declval())) __call(const _Pointer& __p) _NOEXCEPT { return pointer_traits<_Pointer>::to_address(__p); } diff --git a/libcxx/include/__memory/ranges_construct_at.h b/libcxx/include/__memory/ranges_construct_at.h --- a/libcxx/include/__memory/ranges_construct_at.h +++ b/libcxx/include/__memory/ranges_construct_at.h @@ -39,7 +39,7 @@ struct __fn { template()) _Tp(declval<_Args>()...) + ::new (std::declval()) _Tp(std::declval<_Args>()...) )> _LIBCPP_HIDE_FROM_ABI constexpr _Tp* operator()(_Tp* __location, _Args&& ...__args) const { diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h --- a/libcxx/include/__memory/shared_ptr.h +++ b/libcxx/include/__memory/shared_ptr.h @@ -366,15 +366,15 @@ template struct __is_deletable : false_type { }; template -struct __is_deletable<_Ptr, decltype(delete declval<_Ptr>())> : true_type { }; +struct __is_deletable<_Ptr, decltype(delete std::declval<_Ptr>())> : true_type { }; template struct __is_array_deletable : false_type { }; template -struct __is_array_deletable<_Ptr, decltype(delete[] declval<_Ptr>())> : true_type { }; +struct __is_array_deletable<_Ptr, decltype(delete[] std::declval<_Ptr>())> : true_type { }; template ()(declval<_Pt>()))> + class = decltype(std::declval<_Dp>()(std::declval<_Pt>()))> static true_type __well_formed_deleter_test(int); template diff --git a/libcxx/include/__random/is_valid.h b/libcxx/include/__random/is_valid.h --- a/libcxx/include/__random/is_valid.h +++ b/libcxx/include/__random/is_valid.h @@ -53,7 +53,7 @@ template struct __libcpp_random_is_valid_urng : false_type {}; template struct __libcpp_random_is_valid_urng<_Gp, __enable_if_t< is_unsigned::value && - _IsSame()()), typename _Gp::result_type>::value + _IsSame()()), typename _Gp::result_type>::value > > : true_type {}; _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__ranges/access.h b/libcxx/include/__ranges/access.h --- a/libcxx/include/__ranges/access.h +++ b/libcxx/include/__ranges/access.h @@ -105,7 +105,7 @@ namespace ranges { template - using iterator_t = decltype(ranges::begin(declval<_Tp&>())); + using iterator_t = decltype(ranges::begin(std::declval<_Tp&>())); } // namespace ranges // [range.access.end] diff --git a/libcxx/include/__ranges/all.h b/libcxx/include/__ranges/all.h --- a/libcxx/include/__ranges/all.h +++ b/libcxx/include/__ranges/all.h @@ -73,7 +73,7 @@ } // namespace __cpo template -using all_t = decltype(views::all(declval<_Range>())); +using all_t = decltype(views::all(std::declval<_Range>())); } // namespace ranges::views diff --git a/libcxx/include/__ranges/concepts.h b/libcxx/include/__ranges/concepts.h --- a/libcxx/include/__ranges/concepts.h +++ b/libcxx/include/__ranges/concepts.h @@ -59,7 +59,7 @@ // `iterator_t` defined in <__ranges/access.h> template - using sentinel_t = decltype(ranges::end(declval<_Rp&>())); + using sentinel_t = decltype(ranges::end(std::declval<_Rp&>())); template using range_difference_t = iter_difference_t>; @@ -78,7 +78,7 @@ concept sized_range = range<_Tp> && requires(_Tp& __t) { ranges::size(__t); }; template - using range_size_t = decltype(ranges::size(declval<_Rp&>())); + using range_size_t = decltype(ranges::size(std::declval<_Rp&>())); // `disable_sized_range` defined in `<__ranges/size.h>` diff --git a/libcxx/include/__ranges/ref_view.h b/libcxx/include/__ranges/ref_view.h --- a/libcxx/include/__ranges/ref_view.h +++ b/libcxx/include/__ranges/ref_view.h @@ -47,7 +47,7 @@ public: template requires __different_from<_Tp, ref_view> && - convertible_to<_Tp, _Range&> && requires { __fun(declval<_Tp>()); } + convertible_to<_Tp, _Range&> && requires { __fun(std::declval<_Tp>()); } _LIBCPP_HIDE_FROM_ABI constexpr ref_view(_Tp&& __t) : __range_(std::addressof(static_cast<_Range&>(std::forward<_Tp>(__t)))) diff --git a/libcxx/include/__ranges/size.h b/libcxx/include/__ranges/size.h --- a/libcxx/include/__ranges/size.h +++ b/libcxx/include/__ranges/size.h @@ -21,6 +21,7 @@ #include <__type_traits/make_unsigned.h> #include <__type_traits/remove_cvref.h> #include <__utility/auto_cast.h> +#include <__utility/declval.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -70,7 +71,7 @@ __class_or_enum> && requires(_Tp&& __t) { { ranges::begin(__t) } -> forward_iterator; - { ranges::end(__t) } -> sized_sentinel_for()))>; + { ranges::end(__t) } -> sized_sentinel_for()))>; }; struct __fn { diff --git a/libcxx/include/__ranges/zip_view.h b/libcxx/include/__ranges/zip_view.h --- a/libcxx/include/__ranges/zip_view.h +++ b/libcxx/include/__ranges/zip_view.h @@ -403,15 +403,15 @@ _LIBCPP_HIDE_FROM_ABI friend constexpr auto iter_move(const __iterator& __i) noexcept( - (noexcept(ranges::iter_move(declval>&>())) && ...) && + (noexcept(ranges::iter_move(std::declval>&>())) && ...) && (is_nothrow_move_constructible_v>> && ...)) { return ranges::__tuple_transform(ranges::iter_move, __i.__current_); } _LIBCPP_HIDE_FROM_ABI friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept( - (noexcept(ranges::iter_swap(declval>&>(), - declval>&>())) && + (noexcept(ranges::iter_swap(std::declval>&>(), + std::declval>&>())) && ...)) requires(indirectly_swappable>> && ...) { ranges::__tuple_zip_for_each(ranges::iter_swap, __l.__current_, __r.__current_); diff --git a/libcxx/include/__type_traits/common_reference.h b/libcxx/include/__type_traits/common_reference.h --- a/libcxx/include/__type_traits/common_reference.h +++ b/libcxx/include/__type_traits/common_reference.h @@ -31,7 +31,7 @@ // Let COND_RES(X, Y) be: template using __cond_res = - decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()()); + decltype(false ? std::declval<_Xp(&)()>()() : std::declval<_Yp(&)()>()()); // Let `XREF(A)` denote a unary alias template `T` such that `T` denotes the same type as `U` // with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type diff --git a/libcxx/include/__type_traits/common_type.h b/libcxx/include/__type_traits/common_type.h --- a/libcxx/include/__type_traits/common_type.h +++ b/libcxx/include/__type_traits/common_type.h @@ -26,7 +26,7 @@ #if _LIBCPP_STD_VER > 17 // Let COND_RES(X, Y) be: template -using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>()); +using __cond_type = decltype(false ? std::declval<_Tp>() : std::declval<_Up>()); template struct __common_type3 {}; @@ -47,10 +47,10 @@ // sub-bullet 3 - "if decay_t() : declval())> ..." template -struct __common_type2_imp<_Tp, _Up, __void_t() : declval<_Up>())> > +struct __common_type2_imp<_Tp, _Up, __void_t() : std::declval<_Up>())> > { typedef _LIBCPP_NODEBUG typename decay() : declval<_Up>() + true ? std::declval<_Tp>() : std::declval<_Up>() )>::type type; }; diff --git a/libcxx/include/__type_traits/is_allocator.h b/libcxx/include/__type_traits/is_allocator.h --- a/libcxx/include/__type_traits/is_allocator.h +++ b/libcxx/include/__type_traits/is_allocator.h @@ -27,7 +27,7 @@ template struct __is_allocator<_Alloc, __void_t, - __void_t().allocate(size_t(0)))> + __void_t().allocate(size_t(0)))> > : true_type {}; diff --git a/libcxx/include/__type_traits/is_convertible.h b/libcxx/include/__type_traits/is_convertible.h --- a/libcxx/include/__type_traits/is_convertible.h +++ b/libcxx/include/__type_traits/is_convertible.h @@ -40,7 +40,7 @@ template struct __is_convertible_test<_From, _To, - decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type + decltype(__is_convertible_imp::__test_convert<_To>(std::declval<_From>()))> : public true_type {}; template ::value, diff --git a/libcxx/include/__type_traits/is_destructible.h b/libcxx/include/__type_traits/is_destructible.h --- a/libcxx/include/__type_traits/is_destructible.h +++ b/libcxx/include/__type_traits/is_destructible.h @@ -48,7 +48,7 @@ struct __is_destructor_wellformed { template static true_type __test ( - typename __is_destructible_apply().~_Tp1())>::type + typename __is_destructible_apply().~_Tp1())>::type ); template diff --git a/libcxx/include/__type_traits/is_nothrow_constructible.h b/libcxx/include/__type_traits/is_nothrow_constructible.h --- a/libcxx/include/__type_traits/is_nothrow_constructible.h +++ b/libcxx/include/__type_traits/is_nothrow_constructible.h @@ -34,7 +34,7 @@ template struct __libcpp_is_nothrow_constructible - : public integral_constant()...))> + : public integral_constant()...))> { }; @@ -43,7 +43,7 @@ template struct __libcpp_is_nothrow_constructible - : public integral_constant(declval<_Arg>()))> + : public integral_constant(std::declval<_Arg>()))> { }; diff --git a/libcxx/include/__type_traits/is_nothrow_convertible.h b/libcxx/include/__type_traits/is_nothrow_convertible.h --- a/libcxx/include/__type_traits/is_nothrow_convertible.h +++ b/libcxx/include/__type_traits/is_nothrow_convertible.h @@ -30,7 +30,7 @@ static void __test_noexcept(_Tp) noexcept; template -static bool_constant(declval<_Fm>()))> +static bool_constant(std::declval<_Fm>()))> __is_nothrow_convertible_test(); template diff --git a/libcxx/include/__type_traits/is_nothrow_destructible.h b/libcxx/include/__type_traits/is_nothrow_destructible.h --- a/libcxx/include/__type_traits/is_nothrow_destructible.h +++ b/libcxx/include/__type_traits/is_nothrow_destructible.h @@ -36,7 +36,7 @@ template struct __libcpp_is_nothrow_destructible - : public integral_constant().~_Tp()) > + : public integral_constant().~_Tp()) > { }; diff --git a/libcxx/include/__type_traits/is_swappable.h b/libcxx/include/__type_traits/is_swappable.h --- a/libcxx/include/__type_traits/is_swappable.h +++ b/libcxx/include/__type_traits/is_swappable.h @@ -64,7 +64,7 @@ struct __swappable_with { template - static decltype(swap(declval<_LHS>(), declval<_RHS>())) + static decltype(swap(std::declval<_LHS>(), std::declval<_RHS>())) __test_swap(int); template static __nat __test_swap(long); @@ -84,8 +84,8 @@ struct __nothrow_swappable_with { static const bool value = #ifndef _LIBCPP_HAS_NO_NOEXCEPT - noexcept(swap(declval<_Tp>(), declval<_Up>())) - && noexcept(swap(declval<_Up>(), declval<_Tp>())); + noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) + && noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())); #else false; #endif diff --git a/libcxx/include/__type_traits/promote.h b/libcxx/include/__type_traits/promote.h --- a/libcxx/include/__type_traits/promote.h +++ b/libcxx/include/__type_traits/promote.h @@ -40,7 +40,7 @@ static double __test(double); static long double __test(long double); - typedef decltype(__test(declval<_Tp>())) type; + typedef decltype(__test(std::declval<_Tp>())) type; static const bool value = _IsNotSame::value; }; diff --git a/libcxx/include/experimental/propagate_const b/libcxx/include/experimental/propagate_const --- a/libcxx/include/experimental/propagate_const +++ b/libcxx/include/experimental/propagate_const @@ -139,7 +139,7 @@ class propagate_const { public: - typedef remove_reference_t())> element_type; + typedef remove_reference_t())> element_type; static_assert(!is_array<_Tp>::value, "Instantiation of propagate_const with an array type is ill-formed."); diff --git a/libcxx/include/istream b/libcxx/include/istream --- a/libcxx/include/istream +++ b/libcxx/include/istream @@ -1375,7 +1375,7 @@ template struct __is_istreamable<_Stream, _Tp, decltype( - declval<_Stream>() >> declval<_Tp>(), void() + std::declval<_Stream>() >> std::declval<_Tp>(), void() )> : true_type { }; template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() == - declval()), bool>, + is_convertible_v() == + std::declval()), bool>, bool > operator==(const optional<_Tp>& __x, const optional<_Up>& __y) @@ -1201,8 +1201,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() != - declval()), bool>, + is_convertible_v() != + std::declval()), bool>, bool > operator!=(const optional<_Tp>& __x, const optional<_Up>& __y) @@ -1217,8 +1217,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() < - declval()), bool>, + is_convertible_v() < + std::declval()), bool>, bool > operator<(const optional<_Tp>& __x, const optional<_Up>& __y) @@ -1233,8 +1233,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() > - declval()), bool>, + is_convertible_v() > + std::declval()), bool>, bool > operator>(const optional<_Tp>& __x, const optional<_Up>& __y) @@ -1249,8 +1249,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() <= - declval()), bool>, + is_convertible_v() <= + std::declval()), bool>, bool > operator<=(const optional<_Tp>& __x, const optional<_Up>& __y) @@ -1265,8 +1265,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() >= - declval()), bool>, + is_convertible_v() >= + std::declval()), bool>, bool > operator>=(const optional<_Tp>& __x, const optional<_Up>& __y) @@ -1379,8 +1379,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() == - declval()), bool>, + is_convertible_v() == + std::declval()), bool>, bool > operator==(const optional<_Tp>& __x, const _Up& __v) @@ -1391,8 +1391,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() == - declval()), bool>, + is_convertible_v() == + std::declval()), bool>, bool > operator==(const _Tp& __v, const optional<_Up>& __x) @@ -1403,8 +1403,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() != - declval()), bool>, + is_convertible_v() != + std::declval()), bool>, bool > operator!=(const optional<_Tp>& __x, const _Up& __v) @@ -1415,8 +1415,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() != - declval()), bool>, + is_convertible_v() != + std::declval()), bool>, bool > operator!=(const _Tp& __v, const optional<_Up>& __x) @@ -1427,8 +1427,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() < - declval()), bool>, + is_convertible_v() < + std::declval()), bool>, bool > operator<(const optional<_Tp>& __x, const _Up& __v) @@ -1439,8 +1439,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() < - declval()), bool>, + is_convertible_v() < + std::declval()), bool>, bool > operator<(const _Tp& __v, const optional<_Up>& __x) @@ -1451,8 +1451,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() <= - declval()), bool>, + is_convertible_v() <= + std::declval()), bool>, bool > operator<=(const optional<_Tp>& __x, const _Up& __v) @@ -1463,8 +1463,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() <= - declval()), bool>, + is_convertible_v() <= + std::declval()), bool>, bool > operator<=(const _Tp& __v, const optional<_Up>& __x) @@ -1475,8 +1475,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() > - declval()), bool>, + is_convertible_v() > + std::declval()), bool>, bool > operator>(const optional<_Tp>& __x, const _Up& __v) @@ -1487,8 +1487,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() > - declval()), bool>, + is_convertible_v() > + std::declval()), bool>, bool > operator>(const _Tp& __v, const optional<_Up>& __x) @@ -1499,8 +1499,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() >= - declval()), bool>, + is_convertible_v() >= + std::declval()), bool>, bool > operator>=(const optional<_Tp>& __x, const _Up& __v) @@ -1511,8 +1511,8 @@ template _LIBCPP_INLINE_VISIBILITY constexpr enable_if_t< - is_convertible_v() >= - declval()), bool>, + is_convertible_v() >= + std::declval()), bool>, bool > operator>=(const _Tp& __v, const optional<_Up>& __x) diff --git a/libcxx/include/ostream b/libcxx/include/ostream --- a/libcxx/include/ostream +++ b/libcxx/include/ostream @@ -1063,7 +1063,7 @@ template struct __is_ostreamable<_Stream, _Tp, decltype( - declval<_Stream>() << declval<_Tp>(), void() + std::declval<_Stream>() << std::declval<_Tp>(), void() )> : true_type { }; template &>() << declval::pointer>()))> >::value, + is_same&>() << std::declval::pointer>()))> >::value, basic_ostream<_CharT, _Traits>& >::type operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p) diff --git a/libcxx/include/scoped_allocator b/libcxx/include/scoped_allocator --- a/libcxx/include/scoped_allocator +++ b/libcxx/include/scoped_allocator @@ -363,7 +363,7 @@ // __outermost template -decltype(declval<_Alloc>().outer_allocator(), true_type()) +decltype(std::declval<_Alloc>().outer_allocator(), true_type()) __has_outer_allocator_test(_Alloc&& __a); template @@ -374,7 +374,7 @@ struct __has_outer_allocator : public common_type < - decltype(std::__has_outer_allocator_test(declval<_Alloc&>())) + decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>())) >::type { }; @@ -392,7 +392,7 @@ { typedef __libcpp_remove_reference_t < - decltype(declval<_Alloc>().outer_allocator()) + decltype(std::declval<_Alloc>().outer_allocator()) > _OuterAlloc; typedef typename __outermost<_OuterAlloc>::type type; _LIBCPP_INLINE_VISIBILITY diff --git a/libcxx/include/variant b/libcxx/include/variant --- a/libcxx/include/variant +++ b/libcxx/include/variant @@ -1229,7 +1229,7 @@ template static auto __test_impl(_Dest (&&)[1]) -> __type_identity<_Dest>; template - using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({declval<_Source>()})); + using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({std::declval<_Source>()})); }; template @@ -1747,7 +1747,7 @@ template < class _Visitor, class... _Vs, - typename = void_t()))...> > + typename = void_t()))...> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) { @@ -1760,7 +1760,7 @@ #if _LIBCPP_STD_VER > 17 template < class _Rp, class _Visitor, class... _Vs, - typename = void_t()))...> > + typename = void_t()))...> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs) { diff --git a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt --- a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt +++ b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt @@ -7,7 +7,9 @@ set(SOURCES robust_against_adl.cpp - libcpp_module.cpp) + libcpp_module.cpp + qualify_declval.cpp + ) if(NOT Clang_FOUND) diff --git a/libcxx/test/tools/clang_tidy_checks/libcpp_module.cpp b/libcxx/test/tools/clang_tidy_checks/libcpp_module.cpp --- a/libcxx/test/tools/clang_tidy_checks/libcpp_module.cpp +++ b/libcxx/test/tools/clang_tidy_checks/libcpp_module.cpp @@ -9,12 +9,14 @@ #include "clang-tidy/ClangTidyModule.h" #include "clang-tidy/ClangTidyModuleRegistry.h" #include "robust_against_adl.hpp" +#include "qualify_declval.hpp" namespace { class LibcxxTestModule : public clang::tidy::ClangTidyModule { public: void addCheckFactories(clang::tidy::ClangTidyCheckFactories& check_factories) override { check_factories.registerCheck("libcpp-robust-against-adl"); + check_factories.registerCheck("libcpp-qualify-declval"); } }; } // namespace diff --git a/libcxx/test/tools/clang_tidy_checks/qualify_declval.hpp b/libcxx/test/tools/clang_tidy_checks/qualify_declval.hpp new file mode 100644 --- /dev/null +++ b/libcxx/test/tools/clang_tidy_checks/qualify_declval.hpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-tidy/ClangTidyCheck.h" + +namespace libcpp { +class qualify_declval : public clang::tidy::ClangTidyCheck { +public: + qualify_declval(llvm::StringRef, clang::tidy::ClangTidyContext*); + void registerMatchers(clang::ast_matchers::MatchFinder*) override; + void check(const clang::ast_matchers::MatchFinder::MatchResult&) override; +}; +} // namespace libcpp diff --git a/libcxx/test/tools/clang_tidy_checks/qualify_declval.cpp b/libcxx/test/tools/clang_tidy_checks/qualify_declval.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/tools/clang_tidy_checks/qualify_declval.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "qualify_declval.hpp" + +namespace { +AST_MATCHER(clang::UnresolvedLookupExpr, requiresADL) { return Node.requiresADL(); } +AST_MATCHER(clang::UnresolvedLookupExpr, isDeclval) { return Node.getName().getAsString() == "declval"; } +} // namespace + +namespace libcpp { +qualify_declval::qualify_declval(llvm::StringRef name, clang::tidy::ClangTidyContext* context) + : clang::tidy::ClangTidyCheck(name, context) {} + +void qualify_declval::registerMatchers(clang::ast_matchers::MatchFinder* finder) { + using namespace clang::ast_matchers; + finder->addMatcher(callExpr(has(unresolvedLookupExpr(requiresADL(), isDeclval()))).bind("ADLcall"), this); +} + +void qualify_declval::check(const clang::ast_matchers::MatchFinder::MatchResult& result) { + if (const auto* call = result.Nodes.getNodeAs("ADLcall"); call != nullptr) { + diag(call->getBeginLoc(), "declval should be qualified to get better error messages") + << clang::FixItHint::CreateInsertion(call->getBeginLoc(), "std::"); + } +} +} // namespace libcpp