diff options
Diffstat (limited to 'contrib/llvm-project/libcxx')
71 files changed, 650 insertions, 198 deletions
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/in_in_out_result.h b/contrib/llvm-project/libcxx/include/__algorithm/in_in_out_result.h new file mode 100644 index 000000000000..e365eb58eb62 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__algorithm/in_in_out_result.h @@ -0,0 +1,48 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H +#define _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H + +#include <__concepts/convertible_to.h> +#include <__config> +#include <__utility/move.h> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifndef _LIBCPP_HAS_NO_CONCEPTS + +namespace ranges { +template <class _I1, class _I2, class _O1> +struct in_in_out_result { + [[no_unique_address]] _I1 in1; + [[no_unique_address]] _I2 in2; + [[no_unique_address]] _O1 out; + + template <class _II1, class _II2, class _OO1> + requires convertible_to<const _I1&, _II1> && convertible_to<const _I2&, _II2> && convertible_to<const _O1&, _OO1> + _LIBCPP_HIDE_FROM_ABI constexpr + operator in_in_out_result<_II1, _II2, _OO1>() const& { + return {in1, in2, out}; + } + + template <class _II1, class _II2, class _OO1> + requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2> && convertible_to<_O1, _OO1> + _LIBCPP_HIDE_FROM_ABI constexpr + operator in_in_out_result<_II1, _II2, _OO1>() && { + return {_VSTD::move(in1), _VSTD::move(in2), _VSTD::move(out)}; + } +}; +} // namespace ranges + +#endif // _LIBCPP_HAS_NO_CONCEPTS + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ALGORITHM_IN_IN_RESULT_H diff --git a/contrib/llvm-project/libcxx/include/__algorithm/in_in_result.h b/contrib/llvm-project/libcxx/include/__algorithm/in_in_result.h index fbe53ae4f57e..ed14ecedbbdf 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/in_in_result.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/in_in_result.h @@ -16,7 +16,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_HAS_NO_RANGES +#ifndef _LIBCPP_HAS_NO_CONCEPTS namespace ranges { template <class _I1, class _I2> @@ -38,7 +38,7 @@ struct in_in_result { }; } // namespace ranges -#endif // _LIBCPP_HAS_NO_RANGES +#endif // _LIBCPP_HAS_NO_CONCEPTS _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__algorithm/in_out_result.h b/contrib/llvm-project/libcxx/include/__algorithm/in_out_result.h index 9d971157200f..8a58d6ada10c 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/in_out_result.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/in_out_result.h @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template<class _InputIterator, class _OutputIterator> @@ -45,7 +45,7 @@ struct in_out_result { }; } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__compare/compare_partial_order_fallback.h b/contrib/llvm-project/libcxx/include/__compare/compare_partial_order_fallback.h new file mode 100644 index 000000000000..895523b38fb3 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__compare/compare_partial_order_fallback.h @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK +#define _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK + +#include <__compare/ordering.h> +#include <__compare/partial_order.h> +#include <__config> +#include <__utility/forward.h> +#include <__utility/priority_tag.h> +#include <type_traits> + +#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) + +// [cmp.alg] +namespace __compare_partial_order_fallback { + struct __fn { + template<class _Tp, class _Up> + requires is_same_v<decay_t<_Tp>, decay_t<_Up>> + _LIBCPP_HIDE_FROM_ABI static constexpr auto + __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) + noexcept(noexcept(_VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) + -> decltype( _VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))) + { return _VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } + + template<class _Tp, class _Up> + requires is_same_v<decay_t<_Tp>, decay_t<_Up>> + _LIBCPP_HIDE_FROM_ABI static constexpr auto + __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) + noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent : + _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less : + _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater : + partial_ordering::unordered)) + -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent : + _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less : + _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater : + partial_ordering::unordered) + { + return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent : + _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less : + _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater : + partial_ordering::unordered; + } + + template<class _Tp, class _Up> + _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))) + -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())) + { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); } + }; +} // namespace __compare_partial_order_fallback + +inline namespace __cpo { + inline constexpr auto compare_partial_order_fallback = __compare_partial_order_fallback::__fn{}; +} // namespace __cpo + +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK diff --git a/contrib/llvm-project/libcxx/include/__compare/compare_strong_order_fallback.h b/contrib/llvm-project/libcxx/include/__compare/compare_strong_order_fallback.h new file mode 100644 index 000000000000..5fee7b478068 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__compare/compare_strong_order_fallback.h @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK +#define _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK + +#include <__compare/ordering.h> +#include <__compare/strong_order.h> +#include <__config> +#include <__utility/forward.h> +#include <__utility/priority_tag.h> +#include <type_traits> + +#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) + +// [cmp.alg] +namespace __compare_strong_order_fallback { + struct __fn { + template<class _Tp, class _Up> + requires is_same_v<decay_t<_Tp>, decay_t<_Up>> + _LIBCPP_HIDE_FROM_ABI static constexpr auto + __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) + noexcept(noexcept(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) + -> decltype( _VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))) + { return _VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } + + template<class _Tp, class _Up> + requires is_same_v<decay_t<_Tp>, decay_t<_Up>> + _LIBCPP_HIDE_FROM_ABI static constexpr auto + __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) + noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal : + _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less : + strong_ordering::greater)) + -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal : + _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less : + strong_ordering::greater) + { + return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal : + _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less : + strong_ordering::greater; + } + + template<class _Tp, class _Up> + _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))) + -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())) + { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); } + }; +} // namespace __compare_strong_order_fallback + +inline namespace __cpo { + inline constexpr auto compare_strong_order_fallback = __compare_strong_order_fallback::__fn{}; +} // namespace __cpo + +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK diff --git a/contrib/llvm-project/libcxx/include/__compare/compare_weak_order_fallback.h b/contrib/llvm-project/libcxx/include/__compare/compare_weak_order_fallback.h new file mode 100644 index 000000000000..0abd4f2dfbee --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__compare/compare_weak_order_fallback.h @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK +#define _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK + +#include <__compare/ordering.h> +#include <__compare/weak_order.h> +#include <__config> +#include <__utility/forward.h> +#include <__utility/priority_tag.h> +#include <type_traits> + +#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) + +// [cmp.alg] +namespace __compare_weak_order_fallback { + struct __fn { + template<class _Tp, class _Up> + requires is_same_v<decay_t<_Tp>, decay_t<_Up>> + _LIBCPP_HIDE_FROM_ABI static constexpr auto + __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) + noexcept(noexcept(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) + -> decltype( _VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))) + { return _VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } + + template<class _Tp, class _Up> + requires is_same_v<decay_t<_Tp>, decay_t<_Up>> + _LIBCPP_HIDE_FROM_ABI static constexpr auto + __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) + noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent : + _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less : + weak_ordering::greater)) + -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent : + _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less : + weak_ordering::greater) + { + return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent : + _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less : + weak_ordering::greater; + } + + template<class _Tp, class _Up> + _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))) + -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())) + { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); } + }; +} // namespace __compare_weak_order_fallback + +inline namespace __cpo { + inline constexpr auto compare_weak_order_fallback = __compare_weak_order_fallback::__fn{}; +} // namespace __cpo + +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK diff --git a/contrib/llvm-project/libcxx/include/__concepts/swappable.h b/contrib/llvm-project/libcxx/include/__concepts/swappable.h index 423b3a89fa40..d45249738535 100644 --- a/contrib/llvm-project/libcxx/include/__concepts/swappable.h +++ b/contrib/llvm-project/libcxx/include/__concepts/swappable.h @@ -28,13 +28,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.swappable] -namespace ranges::__swap { - // Deleted to inhibit ADL + +namespace ranges { +namespace __swap { + template<class _Tp> void swap(_Tp&, _Tp&) = delete; - - // [1] template<class _Tp, class _Up> concept __unqualified_swappable_with = (__class_or_enum<remove_cvref_t<_Tp>> || __class_or_enum<remove_cvref_t<_Up>>) && @@ -89,11 +89,12 @@ namespace ranges::__swap { __y = _VSTD::exchange(__x, _VSTD::move(__y)); } }; -} // namespace ranges::__swap +} // namespace __swap -namespace ranges::inline __cpo { +inline namespace __cpo { inline constexpr auto swap = __swap::__fn{}; -} // namespace ranges::__cpo +} // namespace __cpo +} // namespace ranges template<class _Tp> concept swappable = requires(_Tp& __a, _Tp& __b) { ranges::swap(__a, __b); }; diff --git a/contrib/llvm-project/libcxx/include/__config b/contrib/llvm-project/libcxx/include/__config index b99cdc38dc9f..3c3d4b57c76e 100644 --- a/contrib/llvm-project/libcxx/include/__config +++ b/contrib/llvm-project/libcxx/include/__config @@ -821,10 +821,10 @@ typedef __char32_t char32_t; // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { #define _LIBCPP_END_NAMESPACE_STD } } -#define _VSTD std::_LIBCPP_ABI_NAMESPACE +#define _VSTD std _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 17 +#if _LIBCPP_STD_VER > 14 #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { #else @@ -875,14 +875,10 @@ typedef unsigned int char32_t; # define _LIBCPP_CONSTEVAL consteval #endif -#if !defined(__cpp_concepts) || __cpp_concepts < 201907L +#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_concepts) || __cpp_concepts < 201907L #define _LIBCPP_HAS_NO_CONCEPTS #endif -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_HAS_NO_CONCEPTS) -#define _LIBCPP_HAS_NO_RANGES -#endif - #ifdef __GNUC__ # define _LIBCPP_NOALIAS __attribute__((__malloc__)) #else @@ -1258,8 +1254,9 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( # if defined(__clang__) && __has_attribute(acquire_capability) // Work around the attribute handling in clang. When both __declspec and // __attribute__ are present, the processing goes awry preventing the definition -// of the types. -# if !defined(_LIBCPP_OBJECT_FORMAT_COFF) +// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus +// combining the two does work. +# if !defined(_MSC_VER) # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS # endif # endif diff --git a/contrib/llvm-project/libcxx/include/__filesystem/directory_iterator.h b/contrib/llvm-project/libcxx/include/__filesystem/directory_iterator.h index 7ea66bbc7ff0..1cb1794efdae 100644 --- a/contrib/llvm-project/libcxx/include/__filesystem/directory_iterator.h +++ b/contrib/llvm-project/libcxx/include/__filesystem/directory_iterator.h @@ -133,7 +133,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_POP _LIBCPP_END_NAMESPACE_FILESYSTEM -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template <> _LIBCPP_AVAILABILITY_FILESYSTEM diff --git a/contrib/llvm-project/libcxx/include/__filesystem/recursive_directory_iterator.h b/contrib/llvm-project/libcxx/include/__filesystem/recursive_directory_iterator.h index db7e793e8530..c26d0a381159 100644 --- a/contrib/llvm-project/libcxx/include/__filesystem/recursive_directory_iterator.h +++ b/contrib/llvm-project/libcxx/include/__filesystem/recursive_directory_iterator.h @@ -164,7 +164,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_POP _LIBCPP_END_NAMESPACE_FILESYSTEM -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template <> _LIBCPP_AVAILABILITY_FILESYSTEM diff --git a/contrib/llvm-project/libcxx/include/__format/format_arg.h b/contrib/llvm-project/libcxx/include/__format/format_arg.h index da829d52fbfe..e76b0dd50d3c 100644 --- a/contrib/llvm-project/libcxx/include/__format/format_arg.h +++ b/contrib/llvm-project/libcxx/include/__format/format_arg.h @@ -140,13 +140,12 @@ private: // shall be well-formed when treated as an unevaluated operand. template <class _Ctx, class... _Args> - _LIBCPP_HIDE_FROM_ABI - _LIBCPP_AVAILABILITY_FORMAT friend __format_arg_store<_Ctx, _Args...> - _VSTD::make_format_args(const _Args&...); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend __format_arg_store<_Ctx, _Args...> + make_format_args(const _Args&...); template <class _Visitor, class _Ctx> _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend decltype(auto) - _VSTD::visit_format_arg(_Visitor&& __vis, basic_format_arg<_Ctx> __arg); + visit_format_arg(_Visitor&& __vis, basic_format_arg<_Ctx> __arg); union { bool __boolean; diff --git a/contrib/llvm-project/libcxx/include/__format/format_context.h b/contrib/llvm-project/libcxx/include/__format/format_context.h index f8ec7c8eb001..570bf7e90d9f 100644 --- a/contrib/llvm-project/libcxx/include/__format/format_context.h +++ b/contrib/llvm-project/libcxx/include/__format/format_context.h @@ -132,9 +132,8 @@ private: template <class __OutIt, class __CharT> friend _LIBCPP_HIDE_FROM_ABI basic_format_context<__OutIt, __CharT> - _VSTD::__format_context_create( - __OutIt, basic_format_args<basic_format_context<__OutIt, __CharT>>, - optional<_VSTD::locale>&&); + __format_context_create(__OutIt, basic_format_args<basic_format_context<__OutIt, __CharT>>, + optional<_VSTD::locale>&&); // Note: the Standard doesn't specify the required constructors. _LIBCPP_HIDE_FROM_ABI @@ -146,8 +145,7 @@ private: #else template <class __OutIt, class __CharT> friend _LIBCPP_HIDE_FROM_ABI basic_format_context<__OutIt, __CharT> - _VSTD::__format_context_create( - __OutIt, basic_format_args<basic_format_context<__OutIt, __CharT>>); + __format_context_create(__OutIt, basic_format_args<basic_format_context<__OutIt, __CharT>>); _LIBCPP_HIDE_FROM_ABI explicit basic_format_context(_OutIt __out_it, diff --git a/contrib/llvm-project/libcxx/include/__functional/function.h b/contrib/llvm-project/libcxx/include/__functional/function.h index b6d383ce8459..6bb7eb7e8a24 100644 --- a/contrib/llvm-project/libcxx/include/__functional/function.h +++ b/contrib/llvm-project/libcxx/include/__functional/function.h @@ -1664,7 +1664,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const #endif // _LIBCPP_NO_RTTI -} // __function +} // namespace __function template<class _Rp> class _LIBCPP_TEMPLATE_VIS function<_Rp()> diff --git a/contrib/llvm-project/libcxx/include/__functional/ranges_operations.h b/contrib/llvm-project/libcxx/include/__functional/ranges_operations.h index 777c53525102..8b06240e46a7 100644 --- a/contrib/llvm-project/libcxx/include/__functional/ranges_operations.h +++ b/contrib/llvm-project/libcxx/include/__functional/ranges_operations.h @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { struct equal_to { @@ -90,7 +90,7 @@ struct greater_equal { }; } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/advance.h b/contrib/llvm-project/libcxx/include/__iterator/advance.h index 03418979ddbd..5b0e97d76be9 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/advance.h +++ b/contrib/llvm-project/libcxx/include/__iterator/advance.h @@ -64,7 +64,7 @@ void advance(_InputIter& __i, _Distance __orig_n) { _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); } -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [range.iter.op.advance] @@ -192,7 +192,7 @@ inline namespace __cpo { } // namespace __cpo } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/common_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/common_iterator.h index 605071d70928..68309ee08b30 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/common_iterator.h +++ b/contrib/llvm-project/libcxx/include/__iterator/common_iterator.h @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template<class _Iter> concept __can_use_postfix_proxy = @@ -276,7 +276,7 @@ struct iterator_traits<common_iterator<_Iter, _Sent>> { using reference = iter_reference_t<_Iter>; }; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/concepts.h b/contrib/llvm-project/libcxx/include/__iterator/concepts.h index d7a666743afb..f6d092c75d48 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/concepts.h +++ b/contrib/llvm-project/libcxx/include/__iterator/concepts.h @@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [iterator.concept.readable] template<class _In> @@ -257,7 +257,7 @@ concept indirectly_movable_storable = // Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle // (both iter_swap and indirectly_swappable require indirectly_readable). -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/counted_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/counted_iterator.h index 82d7adcfb02e..aaab3ac77777 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/counted_iterator.h +++ b/contrib/llvm-project/libcxx/include/__iterator/counted_iterator.h @@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template<class> struct __counted_iterator_concept {}; @@ -296,7 +296,7 @@ struct iterator_traits<counted_iterator<_Iter>> : iterator_traits<_Iter> { add_pointer_t<iter_reference_t<_Iter>>, void>; }; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/default_sentinel.h b/contrib/llvm-project/libcxx/include/__iterator/default_sentinel.h index 7172a748febc..e12a5909ccf7 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/default_sentinel.h +++ b/contrib/llvm-project/libcxx/include/__iterator/default_sentinel.h @@ -18,12 +18,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) struct default_sentinel_t { }; inline constexpr default_sentinel_t default_sentinel{}; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/distance.h b/contrib/llvm-project/libcxx/include/__iterator/distance.h index 70e8e52398f9..faab03492389 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/distance.h +++ b/contrib/llvm-project/libcxx/include/__iterator/distance.h @@ -11,7 +11,13 @@ #define _LIBCPP___ITERATOR_DISTANCE_H #include <__config> +#include <__iterator/concepts.h> +#include <__iterator/incrementable_traits.h> #include <__iterator/iterator_traits.h> +#include <__ranges/access.h> +#include <__ranges/concepts.h> +#include <__ranges/size.h> +#include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -46,6 +52,56 @@ distance(_InputIter __first, _InputIter __last) return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); } +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) + +// [range.iter.op.distance] + +namespace ranges { +namespace __distance { + +struct __fn { + template<class _Ip, sentinel_for<_Ip> _Sp> + requires (!sized_sentinel_for<_Sp, _Ip>) + _LIBCPP_HIDE_FROM_ABI + constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const { + iter_difference_t<_Ip> __n = 0; + while (__first != __last) { + ++__first; + ++__n; + } + return __n; + } + + template<class _Ip, sized_sentinel_for<decay_t<_Ip>> _Sp> + _LIBCPP_HIDE_FROM_ABI + constexpr iter_difference_t<_Ip> operator()(_Ip&& __first, _Sp __last) const { + if constexpr (sized_sentinel_for<_Sp, __uncvref_t<_Ip>>) { + return __last - __first; + } else { + return __last - decay_t<_Ip>(__first); + } + } + + template<range _Rp> + _LIBCPP_HIDE_FROM_ABI + constexpr range_difference_t<_Rp> operator()(_Rp&& __r) const { + if constexpr (sized_range<_Rp>) { + return static_cast<range_difference_t<_Rp>>(ranges::size(__r)); + } else { + return operator()(ranges::begin(__r), ranges::end(__r)); + } + } +}; + +} // namespace __distance + +inline namespace __cpo { + inline constexpr auto distance = __distance::__fn{}; +} // namespace __cpo +} // namespace ranges + +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___ITERATOR_DISTANCE_H diff --git a/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h b/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h index fd5015ddf1b1..3b68acc9bc51 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h +++ b/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [incrementable.traits] template<class> struct incrementable_traits {}; @@ -65,7 +65,7 @@ using iter_difference_t = typename conditional_t<__is_primary_template<iterator_ incrementable_traits<remove_cvref_t<_Ip> >, iterator_traits<remove_cvref_t<_Ip> > >::difference_type; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/indirectly_comparable.h b/contrib/llvm-project/libcxx/include/__iterator/indirectly_comparable.h index 3129b2dcf65e..3bafc56f926f 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/indirectly_comparable.h +++ b/contrib/llvm-project/libcxx/include/__iterator/indirectly_comparable.h @@ -17,13 +17,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_HAS_NO_RANGES +#ifndef _LIBCPP_HAS_NO_CONCEPTS template <class _I1, class _I2, class _Rp, class _P1 = identity, class _P2 = identity> concept indirectly_comparable = indirect_binary_predicate<_Rp, projected<_I1, _P1>, projected<_I2, _P2>>; -#endif // _LIBCPP_HAS_NO_RANGES +#endif // _LIBCPP_HAS_NO_CONCEPTS _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/insert_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/insert_iterator.h index 33117419881b..2f18f5f12162 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/insert_iterator.h +++ b/contrib/llvm-project/libcxx/include/__iterator/insert_iterator.h @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) template <class _Container> using __insert_iterator_iter_t = ranges::iterator_t<_Container>; #else diff --git a/contrib/llvm-project/libcxx/include/__iterator/iter_move.h b/contrib/llvm-project/libcxx/include/__iterator/iter_move.h index a2951f764b0c..dfcf8e6c8308 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/iter_move.h +++ b/contrib/llvm-project/libcxx/include/__iterator/iter_move.h @@ -23,15 +23,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) + +// [iterator.cust.move] + +namespace ranges { +namespace __iter_move { -namespace ranges::__iter_move { void iter_move(); -template<class _Ip> -concept __unqualified_iter_move = requires(_Ip&& __i) { - iter_move(_VSTD::forward<_Ip>(__i)); -}; +template <class _Tp> +concept __unqualified_iter_move = + __class_or_enum<remove_cvref_t<_Tp>> && + requires (_Tp&& __t) { + iter_move(_VSTD::forward<_Tp>(__t)); + }; // [iterator.cust.move]/1 // The name ranges::iter_move denotes a customization point object. @@ -69,17 +75,18 @@ struct __fn { // [iterator.cust.move]/1.3 // Otherwise, ranges::iter_move(E) is ill-formed. }; -} // namespace ranges::__iter_move +} // namespace __iter_move -namespace ranges::inline __cpo { +inline namespace __cpo { inline constexpr auto iter_move = __iter_move::__fn{}; -} +} // namespace __cpo +} // namespace ranges template<__dereferenceable _Tp> -requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; } + requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; } using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>())); -#endif // !_LIBCPP_HAS_NO_RANGES +#endif // !_LIBCPP_HAS_NO_CONCEPTS _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/iter_swap.h b/contrib/llvm-project/libcxx/include/__iterator/iter_swap.h index a6c3bc8c663e..0179546667b7 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/iter_swap.h +++ b/contrib/llvm-project/libcxx/include/__iterator/iter_swap.h @@ -26,7 +26,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) + +// [iter.cust.swap] namespace ranges { namespace __iter_swap { @@ -34,9 +36,11 @@ namespace __iter_swap { void iter_swap(_I1, _I2) = delete; template<class _T1, class _T2> - concept __unqualified_iter_swap = requires(_T1&& __x, _T2&& __y) { - iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)); - }; + concept __unqualified_iter_swap = + (__class_or_enum<remove_cvref_t<_T1>> || __class_or_enum<remove_cvref_t<_T2>>) && + requires (_T1&& __x, _T2&& __y) { + iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)); + }; template<class _T1, class _T2> concept __readable_swappable = @@ -79,12 +83,11 @@ namespace __iter_swap { *_VSTD::forward<_T1>(__x) = _VSTD::move(__old); } }; -} // end namespace __iter_swap +} // namespace __iter_swap inline namespace __cpo { inline constexpr auto iter_swap = __iter_swap::__fn{}; } // namespace __cpo - } // namespace ranges template<class _I1, class _I2 = _I1> @@ -97,7 +100,7 @@ concept indirectly_swappable = ranges::iter_swap(__i2, __i1); }; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h b/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h index 54c3e11e6738..f2dbb7c700ec 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h +++ b/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template <class _Tp> using __with_reference = _Tp&; @@ -41,7 +41,7 @@ concept __dereferenceable = requires(_Tp& __t) { template<__dereferenceable _Tp> using iter_reference_t = decltype(*declval<_Tp&>()); -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) template <class _Iter> struct _LIBCPP_TEMPLATE_VIS iterator_traits; @@ -139,7 +139,7 @@ public: static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; }; -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // The `cpp17-*-iterator` exposition-only concepts are easily confused with the Cpp17*Iterator tables, // so they've been banished to a namespace that makes it obvious they have a niche use-case. @@ -362,7 +362,7 @@ struct iterator_traits : __iterator_traits<_Ip> { using __primary_template = iterator_traits; }; -#else // !defined(_LIBCPP_HAS_NO_RANGES) +#else // !defined(_LIBCPP_HAS_NO_CONCEPTS) template <class _Iter, bool> struct __iterator_traits {}; @@ -399,10 +399,10 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits using __primary_template = iterator_traits; }; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) template<class _Tp> -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) requires is_object_v<_Tp> #endif struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> diff --git a/contrib/llvm-project/libcxx/include/__iterator/next.h b/contrib/llvm-project/libcxx/include/__iterator/next.h index b9bdd6b27e05..8683e2210e95 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/next.h +++ b/contrib/llvm-project/libcxx/include/__iterator/next.h @@ -35,7 +35,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 return __x; } -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [range.iter.op.next] @@ -79,7 +79,7 @@ inline namespace __cpo { } // namespace __cpo } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/prev.h b/contrib/llvm-project/libcxx/include/__iterator/prev.h index 870cbe64eaee..5a58dc0e4b43 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/prev.h +++ b/contrib/llvm-project/libcxx/include/__iterator/prev.h @@ -34,7 +34,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 return __x; } -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [range.iter.op.prev] @@ -71,7 +71,7 @@ inline namespace __cpo { } // namespace __cpo } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/projected.h b/contrib/llvm-project/libcxx/include/__iterator/projected.h index c24c86b4e06e..30ea3a124b2c 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/projected.h +++ b/contrib/llvm-project/libcxx/include/__iterator/projected.h @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template<indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj> struct projected { @@ -33,7 +33,7 @@ struct incrementable_traits<projected<_It, _Proj>> { using difference_type = iter_difference_t<_It>; }; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/readable_traits.h b/contrib/llvm-project/libcxx/include/__iterator/readable_traits.h index 13f323e295ba..c0b16bafd784 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/readable_traits.h +++ b/contrib/llvm-project/libcxx/include/__iterator/readable_traits.h @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [readable.traits] template<class> struct __cond_value_type {}; @@ -79,7 +79,7 @@ using iter_value_t = typename conditional_t<__is_primary_template<iterator_trait indirectly_readable_traits<remove_cvref_t<_Ip> >, iterator_traits<remove_cvref_t<_Ip> > >::value_type; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__iterator/unreachable_sentinel.h b/contrib/llvm-project/libcxx/include/__iterator/unreachable_sentinel.h index cbbccd7bb288..b200236d8b9d 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/unreachable_sentinel.h +++ b/contrib/llvm-project/libcxx/include/__iterator/unreachable_sentinel.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) struct unreachable_sentinel_t { template<weakly_incrementable _Iter> @@ -31,7 +31,7 @@ struct unreachable_sentinel_t { inline constexpr unreachable_sentinel_t unreachable_sentinel{}; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__locale b/contrib/llvm-project/libcxx/include/__locale index 98445bd2d8f4..51f35eece712 100644 --- a/contrib/llvm-project/libcxx/include/__locale +++ b/contrib/llvm-project/libcxx/include/__locale @@ -452,7 +452,7 @@ public: static const mask punct = _PUNCT; static const mask xdigit = _HEX; static const mask blank = _BLANK; - static const mask __regex_word = 0x80; + static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) # ifdef __APPLE__ @@ -545,6 +545,12 @@ public: static const mask graph = alnum | punct; _LIBCPP_INLINE_VISIBILITY ctype_base() {} + +// TODO: Remove the ifndef when the assert no longer fails on AIX. +#ifndef _AIX + static_assert((__regex_word & ~(space | print | cntrl | upper | lower | alpha | digit | punct | xdigit | blank)) == __regex_word, + "__regex_word can't overlap other bits"); +#endif }; template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype; diff --git a/contrib/llvm-project/libcxx/include/__memory/concepts.h b/contrib/llvm-project/libcxx/include/__memory/concepts.h index 4029b590fe8c..dced563f38b6 100644 --- a/contrib/llvm-project/libcxx/include/__memory/concepts.h +++ b/contrib/llvm-project/libcxx/include/__memory/concepts.h @@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { // [special.mem.concepts] @@ -59,7 +59,7 @@ concept __nothrow_forward_range = __nothrow_forward_iterator<iterator_t<_Rp>>; } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__memory/ranges_construct_at.h b/contrib/llvm-project/libcxx/include/__memory/ranges_construct_at.h index 1a72da739682..b1821c8cc29e 100644 --- a/contrib/llvm-project/libcxx/include/__memory/ranges_construct_at.h +++ b/contrib/llvm-project/libcxx/include/__memory/ranges_construct_at.h @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { // construct_at @@ -117,7 +117,7 @@ inline namespace __cpo { } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__memory/ranges_uninitialized_algorithms.h b/contrib/llvm-project/libcxx/include/__memory/ranges_uninitialized_algorithms.h index 6a8f9f070ed7..70d901a5ad03 100644 --- a/contrib/llvm-project/libcxx/include/__memory/ranges_uninitialized_algorithms.h +++ b/contrib/llvm-project/libcxx/include/__memory/ranges_uninitialized_algorithms.h @@ -32,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { // uninitialized_default_construct @@ -309,7 +309,7 @@ inline namespace __cpo { } // namespace __cpo } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/access.h b/contrib/llvm-project/libcxx/include/__ranges/access.h index 0b9470fa4017..67c6c57bd81e 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/access.h +++ b/contrib/llvm-project/libcxx/include/__ranges/access.h @@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template <class _Tp> @@ -83,7 +83,7 @@ namespace __begin { void operator()(auto&&) const = delete; }; -} +} // namespace __begin inline namespace __cpo { inline constexpr auto begin = __begin::__fn{}; @@ -150,7 +150,7 @@ namespace __end { void operator()(auto&&) const = delete; }; -} +} // namespace __end inline namespace __cpo { inline constexpr auto end = __end::__fn{}; @@ -178,7 +178,7 @@ namespace __cbegin { -> decltype( ranges::begin(static_cast<const _Tp&&>(__t))) { return ranges::begin(static_cast<const _Tp&&>(__t)); } }; -} +} // namespace __cbegin inline namespace __cpo { inline constexpr auto cbegin = __cbegin::__fn{}; @@ -206,14 +206,14 @@ namespace __cend { -> decltype( ranges::end(static_cast<const _Tp&&>(__t))) { return ranges::end(static_cast<const _Tp&&>(__t)); } }; -} +} // namespace __cend inline namespace __cpo { inline constexpr auto cend = __cend::__fn{}; } // namespace __cpo } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/all.h b/contrib/llvm-project/libcxx/include/__ranges/all.h index 90327da81460..b0a58e9bad82 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/all.h +++ b/contrib/llvm-project/libcxx/include/__ranges/all.h @@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges::views { @@ -64,7 +64,7 @@ namespace __all { return ranges::owning_view{_VSTD::forward<_Tp>(__t)}; } }; -} +} // namespace __all inline namespace __cpo { inline constexpr auto all = __all::__fn{}; @@ -75,7 +75,7 @@ using all_t = decltype(views::all(declval<_Range>())); } // namespace ranges::views -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/common_view.h b/contrib/llvm-project/libcxx/include/__ranges/common_view.h index a58554f66e50..fb8078d65558 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/common_view.h +++ b/contrib/llvm-project/libcxx/include/__ranges/common_view.h @@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { @@ -120,15 +120,15 @@ namespace __common { -> decltype( common_view{_VSTD::forward<_Range>(__range)}) { return common_view{_VSTD::forward<_Range>(__range)}; } }; -} +} // namespace __common inline namespace __cpo { inline constexpr auto common = __common::__fn{}; -} +} // namespace __cpo } // namespace views } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/concepts.h b/contrib/llvm-project/libcxx/include/__ranges/concepts.h index a9cb15f9f17c..0590863138ed 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/concepts.h +++ b/contrib/llvm-project/libcxx/include/__ranges/concepts.h @@ -32,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { // [range.range] @@ -133,7 +133,7 @@ namespace ranges { } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/copyable_box.h b/contrib/llvm-project/libcxx/include/__ranges/copyable_box.h index 4811690adaec..608db55dbc5f 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/copyable_box.h +++ b/contrib/llvm-project/libcxx/include/__ranges/copyable_box.h @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // __copyable_box allows turning a type that is copy-constructible (but maybe not copy-assignable) into // a type that is both copy-constructible and copy-assignable. It does that by introducing an empty state @@ -171,7 +171,7 @@ namespace ranges { }; } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/counted.h b/contrib/llvm-project/libcxx/include/__ranges/counted.h index cb9784092420..92bcf06be3ad 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/counted.h +++ b/contrib/llvm-project/libcxx/include/__ranges/counted.h @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges::views { @@ -74,7 +74,7 @@ inline namespace __cpo { } // namespace ranges::views -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/dangling.h b/contrib/llvm-project/libcxx/include/__ranges/dangling.h index 45ff83b205e5..b6b733a6eaa9 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/dangling.h +++ b/contrib/llvm-project/libcxx/include/__ranges/dangling.h @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { struct dangling { @@ -35,7 +35,7 @@ using borrowed_iterator_t = _If<borrowed_range<_Rp>, iterator_t<_Rp>, dangling>; // borrowed_subrange_t defined in <__ranges/subrange.h> } // namespace ranges -#endif // !_LIBCPP_HAS_NO_RANGES +#endif // !_LIBCPP_HAS_NO_CONCEPTS _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/data.h b/contrib/llvm-project/libcxx/include/__ranges/data.h index 69dfd479c011..f97ec8033297 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/data.h +++ b/contrib/llvm-project/libcxx/include/__ranges/data.h @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [range.prim.data] @@ -64,7 +64,7 @@ namespace __data { return _VSTD::to_address(ranges::begin(__t)); } }; -} +} // namespace __data inline namespace __cpo { inline constexpr auto data = __data::__fn{}; @@ -92,14 +92,14 @@ namespace __cdata { -> decltype( ranges::data(static_cast<const _Tp&&>(__t))) { return ranges::data(static_cast<const _Tp&&>(__t)); } }; -} +} // namespace __cdata inline namespace __cpo { inline constexpr auto cdata = __cdata::__fn{}; } // namespace __cpo } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/drop_view.h b/contrib/llvm-project/libcxx/include/__ranges/drop_view.h index 6adb09cf677e..1e2bfa40b325 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/drop_view.h +++ b/contrib/llvm-project/libcxx/include/__ranges/drop_view.h @@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template<view _View> @@ -120,7 +120,7 @@ public: inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>; } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/empty.h b/contrib/llvm-project/libcxx/include/__ranges/empty.h index 8da0b120f182..b06a81c98e8f 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/empty.h +++ b/contrib/llvm-project/libcxx/include/__ranges/empty.h @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [range.prim.empty] @@ -68,14 +68,14 @@ namespace __empty { return ranges::begin(__t) == ranges::end(__t); } }; -} +} // namespace __empty inline namespace __cpo { inline constexpr auto empty = __empty::__fn{}; } // namespace __cpo } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/empty_view.h b/contrib/llvm-project/libcxx/include/__ranges/empty_view.h index f744dcbe92f4..e0116b933797 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/empty_view.h +++ b/contrib/llvm-project/libcxx/include/__ranges/empty_view.h @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template<class _Tp> @@ -38,7 +38,7 @@ namespace ranges { inline constexpr bool enable_borrowed_range<empty_view<_Tp>> = true; } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/enable_borrowed_range.h b/contrib/llvm-project/libcxx/include/__ranges/enable_borrowed_range.h index 20b1d42b26c8..5f5b3f505773 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/enable_borrowed_range.h +++ b/contrib/llvm-project/libcxx/include/__ranges/enable_borrowed_range.h @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { @@ -34,7 +34,7 @@ inline constexpr bool enable_borrowed_range = false; } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/enable_view.h b/contrib/llvm-project/libcxx/include/__ranges/enable_view.h index e1daec046fc0..87d53f3fcc8c 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/enable_view.h +++ b/contrib/llvm-project/libcxx/include/__ranges/enable_view.h @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { @@ -38,9 +38,9 @@ template <class _Tp> inline constexpr bool enable_view = derived_from<_Tp, view_base> || requires { ranges::__is_derived_from_view_interface((_Tp*)nullptr, (_Tp*)nullptr); }; -} // end namespace ranges +} // namespace ranges -#endif // !_LIBCPP_HAS_NO_RANGES +#endif // !_LIBCPP_HAS_NO_CONCEPTS _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/iota_view.h b/contrib/llvm-project/libcxx/include/__ranges/iota_view.h index da712b8e6f4f..17f6021f7dd4 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/iota_view.h +++ b/contrib/llvm-project/libcxx/include/__ranges/iota_view.h @@ -39,7 +39,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template<class _Int> @@ -397,11 +397,11 @@ namespace __iota { inline namespace __cpo { inline constexpr auto iota = __iota::__fn{}; -} +} // namespace __cpo } // namespace views } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/join_view.h b/contrib/llvm-project/libcxx/include/__ranges/join_view.h index 9aa69da76cf0..7efbcfdf8788 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/join_view.h +++ b/contrib/llvm-project/libcxx/include/__ranges/join_view.h @@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template<class> @@ -343,7 +343,7 @@ namespace ranges { #undef _CONSTEXPR_TERNARY -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/non_propagating_cache.h b/contrib/llvm-project/libcxx/include/__ranges/non_propagating_cache.h index 456e08d8c971..d0f447ce7cc5 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/non_propagating_cache.h +++ b/contrib/llvm-project/libcxx/include/__ranges/non_propagating_cache.h @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { // __non_propagating_cache is a helper type that allows storing an optional value in it, @@ -107,7 +107,7 @@ namespace ranges { struct __empty_cache { }; } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/owning_view.h b/contrib/llvm-project/libcxx/include/__ranges/owning_view.h index 29182d2d8e46..9c038cbd7580 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/owning_view.h +++ b/contrib/llvm-project/libcxx/include/__ranges/owning_view.h @@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template<range _Rp> @@ -74,7 +74,7 @@ public: } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/range_adaptor.h b/contrib/llvm-project/libcxx/include/__ranges/range_adaptor.h index 74aea3187e89..d037585d2679 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/range_adaptor.h +++ b/contrib/llvm-project/libcxx/include/__ranges/range_adaptor.h @@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // CRTP base that one can derive from in order to be considered a range adaptor closure // by the library. When deriving from this class, a pipe operator will be provided to @@ -66,7 +66,7 @@ struct __range_adaptor_closure { { return __range_adaptor_closure_t(_VSTD::__compose(_VSTD::forward<_OtherClosure>(__c2), _VSTD::forward<_Closure>(__c1))); } }; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/ref_view.h b/contrib/llvm-project/libcxx/include/__ranges/ref_view.h index 283fa2599bff..4d12759e614f 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/ref_view.h +++ b/contrib/llvm-project/libcxx/include/__ranges/ref_view.h @@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template<range _Range> @@ -79,7 +79,7 @@ public: inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true; } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/reverse_view.h b/contrib/llvm-project/libcxx/include/__ranges/reverse_view.h index 618be80457b6..04ac7f29aa7c 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/reverse_view.h +++ b/contrib/llvm-project/libcxx/include/__ranges/reverse_view.h @@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template<view _View> @@ -175,15 +175,15 @@ namespace ranges { -> decltype( reverse_view{_VSTD::forward<_Range>(__range)}) { return reverse_view{_VSTD::forward<_Range>(__range)}; } }; - } + } // namespace __reverse inline namespace __cpo { inline constexpr auto reverse = __reverse::__fn{}; - } + } // namespace __cpo } // namespace views } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/single_view.h b/contrib/llvm-project/libcxx/include/__ranges/single_view.h index 931ce78da7b9..c6f0746ea795 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/single_view.h +++ b/contrib/llvm-project/libcxx/include/__ranges/single_view.h @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template<copy_constructible _Tp> @@ -74,7 +74,7 @@ namespace ranges { single_view(_Tp) -> single_view<_Tp>; } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/size.h b/contrib/llvm-project/libcxx/include/__ranges/size.h index f3de5a8b8410..e1aaf7eba898 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/size.h +++ b/contrib/llvm-project/libcxx/include/__ranges/size.h @@ -24,12 +24,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template<class> inline constexpr bool disable_sized_range = false; -} +} // namespace ranges // [range.prim.size] @@ -97,7 +97,7 @@ namespace __size { return _VSTD::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t)); } }; -} +} // namespace __size inline namespace __cpo { inline constexpr auto size = __size::__fn{}; @@ -121,14 +121,14 @@ namespace __ssize { return static_cast<_Signed>(ranges::size(__t)); } }; -} +} // namespace __ssize inline namespace __cpo { inline constexpr auto ssize = __ssize::__fn{}; } // namespace __cpo } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/subrange.h b/contrib/llvm-project/libcxx/include/__ranges/subrange.h index 14716d1fb0ff..c6977cec3672 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/subrange.h +++ b/contrib/llvm-project/libcxx/include/__ranges/subrange.h @@ -36,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template<class _From, class _To> @@ -227,7 +227,7 @@ namespace ranges { -> subrange<iterator_t<_Range>, sentinel_t<_Range>, subrange_kind::sized>; template<size_t _Index, class _Iter, class _Sent, subrange_kind _Kind> - requires (_Index < 2) + requires ((_Index == 0 && copyable<_Iter>) || _Index == 1) _LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>& __subrange) { if constexpr (_Index == 0) @@ -282,7 +282,7 @@ struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> { using type = _Sp; }; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/take_view.h b/contrib/llvm-project/libcxx/include/__ranges/take_view.h index 73a57fe96c08..4d45219020da 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/take_view.h +++ b/contrib/llvm-project/libcxx/include/__ranges/take_view.h @@ -34,7 +34,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template<view _View> @@ -176,7 +176,7 @@ public: inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>; } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/transform_view.h b/contrib/llvm-project/libcxx/include/__ranges/transform_view.h index 1506e8b2a7fe..d39dd4097290 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/transform_view.h +++ b/contrib/llvm-project/libcxx/include/__ranges/transform_view.h @@ -20,7 +20,6 @@ #include <__functional/bind_back.h> #include <__functional/invoke.h> #include <__iterator/concepts.h> -#include <__iterator/iter_swap.h> #include <__iterator/iterator_traits.h> #include <__memory/addressof.h> #include <__ranges/access.h> @@ -42,7 +41,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { @@ -425,16 +424,16 @@ namespace __transform { noexcept(is_nothrow_constructible_v<decay_t<_Fn>, _Fn>) { return __range_adaptor_closure_t(_VSTD::__bind_back(*this, _VSTD::forward<_Fn>(__f))); } }; -} +} // namespace __transform inline namespace __cpo { inline constexpr auto transform = __transform::__fn{}; -} +} // namespace __cpo } // namespace views } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__ranges/view_interface.h b/contrib/llvm-project/libcxx/include/__ranges/view_interface.h index c5215cbcb8e3..0a37323df817 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/view_interface.h +++ b/contrib/llvm-project/libcxx/include/__ranges/view_interface.h @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { @@ -186,9 +186,9 @@ public: } }; -} +} // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/algorithm b/contrib/llvm-project/libcxx/include/algorithm index 03b4faaee284..e5f1030be201 100644 --- a/contrib/llvm-project/libcxx/include/algorithm +++ b/contrib/llvm-project/libcxx/include/algorithm @@ -20,7 +20,10 @@ namespace std namespace ranges { template <class I1, class I2> - struct in_in_result; // since C++20 + struct in_in_result; // since C++20 + + template <class I1, class I2, class O> + struct in_in_out_result; // since C++20 } template <class InputIterator, class Predicate> @@ -696,6 +699,7 @@ template<class InputIterator, class OutputIterator> #include <__algorithm/generate.h> #include <__algorithm/generate_n.h> #include <__algorithm/half_positive.h> +#include <__algorithm/in_in_out_result.h> #include <__algorithm/in_in_result.h> #include <__algorithm/in_out_result.h> #include <__algorithm/includes.h> diff --git a/contrib/llvm-project/libcxx/include/atomic b/contrib/llvm-project/libcxx/include/atomic index e1820fca351f..f3613d7bb912 100644 --- a/contrib/llvm-project/libcxx/include/atomic +++ b/contrib/llvm-project/libcxx/include/atomic @@ -2692,10 +2692,13 @@ typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>::typ typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char>::type __libcpp_unsigned_lock_free; #else // No signed/unsigned lock-free types +#define _LIBCPP_NO_LOCK_FREE_TYPES #endif +#if !defined(_LIBCPP_NO_LOCK_FREE_TYPES) typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free; typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free; +#endif #define ATOMIC_FLAG_INIT {false} #define ATOMIC_VAR_INIT(__v) {__v} diff --git a/contrib/llvm-project/libcxx/include/compare b/contrib/llvm-project/libcxx/include/compare index d686b5a369f2..287e61690bbb 100644 --- a/contrib/llvm-project/libcxx/include/compare +++ b/contrib/llvm-project/libcxx/include/compare @@ -51,9 +51,14 @@ namespace std { struct compare_three_way; // C++20 // [cmp.alg], comparison algorithms - template<class T> constexpr strong_ordering strong_order(const T& a, const T& b); - template<class T> constexpr weak_ordering weak_order(const T& a, const T& b); - template<class T> constexpr partial_ordering partial_order(const T& a, const T& b); + inline namespace unspecified { + inline constexpr unspecified strong_order = unspecified; + inline constexpr unspecified weak_order = unspecified; + inline constexpr unspecified partial_order = unspecified; + inline constexpr unspecified compare_strong_order_fallback = unspecified; + inline constexpr unspecified compare_weak_order_fallback = unspecified; + inline constexpr unspecified compare_partial_order_fallback = unspecified; + } // [cmp.partialord], Class partial_ordering class partial_ordering { @@ -136,8 +141,11 @@ namespace std { */ #include <__compare/common_comparison_category.h> +#include <__compare/compare_partial_order_fallback.h> +#include <__compare/compare_strong_order_fallback.h> #include <__compare/compare_three_way.h> #include <__compare/compare_three_way_result.h> +#include <__compare/compare_weak_order_fallback.h> #include <__compare/is_eq.h> #include <__compare/ordering.h> #include <__compare/partial_order.h> diff --git a/contrib/llvm-project/libcxx/include/cstddef b/contrib/llvm-project/libcxx/include/cstddef index ed5aea6f7a19..e77629e1ea0c 100644 --- a/contrib/llvm-project/libcxx/include/cstddef +++ b/contrib/llvm-project/libcxx/include/cstddef @@ -156,7 +156,8 @@ template <class _Integer> template <class _Integer, class = _EnableByteOverload<_Integer> > _LIBCPP_NODISCARD_EXT constexpr _Integer to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); } -} + +} // namespace std #endif diff --git a/contrib/llvm-project/libcxx/include/module.modulemap b/contrib/llvm-project/libcxx/include/module.modulemap index 90fae9bb8362..84abf01bf5d7 100644 --- a/contrib/llvm-project/libcxx/include/module.modulemap +++ b/contrib/llvm-project/libcxx/include/module.modulemap @@ -246,6 +246,7 @@ module std [system] { module generate { private header "__algorithm/generate.h" } module generate_n { private header "__algorithm/generate_n.h" } module half_positive { private header "__algorithm/half_positive.h" } + module in_in_out_result { private header "__algorithm/in_in_out_result.h" } module in_in_result { private header "__algorithm/in_in_result.h" } module in_out_result { private header "__algorithm/in_out_result.h" } module includes { private header "__algorithm/includes.h" } @@ -385,16 +386,19 @@ module std [system] { export * module __compare { - module common_comparison_category { private header "__compare/common_comparison_category.h" } - module compare_three_way { private header "__compare/compare_three_way.h" } - module compare_three_way_result { private header "__compare/compare_three_way_result.h" } - module is_eq { private header "__compare/is_eq.h" } - module ordering { private header "__compare/ordering.h" } - module partial_order { private header "__compare/partial_order.h" } - module strong_order { private header "__compare/strong_order.h" } - module synth_three_way { private header "__compare/synth_three_way.h" } - module three_way_comparable { private header "__compare/three_way_comparable.h" } - module weak_order { private header "__compare/weak_order.h" } + module common_comparison_category { private header "__compare/common_comparison_category.h" } + module compare_partial_order_fallback { private header "__compare/compare_partial_order_fallback.h" } + module compare_strong_order_fallback { private header "__compare/compare_strong_order_fallback.h" } + module compare_three_way { private header "__compare/compare_three_way.h" } + module compare_three_way_result { private header "__compare/compare_three_way_result.h" } + module compare_weak_order_fallback { private header "__compare/compare_weak_order_fallback.h" } + module is_eq { private header "__compare/is_eq.h" } + module ordering { private header "__compare/ordering.h" } + module partial_order { private header "__compare/partial_order.h" } + module strong_order { private header "__compare/strong_order.h" } + module synth_three_way { private header "__compare/synth_three_way.h" } + module three_way_comparable { private header "__compare/three_way_comparable.h" } + module weak_order { private header "__compare/weak_order.h" } } } module complex { diff --git a/contrib/llvm-project/libcxx/include/ranges b/contrib/llvm-project/libcxx/include/ranges index eb4492376c5c..f7c543d7316c 100644 --- a/contrib/llvm-project/libcxx/include/ranges +++ b/contrib/llvm-project/libcxx/include/ranges @@ -239,11 +239,11 @@ namespace std::ranges { _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace views = ranges::views; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/span b/contrib/llvm-project/libcxx/include/span index d33ad09a388f..bd11330e69d9 100644 --- a/contrib/llvm-project/libcxx/include/span +++ b/contrib/llvm-project/libcxx/include/span @@ -170,7 +170,7 @@ struct __is_std_span : false_type {}; template <class _Tp, size_t _Sz> struct __is_std_span<span<_Tp, _Sz>> : true_type {}; -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template <class _Range, class _ElementType> concept __span_compatible_range = ranges::contiguous_range<_Range> && @@ -210,7 +210,7 @@ public: constexpr span (const span&) noexcept = default; constexpr span& operator=(const span&) noexcept = default; -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template <class _It, enable_if_t<contiguous_iterator<_It> && is_convertible_v<remove_reference_t<iter_reference_t<_It>>(*)[], element_type (*)[]>, @@ -248,7 +248,7 @@ public: _LIBCPP_INLINE_VISIBILITY constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {} -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template <__span_compatible_range<element_type> _Range> _LIBCPP_INLINE_VISIBILITY constexpr explicit span(_Range&& __r) : __data{ranges::data(__r)} { @@ -401,7 +401,7 @@ public: constexpr span (const span&) noexcept = default; constexpr span& operator=(const span&) noexcept = default; -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template <class _It, enable_if_t<contiguous_iterator<_It> && is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]>, @@ -434,7 +434,7 @@ public: _LIBCPP_INLINE_VISIBILITY constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {} -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template <__span_compatible_range<element_type> _Range> _LIBCPP_INLINE_VISIBILITY constexpr span(_Range&& __r) : __data(ranges::data(__r)), __size{ranges::size(__r)} {} @@ -543,13 +543,13 @@ private: size_type __size; }; -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template <class _Tp, size_t _Extent> inline constexpr bool ranges::enable_borrowed_range<span<_Tp, _Extent> > = true; template <class _ElementType, size_t _Extent> inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) // as_bytes & as_writable_bytes template <class _Tp, size_t _Extent> @@ -564,7 +564,7 @@ auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept -> enable_if_t<!is_const_v<_Tp>, decltype(__s.__as_writable_bytes())> { return __s.__as_writable_bytes(); } -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // Deduction guides template<contiguous_iterator _It, class _EndOrSize> span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>; @@ -579,7 +579,7 @@ template<class _Tp, size_t _Sz> template<class _Tp, size_t _Sz> span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>; -#if !defined(_LIBCPP_HAS_NO_RANGES) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template<ranges::contiguous_range _Range> span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>; #endif diff --git a/contrib/llvm-project/libcxx/include/string_view b/contrib/llvm-project/libcxx/include/string_view index 3861ad67ca5d..992e88ea3c00 100644 --- a/contrib/llvm-project/libcxx/include/string_view +++ b/contrib/llvm-project/libcxx/include/string_view @@ -286,7 +286,7 @@ public: #endif } -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) template <contiguous_iterator _It, sized_sentinel_for<_It> _End> requires (is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>) constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end) @@ -296,7 +296,7 @@ public: } #endif -#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_RANGES) +#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) template <class _Range> requires ( !is_same_v<remove_cvref_t<_Range>, basic_string_view> && @@ -707,23 +707,23 @@ private: size_type __size; }; -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) template <class _CharT, class _Traits> inline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true; template <class _CharT, class _Traits> inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) // [string.view.deduct] -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) template <contiguous_iterator _It, sized_sentinel_for<_It> _End> basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>; #endif -#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_RANGES) +#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) template <ranges::contiguous_range _Range> basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>; #endif diff --git a/contrib/llvm-project/libcxx/include/variant b/contrib/llvm-project/libcxx/include/variant index 51bcd6ef4e98..21fd53729d55 100644 --- a/contrib/llvm-project/libcxx/include/variant +++ b/contrib/llvm-project/libcxx/include/variant @@ -1252,7 +1252,7 @@ template <class _Tp, class... _Types> using __best_match_t = typename invoke_result_t<_MakeOverloads<_Types...>, _Tp, _Tp>::type; -} // __variant_detail +} // namespace __variant_detail template <class... _Types> class _LIBCPP_TEMPLATE_VIS variant diff --git a/contrib/llvm-project/libcxx/src/filesystem/operations.cpp b/contrib/llvm-project/libcxx/src/filesystem/operations.cpp index 62bcfbff097f..7aeeffaae8f3 100644 --- a/contrib/llvm-project/libcxx/src/filesystem/operations.cpp +++ b/contrib/llvm-project/libcxx/src/filesystem/operations.cpp @@ -24,9 +24,10 @@ # define NOMINMAX # include <windows.h> #else -# include <unistd.h> +# include <dirent.h> # include <sys/stat.h> # include <sys/statvfs.h> +# include <unistd.h> #endif #include <time.h> #include <fcntl.h> /* values for fchmodat */ @@ -1338,6 +1339,19 @@ bool __remove(const path& p, error_code* ec) { return true; } +// We currently have two implementations of `__remove_all`. The first one is general and +// used on platforms where we don't have access to the `openat()` family of POSIX functions. +// That implementation uses `directory_iterator`, however it is vulnerable to some race +// conditions, see https://reviews.llvm.org/D118134 for details. +// +// The second implementation is used on platforms where `openat()` & friends are available, +// and it threads file descriptors through recursive calls to avoid such race conditions. +#if defined(_LIBCPP_WIN32API) +# define REMOVE_ALL_USE_DIRECTORY_ITERATOR +#endif + +#if defined(REMOVE_ALL_USE_DIRECTORY_ITERATOR) + namespace { uintmax_t remove_all_impl(path const& p, error_code& ec) { @@ -1377,6 +1391,97 @@ uintmax_t __remove_all(const path& p, error_code* ec) { return count; } +#else // !REMOVE_ALL_USE_DIRECTORY_ITERATOR + +namespace { + +template <class Cleanup> +struct scope_exit { + explicit scope_exit(Cleanup const& cleanup) + : cleanup_(cleanup) + { } + + ~scope_exit() { cleanup_(); } + +private: + Cleanup cleanup_; +}; + +uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) { + // First, try to open the path as a directory. + const int options = O_CLOEXEC | O_RDONLY | O_DIRECTORY | O_NOFOLLOW; + int fd = ::openat(parent_directory, p.c_str(), options); + if (fd != -1) { + // If that worked, iterate over the contents of the directory and + // remove everything in it, recursively. + scope_exit close_fd([=] { ::close(fd); }); + DIR* stream = ::fdopendir(fd); + if (stream == nullptr) { + ec = detail::capture_errno(); + return 0; + } + scope_exit close_stream([=] { ::closedir(stream); }); + + uintmax_t count = 0; + while (true) { + auto [str, type] = detail::posix_readdir(stream, ec); + static_assert(std::is_same_v<decltype(str), std::string_view>); + if (str == "." || str == "..") { + continue; + } else if (ec || str.empty()) { + break; // we're done iterating through the directory + } else { + count += remove_all_impl(fd, str, ec); + } + } + + // Then, remove the now-empty directory itself. + if (::unlinkat(parent_directory, p.c_str(), AT_REMOVEDIR) == -1) { + ec = detail::capture_errno(); + return count; + } + + return count + 1; // the contents of the directory + the directory itself + } + + ec = detail::capture_errno(); + + // If we failed to open `p` because it didn't exist, it's not an + // error -- it might have moved or have been deleted already. + if (ec == errc::no_such_file_or_directory) { + ec.clear(); + return 0; + } + + // If opening `p` failed because it wasn't a directory, remove it as + // a normal file instead. Note that `openat()` can return either ENOTDIR + // or ELOOP depending on the exact reason of the failure. + if (ec == errc::not_a_directory || ec == errc::too_many_symbolic_link_levels) { + ec.clear(); + if (::unlinkat(parent_directory, p.c_str(), /* flags = */0) == -1) { + ec = detail::capture_errno(); + return 0; + } + return 1; + } + + // Otherwise, it's a real error -- we don't remove anything. + return 0; +} + +} // end namespace + +uintmax_t __remove_all(const path& p, error_code* ec) { + ErrorHandler<uintmax_t> err("remove_all", ec, &p); + error_code mec; + uintmax_t count = remove_all_impl(AT_FDCWD, p, mec); + if (mec) + return err.report(mec); + return count; +} + +#endif // REMOVE_ALL_USE_DIRECTORY_ITERATOR + void __rename(const path& from, const path& to, error_code* ec) { ErrorHandler<void> err("rename", ec, &from, &to); if (detail::rename(from.c_str(), to.c_str()) == -1) |