diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2022-07-27 20:11:54 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-02-08 19:04:48 +0000 |
commit | 972a253a57b6f144b0e4a3e2080a2a0076ec55a0 (patch) | |
tree | a8aeeb0997a0a52500f1fa0644244206cf71df94 /contrib/llvm-project/libcxx | |
parent | fcaf7f8644a9988098ac6be2165bce3ea4786e91 (diff) | |
parent | 08e8dd7b9db7bb4a9de26d44c1cbfd24e869c014 (diff) | |
download | src-972a253a57b6f144b0e4a3e2080a2a0076ec55a0.tar.gz src-972a253a57b6f144b0e4a3e2080a2a0076ec55a0.zip |
Merge llvm-project main llvmorg-15-init-17826-g1f8ae9d7e7e4
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-17826-g1f8ae9d7e7e4, the last commit before
the upstream release/16.x branch was created.
PR: 265425
MFC after: 2 weeks
Diffstat (limited to 'contrib/llvm-project/libcxx')
57 files changed, 1882 insertions, 1005 deletions
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/copy.h b/contrib/llvm-project/libcxx/include/__algorithm/copy.h index 886a1ac6ce3e..5428baa68859 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/copy.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/copy.h @@ -58,20 +58,20 @@ pair<_InValueT*, _OutValueT*> __copy_impl(_InValueT* __first, _InValueT* __last, template <class _InIter, class _OutIter, __enable_if_t<is_same<typename remove_const<__iter_value_type<_InIter> >::type, __iter_value_type<_OutIter> >::value - && __is_cpp17_contiguous_iterator<_InIter>::value - && __is_cpp17_contiguous_iterator<_OutIter>::value - && is_trivially_copy_assignable<__iter_value_type<_OutIter> >::value, int> = 0> + && __is_cpp17_contiguous_iterator<typename _InIter::iterator_type>::value + && __is_cpp17_contiguous_iterator<typename _OutIter::iterator_type>::value + && is_trivially_copy_assignable<__iter_value_type<_OutIter> >::value + && __is_reverse_iterator<_InIter>::value + && __is_reverse_iterator<_OutIter>::value, int> = 0> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -pair<reverse_iterator<_InIter>, reverse_iterator<_OutIter> > -__copy_impl(reverse_iterator<_InIter> __first, - reverse_iterator<_InIter> __last, - reverse_iterator<_OutIter> __result) { +pair<_InIter, _OutIter> +__copy_impl(_InIter __first, _InIter __last, _OutIter __result) { auto __first_base = std::__unwrap_iter(__first.base()); auto __last_base = std::__unwrap_iter(__last.base()); auto __result_base = std::__unwrap_iter(__result.base()); auto __result_first = __result_base - (__first_base - __last_base); std::__copy_impl(__last_base, __first_base, __result_first); - return std::make_pair(__last, reverse_iterator<_OutIter>(std::__rewrap_iter(__result.base(), __result_first))); + return std::make_pair(__last, _OutIter(std::__rewrap_iter(__result.base(), __result_first))); } template <class _InIter, class _Sent, class _OutIter, diff --git a/contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h b/contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h index dd43a91ffa87..26b8c4d791fd 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h @@ -10,10 +10,16 @@ #define _LIBCPP___ALGORITHM_COPY_BACKWARD_H #include <__algorithm/copy.h> +#include <__algorithm/iterator_operations.h> +#include <__algorithm/ranges_copy.h> #include <__algorithm/unwrap_iter.h> +#include <__concepts/same_as.h> #include <__config> #include <__iterator/iterator_traits.h> #include <__iterator/reverse_iterator.h> +#include <__ranges/subrange.h> +#include <__utility/move.h> +#include <__utility/pair.h> #include <cstring> #include <type_traits> @@ -23,29 +29,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Iter1, class _Sent1, class _Iter2> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -pair<_Iter1, _Iter2> __copy_backward_impl(_Iter1 __first, _Sent1 __last, _Iter2 __result) { - auto __ret = std::__copy(reverse_iterator<_Iter1>(__last), - reverse_iterator<_Sent1>(__first), - reverse_iterator<_Iter2>(__result)); - return pair<_Iter1, _Iter2>(__ret.first.base(), __ret.second.base()); +template <class _AlgPolicy, class _InputIterator, class _OutputIterator, + __enable_if_t<is_same<_AlgPolicy, _ClassicAlgPolicy>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_InputIterator, _OutputIterator> +__copy_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { + auto __ret = std::__copy( + __unconstrained_reverse_iterator<_InputIterator>(__last), + __unconstrained_reverse_iterator<_InputIterator>(__first), + __unconstrained_reverse_iterator<_OutputIterator>(__result)); + return pair<_InputIterator, _OutputIterator>(__ret.first.base(), __ret.second.base()); } -template <class _Iter1, class _Sent1, class _Iter2> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -pair<_Iter1, _Iter2> __copy_backward(_Iter1 __first, _Sent1 __last, _Iter2 __result) { - auto __ret = std::__copy_backward_impl(std::__unwrap_iter(__first), - std::__unwrap_iter(__last), - std::__unwrap_iter(__result)); - return pair<_Iter1, _Iter2>(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second)); +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +template <class _AlgPolicy, class _Iter1, class _Sent1, class _Iter2, + __enable_if_t<is_same<_AlgPolicy, _RangeAlgPolicy>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter1, _Iter2> __copy_backward(_Iter1 __first, _Sent1 __last, _Iter2 __result) { + auto __reverse_range = std::__reverse_range(std::ranges::subrange(std::move(__first), std::move(__last))); + auto __ret = ranges::copy(std::move(__reverse_range), std::make_reverse_iterator(__result)); + return std::make_pair(__ret.in.base(), __ret.out.base()); } +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) template <class _BidirectionalIterator1, class _BidirectionalIterator2> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 -_BidirectionalIterator2 +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator2 copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) { - return std::__copy_backward(__first, __last, __result).second; + return std::__copy_backward<_ClassicAlgPolicy>(__first, __last, __result).second; } _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__algorithm/equal_range.h b/contrib/llvm-project/libcxx/include/__algorithm/equal_range.h index 42d009ebbc0f..b11165baf384 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/equal_range.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/equal_range.h @@ -21,6 +21,7 @@ #include <__iterator/advance.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> +#include <__iterator/next.h> #include <__type_traits/is_callable.h> #include <__type_traits/is_copy_constructible.h> #include <__utility/move.h> diff --git a/contrib/llvm-project/libcxx/include/__algorithm/includes.h b/contrib/llvm-project/libcxx/include/__algorithm/includes.h index 102d3db39a2d..c64194a2c826 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/includes.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/includes.h @@ -12,7 +12,10 @@ #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__config> +#include <__functional/identity.h> +#include <__functional/invoke.h> #include <__iterator/iterator_traits.h> +#include <__type_traits/is_callable.h> #include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -21,13 +24,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Comp> +template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Comp, class _Proj1, class _Proj2> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool -__includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Comp&& __comp) { +__includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, + _Comp&& __comp, _Proj1&& __proj1, _Proj2&& __proj2) { for (; __first2 != __last2; ++__first1) { - if (__first1 == __last1 || __comp(*__first2, *__first1)) + if (__first1 == __last1 || std::__invoke( + __comp, std::__invoke(__proj2, *__first2), std::__invoke(__proj1, *__first1))) return false; - if (!__comp(*__first1, *__first2)) + if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) ++__first2; } return true; @@ -40,9 +45,13 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { + static_assert(__is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value, + "Comparator has to be callable"); + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return std::__includes( - std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), static_cast<_Comp_ref>(__comp)); + std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), + static_cast<_Comp_ref>(__comp), __identity(), __identity()); } template <class _InputIterator1, class _InputIterator2> diff --git a/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h b/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h index f4364969b8f9..cb662e791872 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h @@ -105,8 +105,8 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator value_type* __p = __buff; for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p) ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i)); - typedef reverse_iterator<_BidirectionalIterator> _RBi; - typedef reverse_iterator<value_type*> _Rv; + typedef __unconstrained_reverse_iterator<_BidirectionalIterator> _RBi; + typedef __unconstrained_reverse_iterator<value_type*> _Rv; typedef __invert<_Compare> _Inverted; std::__half_inplace_merge<_AlgPolicy, _Inverted>(_Rv(__p), _Rv(__buff), _RBi(__middle), _RBi(__first), diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/is_heap.h index fe44e634f6dd..0d399a09b857 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/is_heap.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/is_heap.h @@ -28,7 +28,7 @@ bool is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp) == __last; + return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp)) == __last; } template<class _RandomAccessIterator> diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h b/contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h index 39f313eb0d3f..adb35af887fb 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Compare, class _RandomAccessIterator> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator -__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; difference_type __len = __last - __first; @@ -52,7 +52,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp); + return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp)); } template<class _RandomAccessIterator> diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_copy_backward.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_copy_backward.h index 49c1b26add6d..673df8025fab 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_copy_backward.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_copy_backward.h @@ -11,6 +11,7 @@ #include <__algorithm/copy_backward.h> #include <__algorithm/in_out_result.h> +#include <__algorithm/iterator_operations.h> #include <__config> #include <__iterator/concepts.h> #include <__iterator/reverse_iterator.h> @@ -39,7 +40,7 @@ struct __fn { requires indirectly_copyable<_InIter1, _InIter2> _LIBCPP_HIDE_FROM_ABI constexpr copy_backward_result<_InIter1, _InIter2> operator()(_InIter1 __first, _Sent1 __last, _InIter2 __result) const { - auto __ret = std::__copy_backward(std::move(__first), std::move(__last), std::move(__result)); + auto __ret = std::__copy_backward<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)); return {std::move(__ret.first), std::move(__ret.second)}; } @@ -47,9 +48,7 @@ struct __fn { requires indirectly_copyable<iterator_t<_Range>, _Iter> _LIBCPP_HIDE_FROM_ABI constexpr copy_backward_result<borrowed_iterator_t<_Range>, _Iter> operator()(_Range&& __r, _Iter __result) const { - auto __ret = std::__copy_backward(ranges::begin(__r), - ranges::end(__r), - std::move(__result)); + auto __ret = std::__copy_backward<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), std::move(__result)); return {std::move(__ret.first), std::move(__ret.second)}; } }; diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_generate.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_generate.h index c23645e6d906..149296574d80 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_generate.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_generate.h @@ -9,21 +9,15 @@ #ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_H #define _LIBCPP___ALGORITHM_RANGES_GENERATE_H -#include <__algorithm/generate.h> -#include <__algorithm/make_projected.h> #include <__concepts/constructible.h> #include <__concepts/invocable.h> #include <__config> -#include <__functional/identity.h> #include <__functional/invoke.h> -#include <__functional/ranges_operations.h> #include <__iterator/concepts.h> #include <__iterator/iterator_traits.h> -#include <__iterator/projected.h> #include <__ranges/access.h> #include <__ranges/concepts.h> #include <__ranges/dangling.h> -#include <__utility/forward.h> #include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -39,22 +33,28 @@ namespace __generate { struct __fn { + template <class _OutIter, class _Sent, class _Func> + _LIBCPP_HIDE_FROM_ABI constexpr + static _OutIter __generate_fn_impl(_OutIter __first, _Sent __last, _Func& __gen) { + for (; __first != __last; ++__first) { + *__first = __gen(); + } + + return __first; + } + template <input_or_output_iterator _OutIter, sentinel_for<_OutIter> _Sent, copy_constructible _Func> requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>> _LIBCPP_HIDE_FROM_ABI constexpr _OutIter operator()(_OutIter __first, _Sent __last, _Func __gen) const { - // TODO: implement - (void)__first; (void)__last; (void)__gen; - return {}; + return __generate_fn_impl(std::move(__first), std::move(__last), __gen); } template <class _Range, copy_constructible _Func> requires invocable<_Func&> && output_range<_Range, invoke_result_t<_Func&>> _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> operator()(_Range&& __range, _Func __gen) const { - // TODO: implement - (void)__range; (void)__gen; - return {}; + return __generate_fn_impl(ranges::begin(__range), ranges::end(__range), __gen); } }; diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_generate_n.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_generate_n.h index 7bde5fb4e579..63f466cecdd7 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_generate_n.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_generate_n.h @@ -9,21 +9,16 @@ #ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H #define _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H -#include <__algorithm/generate_n.h> -#include <__algorithm/make_projected.h> #include <__concepts/constructible.h> #include <__concepts/invocable.h> #include <__config> #include <__functional/identity.h> #include <__functional/invoke.h> -#include <__functional/ranges_operations.h> #include <__iterator/concepts.h> #include <__iterator/incrementable_traits.h> #include <__iterator/iterator_traits.h> -#include <__iterator/projected.h> #include <__ranges/access.h> #include <__ranges/concepts.h> -#include <__utility/forward.h> #include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -43,9 +38,12 @@ struct __fn { requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>> _LIBCPP_HIDE_FROM_ABI constexpr _OutIter operator()(_OutIter __first, iter_difference_t<_OutIter> __n, _Func __gen) const { - // TODO: implement - (void)__first; (void)__n; (void)__gen; - return {}; + for (; __n > 0; --__n) { + *__first = __gen(); + ++__first; + } + + return __first; } }; diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_includes.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_includes.h index ba054e6fd89d..2c7581af68af 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_includes.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_includes.h @@ -56,7 +56,9 @@ struct __fn { std::move(__last1), std::move(__first2), std::move(__last2), - ranges::__make_projected_comp(__comp, __proj1, __proj2)); + std::move(__comp), + std::move(__proj1), + std::move(__proj2)); } template < @@ -73,7 +75,9 @@ struct __fn { ranges::end(__range1), ranges::begin(__range2), ranges::end(__range2), - ranges::__make_projected_comp(__comp, __proj1, __proj2)); + std::move(__comp), + std::move(__proj1), + std::move(__proj2)); } }; diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap.h index 00105189fed7..a3e86d1a8d72 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap.h @@ -9,18 +9,17 @@ #ifndef _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H #define _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H -#include <__algorithm/is_heap.h> +#include <__algorithm/is_heap_until.h> #include <__algorithm/make_projected.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__functional/ranges_operations.h> #include <__iterator/concepts.h> #include <__iterator/iterator_traits.h> +#include <__iterator/next.h> #include <__iterator/projected.h> #include <__ranges/access.h> #include <__ranges/concepts.h> -#include <__utility/forward.h> #include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -36,22 +35,28 @@ namespace __is_heap { struct __fn { + template <class _Iter, class _Sent, class _Proj, class _Comp> + _LIBCPP_HIDE_FROM_ABI constexpr + static bool __is_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { + auto __last_iter = ranges::next(__first, __last); + auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj); + + auto __result = std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp); + return __result == __last; + } + template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { - // TODO: implement - (void)__first; (void)__last; (void)__comp; (void)__proj; - return {}; + return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj); } template <random_access_range _Range, class _Proj = identity, indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { - // TODO: implement - (void)__range; (void)__comp; (void)__proj; - return {}; + return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); } }; diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap_until.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap_until.h index ad021d6f2525..bcd33ad404e8 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap_until.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap_until.h @@ -13,15 +13,14 @@ #include <__algorithm/make_projected.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__functional/ranges_operations.h> #include <__iterator/concepts.h> #include <__iterator/iterator_traits.h> +#include <__iterator/next.h> #include <__iterator/projected.h> #include <__ranges/access.h> #include <__ranges/concepts.h> #include <__ranges/dangling.h> -#include <__utility/forward.h> #include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -37,22 +36,27 @@ namespace __is_heap_until { struct __fn { + template <class _Iter, class _Sent, class _Proj, class _Comp> + _LIBCPP_HIDE_FROM_ABI constexpr + static _Iter __is_heap_until_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { + auto __last_iter = ranges::next(__first, __last); + auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj); + + return std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp); + } + template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { - // TODO: implement - (void)__first; (void)__last; (void)__comp; (void)__proj; - return {}; + return __is_heap_until_fn_impl(std::move(__first), std::move(__last), __comp, __proj); } template <random_access_range _Range, class _Proj = identity, indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { - // TODO: implement - (void)__range; (void)__comp; (void)__proj; - return {}; + return __is_heap_until_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); } }; diff --git a/contrib/llvm-project/libcxx/include/__assert b/contrib/llvm-project/libcxx/include/__assert index 84ddcd25b0b5..82db2cf052b5 100644 --- a/contrib/llvm-project/libcxx/include/__assert +++ b/contrib/llvm-project/libcxx/include/__assert @@ -45,7 +45,7 @@ # define _LIBCPP_ASSERT(expression, message) \ (__builtin_expect(static_cast<bool>(expression), 1) ? \ (void)0 : \ - ::std::__libcpp_assertion_handler(__FILE__, __LINE__, #expression, message)) + ::std::__libcpp_assertion_handler("%s:%d: assertion %s failed: %s", __FILE__, __LINE__, #expression, message)) #elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume) # define _LIBCPP_ASSERT(expression, message) \ (_LIBCPP_DIAGNOSTIC_PUSH \ @@ -58,8 +58,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD -_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ASSERTION_HANDLER -void __libcpp_assertion_handler(char const* __file, int __line, char const* __expression, char const* __message); +_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ASSERTION_HANDLER _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) +void __libcpp_assertion_handler(const char *__format, ...); _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/libcxx/include/__concepts/arithmetic.h b/contrib/llvm-project/libcxx/include/__concepts/arithmetic.h index 023f031e7e07..d91570f02b8b 100644 --- a/contrib/llvm-project/libcxx/include/__concepts/arithmetic.h +++ b/contrib/llvm-project/libcxx/include/__concepts/arithmetic.h @@ -10,6 +10,8 @@ #define _LIBCPP___CONCEPTS_ARITHMETIC_H #include <__config> +#include <__type_traits/is_signed_integer.h> +#include <__type_traits/is_unsigned_integer.h> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/llvm-project/libcxx/include/__format/formatter_integer.h b/contrib/llvm-project/libcxx/include/__format/formatter_integer.h index 0281b4f2fa67..3139c9efdf80 100644 --- a/contrib/llvm-project/libcxx/include/__format/formatter_integer.h +++ b/contrib/llvm-project/libcxx/include/__format/formatter_integer.h @@ -19,6 +19,7 @@ #include <__format/formatter_integral.h> #include <__format/formatter_output.h> #include <__format/parser_std_format_spec.h> +#include <__type_traits/make_32_64_or_128_bit.h> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/llvm-project/libcxx/include/__functional/invoke.h b/contrib/llvm-project/libcxx/include/__functional/invoke.h index 7381462ffca5..d56a0accdbce 100644 --- a/contrib/llvm-project/libcxx/include/__functional/invoke.h +++ b/contrib/llvm-project/libcxx/include/__functional/invoke.h @@ -24,6 +24,7 @@ #include <__type_traits/is_reference_wrapper.h> #include <__type_traits/is_same.h> #include <__type_traits/is_void.h> +#include <__type_traits/nat.h> #include <__type_traits/remove_cv.h> #include <__utility/declval.h> #include <__utility/forward.h> @@ -41,16 +42,6 @@ struct __any __any(...); }; -struct __nat -{ -#ifndef _LIBCPP_CXX03_LANG - __nat() = delete; - __nat(const __nat&) = delete; - __nat& operator=(const __nat&) = delete; - ~__nat() = delete; -#endif -}; - template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr> struct __member_pointer_traits_imp { diff --git a/contrib/llvm-project/libcxx/include/__hash_table b/contrib/llvm-project/libcxx/include/__hash_table index 6123a310ad63..959ef7fe7d83 100644 --- a/contrib/llvm-project/libcxx/include/__hash_table +++ b/contrib/llvm-project/libcxx/include/__hash_table @@ -18,6 +18,7 @@ #include <__debug> #include <__functional/hash.h> #include <__iterator/iterator_traits.h> +#include <__memory/swap_allocator.h> #include <__utility/swap.h> #include <cmath> #include <initializer_list> diff --git a/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h b/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h index ef5f5110a30e..4109b58d46a9 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h +++ b/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h @@ -11,6 +11,7 @@ #define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H #include <__config> +#include <__type_traits/is_primary_template.h> #include <concepts> #include <type_traits> diff --git a/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h b/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h index 63525e230add..254f8c2339e4 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h +++ b/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h @@ -501,6 +501,12 @@ using __iter_to_alloc_type = pair< typename add_const<typename iterator_traits<_InputIterator>::value_type::first_type>::type, typename iterator_traits<_InputIterator>::value_type::second_type>; +template <class _Iter> +using __iterator_category_type = typename iterator_traits<_Iter>::iterator_category; + +template <class _Iter> +using __iterator_pointer_type = typename iterator_traits<_Iter>::pointer; + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H diff --git a/contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h index 7f4ef3c3d503..5c344c2ee310 100644 --- a/contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h +++ b/contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h @@ -197,6 +197,12 @@ public: #endif // _LIBCPP_STD_VER > 17 }; +template <class _Iter> +struct __is_reverse_iterator : false_type {}; + +template <class _Iter> +struct __is_reverse_iterator<reverse_iterator<_Iter> > : true_type {}; + template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool @@ -327,20 +333,162 @@ reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) } #endif +#if _LIBCPP_STD_VER <= 17 template <class _Iter> -using _ReverseWrapper = reverse_iterator<reverse_iterator<_Iter> >; +using __unconstrained_reverse_iterator = reverse_iterator<_Iter>; +#else -template <class _Iter, bool __b> -struct __unwrap_iter_impl<_ReverseWrapper<_Iter>, __b> { +// __unconstrained_reverse_iterator allows us to use reverse iterators in the implementation of algorithms by working +// around a language issue in C++20. +// In C++20, when a reverse iterator wraps certain C++20-hostile iterators, calling comparison operators on it will +// result in a compilation error. However, calling comparison operators on the pristine hostile iterator is not +// an error. Thus, we cannot use reverse_iterators in the implementation of an algorithm that accepts a +// C++20-hostile iterator. This class is an internal workaround -- it is a copy of reverse_iterator with +// tweaks to make it support hostile iterators. +// +// A C++20-hostile iterator is one that defines a comparison operator where one of the arguments is an exact match +// and the other requires an implicit conversion, for example: +// friend bool operator==(const BaseIter&, const DerivedIter&); +// +// C++20 rules for rewriting equality operators create another overload of this function with parameters reversed: +// friend bool operator==(const DerivedIter&, const BaseIter&); +// +// This creates an ambiguity in overload resolution. +// +// Clang treats this ambiguity differently in different contexts. When operator== is actually called in the function +// body, the code is accepted with a warning. When a concept requires operator== to be a valid expression, however, +// it evaluates to false. Thus, the implementation of reverse_iterator::operator== can actually call operator== on its +// base iterators, but the constraints on reverse_iterator::operator== prevent it from being considered during overload +// resolution. This class simply removes the problematic constraints from comparison functions. +template <class _Iter> +class __unconstrained_reverse_iterator { + _Iter __iter_; + +public: + static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value); + + using iterator_type = _Iter; + using iterator_category = + _If<__is_cpp17_random_access_iterator<_Iter>::value, random_access_iterator_tag, __iterator_category_type<_Iter>>; + using pointer = __iterator_pointer_type<_Iter>; + using value_type = iter_value_t<_Iter>; + using difference_type = iter_difference_t<_Iter>; + using reference = iter_reference_t<_Iter>; + + _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator() = default; + _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator(const __unconstrained_reverse_iterator&) = default; + _LIBCPP_HIDE_FROM_ABI constexpr explicit __unconstrained_reverse_iterator(_Iter __iter) : __iter_(__iter) {} + + _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() const { return __iter_; } + _LIBCPP_HIDE_FROM_ABI constexpr reference operator*() const { + auto __tmp = __iter_; + return *--__tmp; + } + + _LIBCPP_HIDE_FROM_ABI constexpr pointer operator->() const { + if constexpr (is_pointer_v<_Iter>) { + return std::prev(__iter_); + } else { + return std::prev(__iter_).operator->(); + } + } + + _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator++() { + --__iter_; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator++(int) { + auto __tmp = *this; + --__iter_; + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator--() { + ++__iter_; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator--(int) { + auto __tmp = *this; + ++__iter_; + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator+=(difference_type __n) { + __iter_ -= __n; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator-=(difference_type __n) { + __iter_ += __n; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator+(difference_type __n) const { + return __unconstrained_reverse_iterator(__iter_ - __n); + } + + _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator-(difference_type __n) const { + return __unconstrained_reverse_iterator(__iter_ + __n); + } + + _LIBCPP_HIDE_FROM_ABI constexpr difference_type operator-(const __unconstrained_reverse_iterator& __other) const { + return __other.__iter_ - __iter_; + } + + _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const { return *(*this + __n); } + + // Deliberately unconstrained unlike the comparison functions in `reverse_iterator` -- see the class comment for the + // rationale. + _LIBCPP_HIDE_FROM_ABI friend constexpr bool + operator==(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { + return __lhs.base() == __rhs.base(); + } + + _LIBCPP_HIDE_FROM_ABI friend constexpr bool + operator!=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { + return __lhs.base() != __rhs.base(); + } + + _LIBCPP_HIDE_FROM_ABI friend constexpr bool + operator<(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { + return __lhs.base() > __rhs.base(); + } + + _LIBCPP_HIDE_FROM_ABI friend constexpr bool + operator>(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { + return __lhs.base() < __rhs.base(); + } + + _LIBCPP_HIDE_FROM_ABI friend constexpr bool + operator<=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { + return __lhs.base() >= __rhs.base(); + } + + _LIBCPP_HIDE_FROM_ABI friend constexpr bool + operator>=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { + return __lhs.base() <= __rhs.base(); + } +}; + +template <class _Iter> +struct __is_reverse_iterator<__unconstrained_reverse_iterator<_Iter>> : true_type {}; + +#endif // _LIBCPP_STD_VER <= 17 + +template <template <class> class _RevIter1, template <class> class _RevIter2, class _Iter> +struct __unwrap_reverse_iter_impl { using _UnwrappedIter = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>())); + using _ReverseWrapper = _RevIter1<_RevIter2<_Iter> >; - static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper<_Iter> - __rewrap(_ReverseWrapper<_Iter> __orig_iter, _UnwrappedIter __unwrapped_iter) { - return _ReverseWrapper<_Iter>( - reverse_iterator<_Iter>(__unwrap_iter_impl<_Iter>::__rewrap(__orig_iter.base().base(), __unwrapped_iter))); + static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper + __rewrap(_ReverseWrapper __orig_iter, _UnwrappedIter __unwrapped_iter) { + return _ReverseWrapper( + _RevIter2<_Iter>(__unwrap_iter_impl<_Iter>::__rewrap(__orig_iter.base().base(), __unwrapped_iter))); } - static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _UnwrappedIter __unwrap(_ReverseWrapper<_Iter> __i) _NOEXCEPT { + static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _UnwrappedIter __unwrap(_ReverseWrapper __i) _NOEXCEPT { return __unwrap_iter_impl<_Iter>::__unwrap(__i.base().base()); } }; @@ -355,6 +503,26 @@ _LIBCPP_HIDE_FROM_ABI constexpr ranges:: } #endif +template <class _Iter, bool __b> +struct __unwrap_iter_impl<reverse_iterator<reverse_iterator<_Iter> >, __b> + : __unwrap_reverse_iter_impl<reverse_iterator, reverse_iterator, _Iter> {}; + +#if _LIBCPP_STD_VER > 17 + +template <class _Iter, bool __b> +struct __unwrap_iter_impl<reverse_iterator<__unconstrained_reverse_iterator<_Iter>>, __b> + : __unwrap_reverse_iter_impl<reverse_iterator, __unconstrained_reverse_iterator, _Iter> {}; + +template <class _Iter, bool __b> +struct __unwrap_iter_impl<__unconstrained_reverse_iterator<reverse_iterator<_Iter>>, __b> + : __unwrap_reverse_iter_impl<__unconstrained_reverse_iterator, reverse_iterator, _Iter> {}; + +template <class _Iter, bool __b> +struct __unwrap_iter_impl<__unconstrained_reverse_iterator<__unconstrained_reverse_iterator<_Iter>>, __b> + : __unwrap_reverse_iter_impl<__unconstrained_reverse_iterator, __unconstrained_reverse_iterator, _Iter> {}; + +#endif // _LIBCPP_STD_VER > 17 + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H diff --git a/contrib/llvm-project/libcxx/include/__memory/swap_allocator.h b/contrib/llvm-project/libcxx/include/__memory/swap_allocator.h new file mode 100644 index 000000000000..64970fa9e2f4 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__memory/swap_allocator.h @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// 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___MEMORY_SWAP_ALLOCATOR_H +#define _LIBCPP___MEMORY_SWAP_ALLOCATOR_H + +#include <__config> +#include <__memory/allocator_traits.h> +#include <__type_traits/integral_constant.h> +#include <__utility/swap.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <typename _Alloc> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type) +#if _LIBCPP_STD_VER > 11 + _NOEXCEPT +#else + _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) +#endif +{ + using _VSTD::swap; + swap(__a1, __a2); +} + +template <typename _Alloc> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void +__swap_allocator(_Alloc&, _Alloc&, false_type) _NOEXCEPT {} + +template <typename _Alloc> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2) +#if _LIBCPP_STD_VER > 11 + _NOEXCEPT +#else + _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) +#endif +{ + _VSTD::__swap_allocator( + __a1, __a2, integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>()); +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MEMORY_SWAP_ALLOCATOR_H diff --git a/contrib/llvm-project/libcxx/include/__memory/temporary_buffer.h b/contrib/llvm-project/libcxx/include/__memory/temporary_buffer.h index 9822bd30c826..b1f7a126299f 100644 --- a/contrib/llvm-project/libcxx/include/__memory/temporary_buffer.h +++ b/contrib/llvm-project/libcxx/include/__memory/temporary_buffer.h @@ -11,6 +11,7 @@ #define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H #include <__config> +#include <__type_traits/alignment_of.h> #include <__utility/pair.h> #include <cstddef> #include <new> diff --git a/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h b/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h index 3a8560f080c6..72b6890c2225 100644 --- a/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h +++ b/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h @@ -10,12 +10,17 @@ #ifndef _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H #define _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H +#include <__algorithm/copy.h> +#include <__algorithm/move.h> #include <__config> #include <__iterator/iterator_traits.h> +#include <__iterator/reverse_iterator.h> #include <__memory/addressof.h> #include <__memory/allocator_traits.h> #include <__memory/construct_at.h> +#include <__memory/pointer_traits.h> #include <__memory/voidify.h> +#include <__type_traits/is_constant_evaluated.h> #include <__utility/move.h> #include <__utility/pair.h> #include <__utility/transaction.h> @@ -347,6 +352,7 @@ uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofir __unreachable_sentinel(), __iter_move); } +// TODO: Rewrite this to iterate left to right and use reverse_iterators when calling // Destroys every element in the range [first, last) FROM RIGHT TO LEFT using allocator // destruction. If elements are themselves C-style arrays, they are recursively destroyed // in the same manner. @@ -492,6 +498,144 @@ constexpr void __uninitialized_allocator_value_construct_n(_Alloc& __alloc, _Bid #endif // _LIBCPP_STD_VER > 14 +// Destroy all elements in [__first, __last) from left to right using allocator destruction. +template <class _Alloc, class _Iter, class _Sent> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void +__allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) { + for (; __first != __last; ++__first) + allocator_traits<_Alloc>::destroy(__alloc, std::__to_address(__first)); +} + +template <class _Alloc, class _Iter> +class _AllocatorDestroyRangeReverse { +public: + _LIBCPP_HIDE_FROM_ABI _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last) + : __alloc_(__alloc), __first_(__first), __last_(__last) {} + + _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const { + std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_)); + } + +private: + _Alloc& __alloc_; + _Iter& __first_; + _Iter& __last_; +}; + +// Copy-construct [__first1, __last1) in [__first2, __first2 + N), where N is distance(__first1, __last1). +// +// The caller has to ensure that __first2 can hold at least N uninitialized elements. If an exception is thrown the +// already copied elements are destroyed in reverse order of their construction. +template <class _Alloc, class _Iter1, class _Sent1, class _Iter2> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 +__uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) { +#ifndef _LIBCPP_NO_EXCEPTIONS + auto __destruct_first = __first2; + try { +#endif + while (__first1 != __last1) { + allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), *__first1); + ++__first1; + ++__first2; + } +#ifndef _LIBCPP_NO_EXCEPTIONS + } catch (...) { + _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)(); + throw; + } +#endif + return __first2; +} + +template <class _Alloc, class _Type> +struct __allocator_has_trivial_copy_construct : _Not<__has_construct<_Alloc, _Type*, const _Type&> > {}; + +template <class _Type> +struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_type {}; + +template <class _Alloc, + class _Type, + class _RawType = typename remove_const<_Type>::type, + __enable_if_t< + // using _RawType because of the allocator<T const> extension + is_trivially_copy_constructible<_RawType>::value && is_trivially_copy_assignable<_RawType>::value && + __allocator_has_trivial_copy_construct<_Alloc, _RawType>::value>* = nullptr> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Type* +__uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __last1, _Type* __first2) { + // TODO: Remove the const_cast once we drop support for std::allocator<T const> + if (__libcpp_is_constant_evaluated()) { + while (__first1 != __last1) { + std::__construct_at(std::__to_address(__first2), *__first1); + ++__first1; + ++__first2; + } + return __first2; + } else { + return std::copy(__first1, __last1, const_cast<_RawType*>(__first2)); + } +} + +// Move-construct the elements [__first1, __last1) into [__first2, __first2 + N) +// if the move constructor is noexcept, where N is distance(__first1, __last1). +// +// Otherwise try to copy all elements. If an exception is thrown the already copied +// elements are destroyed in reverse order of their construction. +template <class _Alloc, class _Iter1, class _Sent1, class _Iter2> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 __uninitialized_allocator_move_if_noexcept( + _Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) { + static_assert(__is_cpp17_move_insertable<_Alloc>::value, + "The specified type does not meet the requirements of Cpp17MoveInsertable"); +#ifndef _LIBCPP_NO_EXCEPTIONS + auto __destruct_first = __first2; + try { +#endif + while (__first1 != __last1) { +#ifndef _LIBCPP_NO_EXCEPTIONS + allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move_if_noexcept(*__first1)); +#else + allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move(*__first1)); +#endif + ++__first1; + ++__first2; + } +#ifndef _LIBCPP_NO_EXCEPTIONS + } catch (...) { + _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)(); + throw; + } +#endif + return __first2; +} + +template <class _Alloc, class _Type> +struct __allocator_has_trivial_move_construct : _Not<__has_construct<_Alloc, _Type*, _Type&&> > {}; + +template <class _Type> +struct __allocator_has_trivial_move_construct<allocator<_Type>, _Type> : true_type {}; + +#ifndef _LIBCPP_COMPILER_GCC +template < + class _Alloc, + class _Iter1, + class _Iter2, + class _Type = typename iterator_traits<_Iter1>::value_type, + class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value && + __allocator_has_trivial_move_construct<_Alloc, _Type>::value> > +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter1 +__uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) { + if (__libcpp_is_constant_evaluated()) { + while (__first1 != __last1) { + std::__construct_at(std::__to_address(__first2), std::move(*__first1)); + ++__first1; + ++__first2; + } + return __first2; + } else { + return std::move(__first1, __last1, __first2); + } +} +#endif // _LIBCPP_COMPILER_GCC + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H diff --git a/contrib/llvm-project/libcxx/include/__split_buffer b/contrib/llvm-project/libcxx/include/__split_buffer index 7409b51b1f96..f78167466217 100644 --- a/contrib/llvm-project/libcxx/include/__split_buffer +++ b/contrib/llvm-project/libcxx/include/__split_buffer @@ -19,6 +19,7 @@ #include <__iterator/move_iterator.h> #include <__memory/allocator.h> #include <__memory/compressed_pair.h> +#include <__memory/swap_allocator.h> #include <__utility/forward.h> #include <memory> #include <type_traits> diff --git a/contrib/llvm-project/libcxx/include/__tree b/contrib/llvm-project/libcxx/include/__tree index 8d8449706871..59525a03047a 100644 --- a/contrib/llvm-project/libcxx/include/__tree +++ b/contrib/llvm-project/libcxx/include/__tree @@ -17,6 +17,7 @@ #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__iterator/next.h> +#include <__memory/swap_allocator.h> #include <__utility/forward.h> #include <__utility/swap.h> #include <limits> diff --git a/contrib/llvm-project/libcxx/include/__type_traits/aligned_storage.h b/contrib/llvm-project/libcxx/include/__type_traits/aligned_storage.h new file mode 100644 index 000000000000..9659a90ae50c --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/aligned_storage.h @@ -0,0 +1,142 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_ALIGNED_STORAGE_H +#define _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H + +#include <__config> +#include <__type_traits/conditional.h> +#include <__type_traits/integral_constant.h> +#include <__type_traits/nat.h> +#include <__type_traits/type_list.h> +#include <cstddef> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> +struct __align_type +{ + static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp); + typedef _Tp type; +}; + +struct __struct_double {long double __lx;}; +struct __struct_double4 {double __lx[4];}; + +typedef + __type_list<__align_type<unsigned char>, + __type_list<__align_type<unsigned short>, + __type_list<__align_type<unsigned int>, + __type_list<__align_type<unsigned long>, + __type_list<__align_type<unsigned long long>, + __type_list<__align_type<double>, + __type_list<__align_type<long double>, + __type_list<__align_type<__struct_double>, + __type_list<__align_type<__struct_double4>, + __type_list<__align_type<int*>, + __nat + > > > > > > > > > > __all_types; + +template <size_t _Align> +struct _ALIGNAS(_Align) __fallback_overaligned {}; + +template <class _TL, size_t _Align> struct __find_pod; + +template <class _Hp, size_t _Align> +struct __find_pod<__type_list<_Hp, __nat>, _Align> +{ + typedef typename conditional< + _Align == _Hp::value, + typename _Hp::type, + __fallback_overaligned<_Align> + >::type type; +}; + +template <class _Hp, class _Tp, size_t _Align> +struct __find_pod<__type_list<_Hp, _Tp>, _Align> +{ + typedef typename conditional< + _Align == _Hp::value, + typename _Hp::type, + typename __find_pod<_Tp, _Align>::type + >::type type; +}; + +template <class _TL, size_t _Len> struct __find_max_align; + +template <class _Hp, size_t _Len> +struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; + +template <size_t _Len, size_t _A1, size_t _A2> +struct __select_align +{ +private: + static const size_t __min = _A2 < _A1 ? _A2 : _A1; + static const size_t __max = _A1 < _A2 ? _A2 : _A1; +public: + static const size_t value = _Len < __max ? __min : __max; +}; + +template <class _Hp, class _Tp, size_t _Len> +struct __find_max_align<__type_list<_Hp, _Tp>, _Len> + : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; + +template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> +struct _LIBCPP_TEMPLATE_VIS aligned_storage +{ + typedef typename __find_pod<__all_types, _Align>::type _Aligner; + union type + { + _Aligner __align; + unsigned char __data[(_Len + _Align - 1)/_Align * _Align]; + }; +}; + +#if _LIBCPP_STD_VER > 11 +template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> + using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; +#endif + +#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ +template <size_t _Len>\ +struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\ +{\ + struct _ALIGNAS(n) type\ + {\ + unsigned char __lx[(_Len + n - 1)/n * n];\ + };\ +} + +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); +// PE/COFF does not support alignment beyond 8192 (=0x2000) +#if !defined(_LIBCPP_OBJECT_FORMAT_COFF) +_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); +#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF) + +#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/aligned_union.h b/contrib/llvm-project/libcxx/include/__type_traits/aligned_union.h new file mode 100644 index 000000000000..31eb9353a9e2 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/aligned_union.h @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_ALIGNED_UNION_H +#define _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H + +#include <__config> +#include <__type_traits/aligned_storage.h> +#include <__type_traits/integral_constant.h> +#include <cstddef> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <size_t _I0, size_t ..._In> +struct __static_max; + +template <size_t _I0> +struct __static_max<_I0> +{ + static const size_t value = _I0; +}; + +template <size_t _I0, size_t _I1, size_t ..._In> +struct __static_max<_I0, _I1, _In...> +{ + static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : + __static_max<_I1, _In...>::value; +}; + +template <size_t _Len, class _Type0, class ..._Types> +struct aligned_union +{ + static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), + _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value; + static const size_t __len = __static_max<_Len, sizeof(_Type0), + sizeof(_Types)...>::value; + typedef typename aligned_storage<__len, alignment_value>::type type; +}; + +#if _LIBCPP_STD_VER > 11 +template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/common_reference.h b/contrib/llvm-project/libcxx/include/__type_traits/common_reference.h new file mode 100644 index 000000000000..559d39858ec8 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/common_reference.h @@ -0,0 +1,188 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_COMMON_REFERENCE_H +#define _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H + +#include <__config> +#include <__type_traits/common_type.h> +#include <__type_traits/copy_cv.h> +#include <__type_traits/copy_cvref.h> +#include <__type_traits/is_convertible.h> +#include <__type_traits/is_reference.h> +#include <__type_traits/remove_cv.h> +#include <__type_traits/remove_cvref.h> +#include <__type_traits/remove_reference.h> +#include <__utility/declval.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +// common_reference +#if _LIBCPP_STD_VER > 17 +// Let COND_RES(X, Y) be: +template <class _Xp, class _Yp> +using __cond_res = + decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()()); + +// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U` +// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type +// `U`. +// [Note: `XREF(A)` is `__xref<A>::template __apply`] +template <class _Tp> +struct __xref { + template<class _Up> + using __apply = __copy_cvref_t<_Tp, _Up>; +}; + +// Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>, +// and let COMMON-REF(A, B) be: +template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>> +struct __common_ref; + +template<class _Xp, class _Yp> +using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type; + +template<class _Xp, class _Yp> +using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>; + + +// If A and B are both lvalue reference types, COMMON-REF(A, B) is +// COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type. +template<class _Ap, class _Bp, class _Xp, class _Yp> +requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>> +struct __common_ref<_Ap&, _Bp&, _Xp, _Yp> +{ + using __type = __cv_cond_res<_Xp, _Yp>; +}; + +// Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ... +template <class _Xp, class _Yp> +using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&; + + +// .... If A and B are both rvalue reference types, C is well-formed, and +// is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C. +template<class _Ap, class _Bp, class _Xp, class _Yp> +requires + requires { typename __common_ref_C<_Xp, _Yp>; } && + is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> && + is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>> +struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp> +{ + using __type = __common_ref_C<_Xp, _Yp>; +}; + +// Otherwise, let D be COMMON-REF(const X&, Y&). ... +template <class _Tp, class _Up> +using __common_ref_D = __common_ref_t<const _Tp&, _Up&>; + +// ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and +// is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D. +template<class _Ap, class _Bp, class _Xp, class _Yp> +requires requires { typename __common_ref_D<_Xp, _Yp>; } && + is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>> +struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp> +{ + using __type = __common_ref_D<_Xp, _Yp>; +}; + +// Otherwise, if A is an lvalue reference and B is an rvalue reference, then +// COMMON-REF(A, B) is COMMON-REF(B, A). +template<class _Ap, class _Bp, class _Xp, class _Yp> +struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {}; + +// Otherwise, COMMON-REF(A, B) is ill-formed. +template<class _Ap, class _Bp, class _Xp, class _Yp> +struct __common_ref {}; + +// Note C: For the common_reference trait applied to a parameter pack [...] + +template <class...> +struct common_reference; + +template <class... _Types> +using common_reference_t = typename common_reference<_Types...>::type; + +// bullet 1 - sizeof...(T) == 0 +template<> +struct common_reference<> {}; + +// bullet 2 - sizeof...(T) == 1 +template <class _Tp> +struct common_reference<_Tp> +{ + using type = _Tp; +}; + +// bullet 3 - sizeof...(T) == 2 +template <class _Tp, class _Up> struct __common_reference_sub_bullet3; +template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {}; +template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {}; + +// sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then +// the member typedef `type` denotes that type. +template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {}; + +template <class _Tp, class _Up> +requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; } +struct __common_reference_sub_bullet1<_Tp, _Up> +{ + using type = __common_ref_t<_Tp, _Up>; +}; + +// sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type +// is well-formed, then the member typedef `type` denotes that type. +template <class, class, template <class> class, template <class> class> struct basic_common_reference {}; + +template <class _Tp, class _Up> +using __basic_common_reference_t = typename basic_common_reference< + remove_cvref_t<_Tp>, remove_cvref_t<_Up>, + __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type; + +template <class _Tp, class _Up> +requires requires { typename __basic_common_reference_t<_Tp, _Up>; } +struct __common_reference_sub_bullet2<_Tp, _Up> +{ + using type = __basic_common_reference_t<_Tp, _Up>; +}; + +// sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed, +// then the member typedef `type` denotes that type. +template <class _Tp, class _Up> +requires requires { typename __cond_res<_Tp, _Up>; } +struct __common_reference_sub_bullet3<_Tp, _Up> +{ + using type = __cond_res<_Tp, _Up>; +}; + + +// sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed, +// then the member typedef `type` denotes that type. +// - Otherwise, there shall be no member `type`. +template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {}; + +// bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if +// any, as `common_reference_t<C, Rest...>`. +template <class _Tp, class _Up, class _Vp, class... _Rest> +requires requires { typename common_reference_t<_Tp, _Up>; } +struct common_reference<_Tp, _Up, _Vp, _Rest...> + : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...> +{}; + +// bullet 5 - Otherwise, there shall be no member `type`. +template <class...> struct common_reference {}; + +#endif // _LIBCPP_STD_VER > 17 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/common_type.h b/contrib/llvm-project/libcxx/include/__type_traits/common_type.h new file mode 100644 index 000000000000..55321e9936dd --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/common_type.h @@ -0,0 +1,138 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_COMMON_TYPE_H +#define _LIBCPP___TYPE_TRAITS_COMMON_TYPE_H + +#include <__config> +#include <__type_traits/conditional.h> +#include <__type_traits/decay.h> +#include <__type_traits/is_same.h> +#include <__type_traits/remove_cvref.h> +#include <__type_traits/void_t.h> +#include <__utility/declval.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 +// Let COND_RES(X, Y) be: +template <class _Tp, class _Up> +using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>()); + +template <class _Tp, class _Up, class = void> +struct __common_type3 {}; + +// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..." +template <class _Tp, class _Up> +struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> +{ + using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>; +}; + +template <class _Tp, class _Up, class = void> +struct __common_type2_imp : __common_type3<_Tp, _Up> {}; +#else +template <class _Tp, class _Up, class = void> +struct __common_type2_imp {}; +#endif + +// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..." +template <class _Tp, class _Up> +struct __common_type2_imp<_Tp, _Up, + typename __void_t<decltype( + true ? declval<_Tp>() : declval<_Up>() + )>::type> +{ + typedef _LIBCPP_NODEBUG typename decay<decltype( + true ? declval<_Tp>() : declval<_Up>() + )>::type type; +}; + +template <class, class = void> +struct __common_type_impl {}; + +// Clang provides variadic templates in C++03 as an extension. +#if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__) +# define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__ +template <class... _Tp> +struct __common_types; +template <class... _Tp> +struct _LIBCPP_TEMPLATE_VIS common_type; +#else +# define _LIBCPP_OPTIONAL_PACK(...) +struct __no_arg; +template <class _Tp, class _Up, class = __no_arg> +struct __common_types; +template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg, + class _Unused = __no_arg> +struct common_type { + static_assert(sizeof(_Unused) == 0, + "common_type accepts at most 3 arguments in C++03"); +}; +#endif // _LIBCPP_CXX03_LANG + +template <class _Tp, class _Up> +struct __common_type_impl< + __common_types<_Tp, _Up>, + typename __void_t<typename common_type<_Tp, _Up>::type>::type> +{ + typedef typename common_type<_Tp, _Up>::type type; +}; + +template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> +struct __common_type_impl< + __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>, + typename __void_t<typename common_type<_Tp, _Up>::type>::type> + : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type, + _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > { +}; + +// bullet 1 - sizeof...(Tp) == 0 + +template <> +struct _LIBCPP_TEMPLATE_VIS common_type<> {}; + +// bullet 2 - sizeof...(Tp) == 1 + +template <class _Tp> +struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> + : public common_type<_Tp, _Tp> {}; + +// bullet 3 - sizeof...(Tp) == 2 + +// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..." +template <class _Tp, class _Up> +struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> + : conditional< + _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value, + __common_type2_imp<_Tp, _Up>, + common_type<typename decay<_Tp>::type, typename decay<_Up>::type> + >::type +{}; + +// bullet 4 - sizeof...(Tp) > 2 + +template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> +struct _LIBCPP_TEMPLATE_VIS + common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> + : __common_type_impl< + __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {}; + +#undef _LIBCPP_OPTIONAL_PACK + +#if _LIBCPP_STD_VER > 11 +template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_COMMON_TYPE_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/copy_cv.h b/contrib/llvm-project/libcxx/include/__type_traits/copy_cv.h new file mode 100644 index 000000000000..8e9bfe0a522f --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/copy_cv.h @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_COPY_CV_H +#define _LIBCPP___TYPE_TRAITS_COPY_CV_H + +#include <__config> +#include <__type_traits/add_const.h> +#include <__type_traits/add_cv.h> +#include <__type_traits/add_volatile.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +// Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's +// top-level cv-qualifiers. +template <class _From, class _To> +struct __copy_cv +{ + using type = _To; +}; + +template <class _From, class _To> +struct __copy_cv<const _From, _To> +{ + using type = typename add_const<_To>::type; +}; + +template <class _From, class _To> +struct __copy_cv<volatile _From, _To> +{ + using type = typename add_volatile<_To>::type; +}; + +template <class _From, class _To> +struct __copy_cv<const volatile _From, _To> +{ + using type = typename add_cv<_To>::type; +}; + +template <class _From, class _To> +using __copy_cv_t = typename __copy_cv<_From, _To>::type; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_COPY_CV_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/copy_cvref.h b/contrib/llvm-project/libcxx/include/__type_traits/copy_cvref.h new file mode 100644 index 000000000000..69b97ac1cb17 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/copy_cvref.h @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_COPY_CVREF_H +#define _LIBCPP___TYPE_TRAITS_COPY_CVREF_H + +#include <__config> +#include <__type_traits/add_lvalue_reference.h> +#include <__type_traits/add_rvalue_reference.h> +#include <__type_traits/copy_cv.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _From, class _To> +struct __copy_cvref +{ + using type = __copy_cv_t<_From, _To>; +}; + +template <class _From, class _To> +struct __copy_cvref<_From&, _To> +{ + using type = typename add_lvalue_reference<__copy_cv_t<_From, _To> >::type; +}; + +template <class _From, class _To> +struct __copy_cvref<_From&&, _To> +{ + using type = typename add_rvalue_reference<__copy_cv_t<_From, _To> >::type; +}; + +template <class _From, class _To> +using __copy_cvref_t = typename __copy_cvref<_From, _To>::type; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_COPY_CVREF_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/is_nothrow_convertible.h b/contrib/llvm-project/libcxx/include/__type_traits/is_nothrow_convertible.h new file mode 100644 index 000000000000..712b6f2cf4b8 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/is_nothrow_convertible.h @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H +#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H + +#include <__config> +#include <__type_traits/conjunction.h> +#include <__type_traits/disjunction.h> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_convertible.h> +#include <__type_traits/is_void.h> +#include <__type_traits/lazy.h> +#include <__utility/declval.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +template <typename _Tp> +static void __test_noexcept(_Tp) noexcept; + +template<typename _Fm, typename _To> +static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))> +__is_nothrow_convertible_test(); + +template <typename _Fm, typename _To> +struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>()) +{ }; + +template <typename _Fm, typename _To> +struct is_nothrow_convertible : _Or< + _And<is_void<_To>, is_void<_Fm>>, + _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>> +>::type { }; + +template <typename _Fm, typename _To> +inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value; + +#endif // _LIBCPP_STD_VER > 17 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/is_primary_template.h b/contrib/llvm-project/libcxx/include/__type_traits/is_primary_template.h new file mode 100644 index 000000000000..a9bebcf7e64c --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/is_primary_template.h @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H +#define _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_same.h> +#include <__type_traits/is_valid_expansion.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> +using __test_for_primary_template = __enable_if_t< + _IsSame<_Tp, typename _Tp::__primary_template>::value + >; +template <class _Tp> +using __is_primary_template = _IsValidExpansion< + __test_for_primary_template, _Tp + >; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/is_signed_integer.h b/contrib/llvm-project/libcxx/include/__type_traits/is_signed_integer.h new file mode 100644 index 000000000000..95aa11bfa1b5 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/is_signed_integer.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_IS_SIGNED_INTEGER_H +#define _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> struct __libcpp_is_signed_integer : public false_type {}; +template <> struct __libcpp_is_signed_integer<signed char> : public true_type {}; +template <> struct __libcpp_is_signed_integer<signed short> : public true_type {}; +template <> struct __libcpp_is_signed_integer<signed int> : public true_type {}; +template <> struct __libcpp_is_signed_integer<signed long> : public true_type {}; +template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {}; +#ifndef _LIBCPP_HAS_NO_INT128 +template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {}; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/is_unsigned_integer.h b/contrib/llvm-project/libcxx/include/__type_traits/is_unsigned_integer.h new file mode 100644 index 000000000000..54b29acd9ea3 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/is_unsigned_integer.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H +#define _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {}; +template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {}; +template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {}; +template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {}; +template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {}; +template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {}; +#ifndef _LIBCPP_HAS_NO_INT128 +template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {}; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/is_valid_expansion.h b/contrib/llvm-project/libcxx/include/__type_traits/is_valid_expansion.h new file mode 100644 index 000000000000..c45db7509e41 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/is_valid_expansion.h @@ -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 +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_H +#define _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> > +true_type __sfinae_test_impl(int); +template <template <class...> class, class ...> +false_type __sfinae_test_impl(...); + +template <template <class ...> class _Templ, class ..._Args> +using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0)); + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/lazy.h b/contrib/llvm-project/libcxx/include/__type_traits/lazy.h new file mode 100644 index 000000000000..6874b06f3c5a --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/lazy.h @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_LAZY_H +#define _LIBCPP___TYPE_TRAITS_LAZY_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <template <class...> class _Func, class ..._Args> +struct _Lazy : _Func<_Args...> {}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_LAZY_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/make_32_64_or_128_bit.h b/contrib/llvm-project/libcxx/include/__type_traits/make_32_64_or_128_bit.h new file mode 100644 index 000000000000..87340eac7fb1 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/make_32_64_or_128_bit.h @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_MAKE_32_64_OR_128_BIT_H +#define _LIBCPP___TYPE_TRAITS_MAKE_32_64_OR_128_BIT_H + +#include <__config> +#include <__type_traits/conditional.h> +#include <__type_traits/is_same.h> +#include <__type_traits/is_signed.h> +#include <__type_traits/is_unsigned.h> +#include <__type_traits/make_unsigned.h> +#include <cstdint> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +/// Helper to promote an integral to smallest 32, 64, or 128 bit representation. +/// +/// The restriction is the same as the integral version of to_char. +template <class _Tp> +#if _LIBCPP_STD_VER > 17 + requires (is_signed_v<_Tp> || is_unsigned_v<_Tp> || is_same_v<_Tp, char>) +#endif +using __make_32_64_or_128_bit_t = + __copy_unsigned_t<_Tp, + __conditional_t<sizeof(_Tp) <= sizeof(int32_t), int32_t, + __conditional_t<sizeof(_Tp) <= sizeof(int64_t), int64_t, +#ifndef _LIBCPP_HAS_NO_INT128 + __conditional_t<sizeof(_Tp) <= sizeof(__int128_t), __int128_t, + /* else */ void> +#else + /* else */ void +#endif + > > + >; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_MAKE_32_64_OR_128_BIT_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/make_signed.h b/contrib/llvm-project/libcxx/include/__type_traits/make_signed.h new file mode 100644 index 000000000000..fbc31172a978 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/make_signed.h @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_MAKE_SIGNED_H +#define _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H + +#include <__config> +#include <__type_traits/apply_cv.h> +#include <__type_traits/is_enum.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/nat.h> +#include <__type_traits/remove_cv.h> +#include <__type_traits/type_list.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +typedef + __type_list<signed char, + __type_list<signed short, + __type_list<signed int, + __type_list<signed long, + __type_list<signed long long, +#ifndef _LIBCPP_HAS_NO_INT128 + __type_list<__int128_t, +#endif + __nat +#ifndef _LIBCPP_HAS_NO_INT128 + > +#endif + > > > > > __signed_types; + +template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> +struct __make_signed {}; + +template <class _Tp> +struct __make_signed<_Tp, true> +{ + typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; +}; + +template <> struct __make_signed<bool, true> {}; +template <> struct __make_signed< signed short, true> {typedef short type;}; +template <> struct __make_signed<unsigned short, true> {typedef short type;}; +template <> struct __make_signed< signed int, true> {typedef int type;}; +template <> struct __make_signed<unsigned int, true> {typedef int type;}; +template <> struct __make_signed< signed long, true> {typedef long type;}; +template <> struct __make_signed<unsigned long, true> {typedef long type;}; +template <> struct __make_signed< signed long long, true> {typedef long long type;}; +template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; +#ifndef _LIBCPP_HAS_NO_INT128 +template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;}; +template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;}; +#endif + +template <class _Tp> +struct _LIBCPP_TEMPLATE_VIS make_signed +{ + typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; +}; + +#if _LIBCPP_STD_VER > 11 +template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/make_unsigned.h b/contrib/llvm-project/libcxx/include/__type_traits/make_unsigned.h new file mode 100644 index 000000000000..8110a5ca9609 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/make_unsigned.h @@ -0,0 +1,89 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_MAKE_UNSIGNED_H +#define _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H + +#include <__config> +#include <__type_traits/apply_cv.h> +#include <__type_traits/conditional.h> +#include <__type_traits/is_enum.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/is_unsigned.h> +#include <__type_traits/nat.h> +#include <__type_traits/remove_cv.h> +#include <__type_traits/type_list.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +typedef + __type_list<unsigned char, + __type_list<unsigned short, + __type_list<unsigned int, + __type_list<unsigned long, + __type_list<unsigned long long, +#ifndef _LIBCPP_HAS_NO_INT128 + __type_list<__uint128_t, +#endif + __nat +#ifndef _LIBCPP_HAS_NO_INT128 + > +#endif + > > > > > __unsigned_types; + +template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> +struct __make_unsigned {}; + +template <class _Tp> +struct __make_unsigned<_Tp, true> +{ + typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; +}; + +template <> struct __make_unsigned<bool, true> {}; +template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; +template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; +template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; +template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; +template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; +template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; +template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; +template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; +#ifndef _LIBCPP_HAS_NO_INT128 +template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; +template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; +#endif + +template <class _Tp> +struct _LIBCPP_TEMPLATE_VIS make_unsigned +{ + typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; +}; + +#if _LIBCPP_STD_VER > 11 +template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; +#endif + +#ifndef _LIBCPP_CXX03_LANG +template <class _Tp> +_LIBCPP_HIDE_FROM_ABI constexpr +typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept { + return static_cast<typename make_unsigned<_Tp>::type>(__x); +} +#endif + +template <class _Tp, class _Up> +using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, typename make_unsigned<_Up>::type, _Up>; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/nat.h b/contrib/llvm-project/libcxx/include/__type_traits/nat.h new file mode 100644 index 000000000000..5216ef520420 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/nat.h @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_NAT_H +#define _LIBCPP___TYPE_TRAITS_NAT_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +struct __nat +{ +#ifndef _LIBCPP_CXX03_LANG + __nat() = delete; + __nat(const __nat&) = delete; + __nat& operator=(const __nat&) = delete; + ~__nat() = delete; +#endif +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_NAT_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/promote.h b/contrib/llvm-project/libcxx/include/__type_traits/promote.h new file mode 100644 index 000000000000..a9226a74b300 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/promote.h @@ -0,0 +1,95 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_PROMOTE_H +#define _LIBCPP___TYPE_TRAITS_PROMOTE_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_same.h> +#include <__utility/declval.h> +#include <cstddef> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> +struct __numeric_type +{ + static void __test(...); + static float __test(float); + static double __test(char); + static double __test(int); + static double __test(unsigned); + static double __test(long); + static double __test(unsigned long); + static double __test(long long); + static double __test(unsigned long long); + static double __test(double); + static long double __test(long double); + + typedef decltype(__test(declval<_Tp>())) type; + static const bool value = _IsNotSame<type, void>::value; +}; + +template <> +struct __numeric_type<void> +{ + static const bool value = true; +}; + +template <class _A1, class _A2 = void, class _A3 = void, + bool = __numeric_type<_A1>::value && + __numeric_type<_A2>::value && + __numeric_type<_A3>::value> +class __promote_imp +{ +public: + static const bool value = false; +}; + +template <class _A1, class _A2, class _A3> +class __promote_imp<_A1, _A2, _A3, true> +{ +private: + typedef typename __promote_imp<_A1>::type __type1; + typedef typename __promote_imp<_A2>::type __type2; + typedef typename __promote_imp<_A3>::type __type3; +public: + typedef decltype(__type1() + __type2() + __type3()) type; + static const bool value = true; +}; + +template <class _A1, class _A2> +class __promote_imp<_A1, _A2, void, true> +{ +private: + typedef typename __promote_imp<_A1>::type __type1; + typedef typename __promote_imp<_A2>::type __type2; +public: + typedef decltype(__type1() + __type2()) type; + static const bool value = true; +}; + +template <class _A1> +class __promote_imp<_A1, void, void, true> +{ +public: + typedef typename __numeric_type<_A1>::type type; + static const bool value = true; +}; + +template <class _A1, class _A2 = void, class _A3 = void> +class __promote : public __promote_imp<_A1, _A2, _A3> {}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/remove_cvref.h b/contrib/llvm-project/libcxx/include/__type_traits/remove_cvref.h new file mode 100644 index 000000000000..d937501fedce --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/remove_cvref.h @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_REMOVE_CVREF_H +#define _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H + +#include <__config> +#include <__type_traits/is_same.h> +#include <__type_traits/remove_cv.h> +#include <__type_traits/remove_reference.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> +using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv<typename remove_reference<_Tp>::type>::type; + +template <class _Tp, class _Up> +struct __is_same_uncvref : _IsSame<__uncvref_t<_Tp>, __uncvref_t<_Up> > {}; + +#if _LIBCPP_STD_VER > 17 +// remove_cvref - same as __uncvref +template <class _Tp> +struct remove_cvref { + using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>; +}; + +template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H diff --git a/contrib/llvm-project/libcxx/include/__type_traits/type_list.h b/contrib/llvm-project/libcxx/include/__type_traits/type_list.h new file mode 100644 index 000000000000..5a9e3319a1d4 --- /dev/null +++ b/contrib/llvm-project/libcxx/include/__type_traits/type_list.h @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// 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___TYPE_TRAITS_TYPE_LIST_H +#define _LIBCPP___TYPE_TRAITS_TYPE_LIST_H + +#include <__config> +#include <cstddef> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Hp, class _Tp> +struct __type_list +{ + typedef _Hp _Head; + typedef _Tp _Tail; +}; + +template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; + +template <class _Hp, class _Tp, size_t _Size> +struct __find_first<__type_list<_Hp, _Tp>, _Size, true> +{ + typedef _LIBCPP_NODEBUG _Hp type; +}; + +template <class _Hp, class _Tp, size_t _Size> +struct __find_first<__type_list<_Hp, _Tp>, _Size, false> +{ + typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type; +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_TYPE_LIST_H diff --git a/contrib/llvm-project/libcxx/include/__utility/transaction.h b/contrib/llvm-project/libcxx/include/__utility/transaction.h index 87e51c0b198e..e2cc43820845 100644 --- a/contrib/llvm-project/libcxx/include/__utility/transaction.h +++ b/contrib/llvm-project/libcxx/include/__utility/transaction.h @@ -86,6 +86,11 @@ private: bool __completed_; }; +template <class _Rollback> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __transaction<_Rollback> __make_transaction(_Rollback __rollback) { + return __transaction<_Rollback>(std::move(__rollback)); +} + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___UTILITY_TRANSACTION_H diff --git a/contrib/llvm-project/libcxx/include/algorithm b/contrib/llvm-project/libcxx/include/algorithm index 5958ad1a95af..197b3b1043bb 100644 --- a/contrib/llvm-project/libcxx/include/algorithm +++ b/contrib/llvm-project/libcxx/include/algorithm @@ -331,6 +331,23 @@ namespace ranges { constexpr borrowed_iterator_t<R> ranges::sort_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 + template<random_access_iterator I, sentinel_for<I> S, class Proj = identity, + indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> + constexpr bool is_heap(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20 + + template<random_access_range R, class Proj = identity, + indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> + constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20 + + template<random_access_iterator I, sentinel_for<I> S, class Proj = identity, + indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> + constexpr I is_heap_until(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20 + + template<random_access_range R, class Proj = identity, + indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> + constexpr borrowed_iterator_t<R> + is_heap_until(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20 + template<bidirectional_iterator I, sentinel_for<I> S> requires permutable<I> constexpr I ranges::reverse(I first, S last); // since C++20 @@ -380,6 +397,18 @@ namespace ranges { template<class T, output_iterator<const T&> O> constexpr O ranges::fill_n(O first, iter_difference_t<O> n, const T& value); // since C++20 + template<input_or_output_iterator O, sentinel_for<O> S, copy_constructible F> + requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>> + constexpr O generate(O first, S last, F gen); // Since C++20 + + template<class R, copy_constructible F> + requires invocable<F&> && output_range<R, invoke_result_t<F&>> + constexpr borrowed_iterator_t<R> generate(R&& r, F gen); // Since C++20 + + template<input_or_output_iterator O, copy_constructible F> + requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>> + constexpr O generate_n(O first, iter_difference_t<O> n, F gen); // Since C++20 + template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2> @@ -1575,7 +1604,11 @@ template <class BidirectionalIterator, class Compare> #include <__algorithm/ranges_find_if_not.h> #include <__algorithm/ranges_for_each.h> #include <__algorithm/ranges_for_each_n.h> +#include <__algorithm/ranges_generate.h> +#include <__algorithm/ranges_generate_n.h> #include <__algorithm/ranges_includes.h> +#include <__algorithm/ranges_is_heap.h> +#include <__algorithm/ranges_is_heap_until.h> #include <__algorithm/ranges_is_partitioned.h> #include <__algorithm/ranges_is_sorted.h> #include <__algorithm/ranges_is_sorted_until.h> diff --git a/contrib/llvm-project/libcxx/include/charconv b/contrib/llvm-project/libcxx/include/charconv index 9f474ae711f3..4f00755a83bb 100644 --- a/contrib/llvm-project/libcxx/include/charconv +++ b/contrib/llvm-project/libcxx/include/charconv @@ -88,6 +88,7 @@ namespace std { #include <__config> #include <__debug> #include <__errc> +#include <__type_traits/make_32_64_or_128_bit.h> #include <__utility/unreachable.h> #include <cmath> // for log2f #include <cstdint> diff --git a/contrib/llvm-project/libcxx/include/forward_list b/contrib/llvm-project/libcxx/include/forward_list index aab3b8715d01..ee90aaa4771f 100644 --- a/contrib/llvm-project/libcxx/include/forward_list +++ b/contrib/llvm-project/libcxx/include/forward_list @@ -188,6 +188,7 @@ template <class T, class Allocator, class Predicate> #include <__iterator/iterator_traits.h> #include <__iterator/move_iterator.h> #include <__iterator/next.h> +#include <__memory/swap_allocator.h> #include <__utility/forward.h> #include <limits> #include <memory> diff --git a/contrib/llvm-project/libcxx/include/list b/contrib/llvm-project/libcxx/include/list index 1db29d14b842..5fcbd67c6703 100644 --- a/contrib/llvm-project/libcxx/include/list +++ b/contrib/llvm-project/libcxx/include/list @@ -194,6 +194,7 @@ template <class T, class Allocator, class Predicate> #include <__iterator/next.h> #include <__iterator/prev.h> #include <__iterator/reverse_iterator.h> +#include <__memory/swap_allocator.h> #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/swap.h> diff --git a/contrib/llvm-project/libcxx/include/math.h b/contrib/llvm-project/libcxx/include/math.h index 7d553e728d0f..0ec584af9dbe 100644 --- a/contrib/llvm-project/libcxx/include/math.h +++ b/contrib/llvm-project/libcxx/include/math.h @@ -305,6 +305,7 @@ long double truncl(long double x); // back to C++ linkage before including these C++ headers. extern "C++" { +#include <__type_traits/promote.h> #include <limits> #include <stdlib.h> #include <type_traits> diff --git a/contrib/llvm-project/libcxx/include/memory b/contrib/llvm-project/libcxx/include/memory index ec9f5773929f..56f8159fbd44 100644 --- a/contrib/llvm-project/libcxx/include/memory +++ b/contrib/llvm-project/libcxx/include/memory @@ -885,93 +885,6 @@ template<size_t N, class T> _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Alloc, class _Ptr> -_LIBCPP_INLINE_VISIBILITY -void __construct_forward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) { - static_assert(__is_cpp17_move_insertable<_Alloc>::value, - "The specified type does not meet the requirements of Cpp17MoveInsertable"); - typedef allocator_traits<_Alloc> _Traits; - for (; __begin1 != __end1; ++__begin1, (void)++__begin2) { - _Traits::construct(__a, _VSTD::__to_address(__begin2), -#ifdef _LIBCPP_NO_EXCEPTIONS - _VSTD::move(*__begin1) -#else - _VSTD::move_if_noexcept(*__begin1) -#endif - ); - } -} - -template <class _Alloc, class _Tp, typename enable_if< - (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) && - is_trivially_move_constructible<_Tp>::value ->::type> -_LIBCPP_INLINE_VISIBILITY -void __construct_forward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) { - ptrdiff_t _Np = __end1 - __begin1; - if (_Np > 0) { - _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp)); - __begin2 += _Np; - } -} - -template <class _Alloc, class _Iter, class _Ptr> -_LIBCPP_INLINE_VISIBILITY -void __construct_range_forward(_Alloc& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2) { - typedef allocator_traits<_Alloc> _Traits; - for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) { - _Traits::construct(__a, _VSTD::__to_address(__begin2), *__begin1); - } -} - -template <class _Alloc, class _Source, class _Dest, - class _RawSource = typename remove_const<_Source>::type, - class _RawDest = typename remove_const<_Dest>::type, - class = - typename enable_if< - is_trivially_copy_constructible<_Dest>::value && - is_same<_RawSource, _RawDest>::value && - (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Dest*, _Source&>::value) - >::type> -_LIBCPP_INLINE_VISIBILITY -void __construct_range_forward(_Alloc&, _Source* __begin1, _Source* __end1, _Dest*& __begin2) { - ptrdiff_t _Np = __end1 - __begin1; - if (_Np > 0) { - _VSTD::memcpy(const_cast<_RawDest*>(__begin2), __begin1, _Np * sizeof(_Dest)); - __begin2 += _Np; - } -} - -template <class _Alloc, class _Ptr> -_LIBCPP_INLINE_VISIBILITY -void __construct_backward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2) { - static_assert(__is_cpp17_move_insertable<_Alloc>::value, - "The specified type does not meet the requirements of Cpp17MoveInsertable"); - typedef allocator_traits<_Alloc> _Traits; - while (__end1 != __begin1) { - _Traits::construct(__a, _VSTD::__to_address(__end2 - 1), -#ifdef _LIBCPP_NO_EXCEPTIONS - _VSTD::move(*--__end1) -#else - _VSTD::move_if_noexcept(*--__end1) -#endif - ); - --__end2; - } -} - -template <class _Alloc, class _Tp, class = typename enable_if< - (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) && - is_trivially_move_constructible<_Tp>::value ->::type> -_LIBCPP_INLINE_VISIBILITY -void __construct_backward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) { - ptrdiff_t _Np = __end1 - __begin1; - __end2 -= _Np; - if (_Np > 0) - _VSTD::memcpy(static_cast<void*>(__end2), static_cast<void const*>(__begin1), _Np * sizeof(_Tp)); -} - struct __destruct_n { private: @@ -1013,37 +926,6 @@ public: _LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); -// --- Helper for container swap -- -template <typename _Alloc> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type) -#if _LIBCPP_STD_VER > 11 - _NOEXCEPT -#else - _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) -#endif -{ - using _VSTD::swap; - swap(__a1, __a2); -} - -template <typename _Alloc> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {} - -template <typename _Alloc> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -void __swap_allocator(_Alloc & __a1, _Alloc & __a2) -#if _LIBCPP_STD_VER > 11 - _NOEXCEPT -#else - _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) -#endif -{ - _VSTD::__swap_allocator(__a1, __a2, - integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>()); -} - template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> > struct __noexcept_move_assign_container : public integral_constant<bool, _Traits::propagate_on_container_move_assignment::value diff --git a/contrib/llvm-project/libcxx/include/module.modulemap.in b/contrib/llvm-project/libcxx/include/module.modulemap.in index cbf0b4f7f16d..98485bcd93ab 100644 --- a/contrib/llvm-project/libcxx/include/module.modulemap.in +++ b/contrib/llvm-project/libcxx/include/module.modulemap.in @@ -832,6 +832,7 @@ module std [system] { module ranges_uninitialized_algorithms { private header "__memory/ranges_uninitialized_algorithms.h" } module raw_storage_iterator { private header "__memory/raw_storage_iterator.h" } module shared_ptr { private header "__memory/shared_ptr.h" } + module swap_allocator { private header "__memory/swap_allocator.h" } module temporary_buffer { private header "__memory/temporary_buffer.h" } module uninitialized_algorithms { private header "__memory/uninitialized_algorithms.h" } module unique_ptr { private header "__memory/unique_ptr.h" } @@ -1090,10 +1091,16 @@ module std [system] { module add_pointer { private header "__type_traits/add_pointer.h" } module add_rvalue_reference { private header "__type_traits/add_rvalue_reference.h" } module add_volatile { private header "__type_traits/add_volatile.h" } + module aligned_storage { private header "__type_traits/aligned_storage.h" } + module aligned_union { private header "__type_traits/aligned_union.h" } module alignment_of { private header "__type_traits/alignment_of.h" } module apply_cv { private header "__type_traits/apply_cv.h" } + module common_reference { private header "__type_traits/common_reference.h" } + module common_type { private header "__type_traits/common_type.h" } module conditional { private header "__type_traits/conditional.h" } module conjunction { private header "__type_traits/conjunction.h" } + module copy_cv { private header "__type_traits/copy_cv.h" } + module copy_cvref { private header "__type_traits/copy_cvref.h" } module decay { private header "__type_traits/decay.h" } module disjunction { private header "__type_traits/disjunction.h" } module enable_if { private header "__type_traits/enable_if.h" } @@ -1135,6 +1142,7 @@ module std [system] { module is_move_constructible { private header "__type_traits/is_move_constructible.h" } module is_nothrow_assignable { private header "__type_traits/is_nothrow_assignable.h" } module is_nothrow_constructible { private header "__type_traits/is_nothrow_constructible.h" } + module is_nothrow_convertible { private header "__type_traits/is_nothrow_convertible.h" } module is_nothrow_copy_assignable { private header "__type_traits/is_nothrow_copy_assignable.h" } module is_nothrow_copy_constructible { private header "__type_traits/is_nothrow_copy_constructible.h" } module is_nothrow_default_constructible { private header "__type_traits/is_nothrow_default_constructible.h" } @@ -1146,6 +1154,7 @@ module std [system] { module is_pod { private header "__type_traits/is_pod.h" } module is_pointer { private header "__type_traits/is_pointer.h" } module is_polymorphic { private header "__type_traits/is_polymorphic.h" } + module is_primary_template { private header "__type_traits/is_primary_template.h" } module is_reference { private header "__type_traits/is_reference.h" } module is_reference_wrapper { private header "__type_traits/is_reference_wrapper.h" } module is_referenceable { private header "__type_traits/is_referenceable.h" } @@ -1153,6 +1162,7 @@ module std [system] { module is_scalar { private header "__type_traits/is_scalar.h" } module is_scoped_enum { private header "__type_traits/is_scoped_enum.h" } module is_signed { private header "__type_traits/is_signed.h" } + module is_signed_integer { private header "__type_traits/is_signed_integer.h" } module is_standard_layout { private header "__type_traits/is_standard_layout.h" } module is_trivial { private header "__type_traits/is_trivial.h" } module is_trivially_assignable { private header "__type_traits/is_trivially_assignable.h" } @@ -1167,18 +1177,28 @@ module std [system] { module is_unbounded_array { private header "__type_traits/is_unbounded_array.h" } module is_union { private header "__type_traits/is_union.h" } module is_unsigned { private header "__type_traits/is_unsigned.h" } + module is_unsigned_integer { private header "__type_traits/is_unsigned_integer.h" } + module is_valid_expansion { private header "__type_traits/is_valid_expansion.h" } module is_void { private header "__type_traits/is_void.h" } module is_volatile { private header "__type_traits/is_volatile.h" } + module lazy { private header "__type_traits/lazy.h" } + module make_32_64_or_128_bit { private header "__type_traits/make_32_64_or_128_bit.h" } + module make_signed { private header "__type_traits/make_signed.h" } + module make_unsigned { private header "__type_traits/make_unsigned.h" } + module nat { private header "__type_traits/nat.h" } module negation { private header "__type_traits/negation.h" } + module promote { private header "__type_traits/promote.h" } module rank { private header "__type_traits/rank.h" } module remove_all_extents { private header "__type_traits/remove_all_extents.h" } module remove_const { private header "__type_traits/remove_const.h" } module remove_cv { private header "__type_traits/remove_cv.h" } + module remove_cvref { private header "__type_traits/remove_cvref.h" } module remove_extent { private header "__type_traits/remove_extent.h" } module remove_pointer { private header "__type_traits/remove_pointer.h" } module remove_reference { private header "__type_traits/remove_reference.h" } module remove_volatile { private header "__type_traits/remove_volatile.h" } module type_identity { private header "__type_traits/type_identity.h" } + module type_list { private header "__type_traits/type_list.h" } module underlying_type { private header "__type_traits/underlying_type.h" } module void_t { private header "__type_traits/void_t.h" } } diff --git a/contrib/llvm-project/libcxx/include/string b/contrib/llvm-project/libcxx/include/string index bb169a82c9e7..3723dc8a3938 100644 --- a/contrib/llvm-project/libcxx/include/string +++ b/contrib/llvm-project/libcxx/include/string @@ -532,6 +532,7 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); #include <__iterator/reverse_iterator.h> #include <__iterator/wrap_iter.h> #include <__memory/allocate_at_least.h> +#include <__memory/swap_allocator.h> #include <__string/char_traits.h> #include <__string/extern_template_lists.h> #include <__utility/auto_cast.h> diff --git a/contrib/llvm-project/libcxx/include/type_traits b/contrib/llvm-project/libcxx/include/type_traits index f7d81e65dd8e..3a086c595f92 100644 --- a/contrib/llvm-project/libcxx/include/type_traits +++ b/contrib/llvm-project/libcxx/include/type_traits @@ -425,8 +425,12 @@ namespace std #include <__type_traits/add_pointer.h> #include <__type_traits/add_rvalue_reference.h> #include <__type_traits/add_volatile.h> +#include <__type_traits/aligned_storage.h> +#include <__type_traits/aligned_union.h> #include <__type_traits/alignment_of.h> #include <__type_traits/apply_cv.h> +#include <__type_traits/common_reference.h> +#include <__type_traits/common_type.h> #include <__type_traits/conditional.h> #include <__type_traits/conjunction.h> #include <__type_traits/decay.h> @@ -469,6 +473,7 @@ namespace std #include <__type_traits/is_move_constructible.h> #include <__type_traits/is_nothrow_assignable.h> #include <__type_traits/is_nothrow_constructible.h> +#include <__type_traits/is_nothrow_convertible.h> #include <__type_traits/is_nothrow_copy_assignable.h> #include <__type_traits/is_nothrow_copy_constructible.h> #include <__type_traits/is_nothrow_default_constructible.h> @@ -503,6 +508,8 @@ namespace std #include <__type_traits/is_unsigned.h> #include <__type_traits/is_void.h> #include <__type_traits/is_volatile.h> +#include <__type_traits/make_signed.h> +#include <__type_traits/make_unsigned.h> #include <__type_traits/negation.h> #include <__type_traits/rank.h> #include <__type_traits/remove_all_extents.h> @@ -529,798 +536,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair; template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash; -template <template <class...> class _Func, class ..._Args> -struct _Lazy : _Func<_Args...> {}; - // Member detector base -template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> > -true_type __sfinae_test_impl(int); -template <template <class...> class, class ...> -false_type __sfinae_test_impl(...); - -template <template <class ...> class _Templ, class ..._Args> -using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0)); - template <class _Tp, bool> struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {}; -// is_same - -template <class _Tp> -using __test_for_primary_template = __enable_if_t< - _IsSame<_Tp, typename _Tp::__primary_template>::value - >; -template <class _Tp> -using __is_primary_template = _IsValidExpansion< - __test_for_primary_template, _Tp - >; - // is_integral -// [basic.fundamental] defines five standard signed integer types; -// __int128_t is an extended signed integer type. -// The signed and unsigned integer types, plus bool and the -// five types with "char" in their name, compose the "integral" types. - -template <class _Tp> struct __libcpp_is_signed_integer : public false_type {}; -template <> struct __libcpp_is_signed_integer<signed char> : public true_type {}; -template <> struct __libcpp_is_signed_integer<signed short> : public true_type {}; -template <> struct __libcpp_is_signed_integer<signed int> : public true_type {}; -template <> struct __libcpp_is_signed_integer<signed long> : public true_type {}; -template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {}; -#ifndef _LIBCPP_HAS_NO_INT128 -template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {}; -#endif - -template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {}; -template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {}; -template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {}; -template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {}; -template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {}; -template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {}; -#ifndef _LIBCPP_HAS_NO_INT128 -template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {}; -#endif - template <class _Tp> struct __unconstref { typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type; }; -template <class _Tp> -using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv<typename remove_reference<_Tp>::type>::type; - -// __is_same_uncvref - -template <class _Tp, class _Up> -struct __is_same_uncvref : _IsSame<__uncvref_t<_Tp>, __uncvref_t<_Up> > {}; - -#if _LIBCPP_STD_VER > 17 -// remove_cvref - same as __uncvref -template <class _Tp> -struct remove_cvref { - using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>; -}; - -template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type; -#endif - -// is_nothrow_convertible - -#if _LIBCPP_STD_VER > 17 - -template <typename _Tp> -static void __test_noexcept(_Tp) noexcept; - -template<typename _Fm, typename _To> -static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))> -__is_nothrow_convertible_test(); - -template <typename _Fm, typename _To> -struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>()) -{ }; - -template <typename _Fm, typename _To> -struct is_nothrow_convertible : _Or< - _And<is_void<_To>, is_void<_Fm>>, - _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>> ->::type { }; - -template <typename _Fm, typename _To> -inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value; - -#endif // _LIBCPP_STD_VER > 17 - -// aligned_storage - -template <class _Hp, class _Tp> -struct __type_list -{ - typedef _Hp _Head; - typedef _Tp _Tail; -}; - -template <class _Tp> -struct __align_type -{ - static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp); - typedef _Tp type; -}; - -struct __struct_double {long double __lx;}; -struct __struct_double4 {double __lx[4];}; - -typedef - __type_list<__align_type<unsigned char>, - __type_list<__align_type<unsigned short>, - __type_list<__align_type<unsigned int>, - __type_list<__align_type<unsigned long>, - __type_list<__align_type<unsigned long long>, - __type_list<__align_type<double>, - __type_list<__align_type<long double>, - __type_list<__align_type<__struct_double>, - __type_list<__align_type<__struct_double4>, - __type_list<__align_type<int*>, - __nat - > > > > > > > > > > __all_types; - -template <size_t _Align> -struct _ALIGNAS(_Align) __fallback_overaligned {}; - -template <class _TL, size_t _Align> struct __find_pod; - -template <class _Hp, size_t _Align> -struct __find_pod<__type_list<_Hp, __nat>, _Align> -{ - typedef typename conditional< - _Align == _Hp::value, - typename _Hp::type, - __fallback_overaligned<_Align> - >::type type; -}; - -template <class _Hp, class _Tp, size_t _Align> -struct __find_pod<__type_list<_Hp, _Tp>, _Align> -{ - typedef typename conditional< - _Align == _Hp::value, - typename _Hp::type, - typename __find_pod<_Tp, _Align>::type - >::type type; -}; - -template <class _TL, size_t _Len> struct __find_max_align; - -template <class _Hp, size_t _Len> -struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; - -template <size_t _Len, size_t _A1, size_t _A2> -struct __select_align -{ -private: - static const size_t __min = _A2 < _A1 ? _A2 : _A1; - static const size_t __max = _A1 < _A2 ? _A2 : _A1; -public: - static const size_t value = _Len < __max ? __min : __max; -}; - -template <class _Hp, class _Tp, size_t _Len> -struct __find_max_align<__type_list<_Hp, _Tp>, _Len> - : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; - -template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> -struct _LIBCPP_TEMPLATE_VIS aligned_storage -{ - typedef typename __find_pod<__all_types, _Align>::type _Aligner; - union type - { - _Aligner __align; - unsigned char __data[(_Len + _Align - 1)/_Align * _Align]; - }; -}; - -#if _LIBCPP_STD_VER > 11 -template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> - using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; -#endif - -#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ -template <size_t _Len>\ -struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\ -{\ - struct _ALIGNAS(n) type\ - {\ - unsigned char __lx[(_Len + n - 1)/n * n];\ - };\ -} - -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); -// PE/COFF does not support alignment beyond 8192 (=0x2000) -#if !defined(_LIBCPP_OBJECT_FORMAT_COFF) -_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); -#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF) - -#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION - - -// aligned_union - -template <size_t _I0, size_t ..._In> -struct __static_max; - -template <size_t _I0> -struct __static_max<_I0> -{ - static const size_t value = _I0; -}; - -template <size_t _I0, size_t _I1, size_t ..._In> -struct __static_max<_I0, _I1, _In...> -{ - static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : - __static_max<_I1, _In...>::value; -}; - -template <size_t _Len, class _Type0, class ..._Types> -struct aligned_union -{ - static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), - _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value; - static const size_t __len = __static_max<_Len, sizeof(_Type0), - sizeof(_Types)...>::value; - typedef typename aligned_storage<__len, alignment_value>::type type; -}; - -#if _LIBCPP_STD_VER > 11 -template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; -#endif - -template <class _Tp> -struct __numeric_type -{ - static void __test(...); - static float __test(float); - static double __test(char); - static double __test(int); - static double __test(unsigned); - static double __test(long); - static double __test(unsigned long); - static double __test(long long); - static double __test(unsigned long long); - static double __test(double); - static long double __test(long double); - - typedef decltype(__test(declval<_Tp>())) type; - static const bool value = _IsNotSame<type, void>::value; -}; - -template <> -struct __numeric_type<void> -{ - static const bool value = true; -}; - -// __promote - -template <class _A1, class _A2 = void, class _A3 = void, - bool = __numeric_type<_A1>::value && - __numeric_type<_A2>::value && - __numeric_type<_A3>::value> -class __promote_imp -{ -public: - static const bool value = false; -}; - -template <class _A1, class _A2, class _A3> -class __promote_imp<_A1, _A2, _A3, true> -{ -private: - typedef typename __promote_imp<_A1>::type __type1; - typedef typename __promote_imp<_A2>::type __type2; - typedef typename __promote_imp<_A3>::type __type3; -public: - typedef decltype(__type1() + __type2() + __type3()) type; - static const bool value = true; -}; - -template <class _A1, class _A2> -class __promote_imp<_A1, _A2, void, true> -{ -private: - typedef typename __promote_imp<_A1>::type __type1; - typedef typename __promote_imp<_A2>::type __type2; -public: - typedef decltype(__type1() + __type2()) type; - static const bool value = true; -}; - -template <class _A1> -class __promote_imp<_A1, void, void, true> -{ -public: - typedef typename __numeric_type<_A1>::type type; - static const bool value = true; -}; - -template <class _A1, class _A2 = void, class _A3 = void> -class __promote : public __promote_imp<_A1, _A2, _A3> {}; - -// make_signed / make_unsigned - -typedef - __type_list<signed char, - __type_list<signed short, - __type_list<signed int, - __type_list<signed long, - __type_list<signed long long, -#ifndef _LIBCPP_HAS_NO_INT128 - __type_list<__int128_t, -#endif - __nat -#ifndef _LIBCPP_HAS_NO_INT128 - > -#endif - > > > > > __signed_types; - -typedef - __type_list<unsigned char, - __type_list<unsigned short, - __type_list<unsigned int, - __type_list<unsigned long, - __type_list<unsigned long long, -#ifndef _LIBCPP_HAS_NO_INT128 - __type_list<__uint128_t, -#endif - __nat -#ifndef _LIBCPP_HAS_NO_INT128 - > -#endif - > > > > > __unsigned_types; - -template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; - -template <class _Hp, class _Tp, size_t _Size> -struct __find_first<__type_list<_Hp, _Tp>, _Size, true> -{ - typedef _LIBCPP_NODEBUG _Hp type; -}; - -template <class _Hp, class _Tp, size_t _Size> -struct __find_first<__type_list<_Hp, _Tp>, _Size, false> -{ - typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type; -}; - -template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> -struct __make_signed {}; - -template <class _Tp> -struct __make_signed<_Tp, true> -{ - typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; -}; - -template <> struct __make_signed<bool, true> {}; -template <> struct __make_signed< signed short, true> {typedef short type;}; -template <> struct __make_signed<unsigned short, true> {typedef short type;}; -template <> struct __make_signed< signed int, true> {typedef int type;}; -template <> struct __make_signed<unsigned int, true> {typedef int type;}; -template <> struct __make_signed< signed long, true> {typedef long type;}; -template <> struct __make_signed<unsigned long, true> {typedef long type;}; -template <> struct __make_signed< signed long long, true> {typedef long long type;}; -template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; -#ifndef _LIBCPP_HAS_NO_INT128 -template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;}; -template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;}; -#endif - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS make_signed -{ - typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; -}; - -#if _LIBCPP_STD_VER > 11 -template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type; -#endif - -template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> -struct __make_unsigned {}; - -template <class _Tp> -struct __make_unsigned<_Tp, true> -{ - typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; -}; - -template <> struct __make_unsigned<bool, true> {}; -template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; -template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; -template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; -template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; -template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; -template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; -template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; -template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; -#ifndef _LIBCPP_HAS_NO_INT128 -template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; -template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; -#endif - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS make_unsigned -{ - typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; -}; - -#if _LIBCPP_STD_VER > 11 -template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; -#endif - -#ifndef _LIBCPP_CXX03_LANG -template <class _Tp> -_LIBCPP_HIDE_FROM_ABI constexpr -typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept { - return static_cast<typename make_unsigned<_Tp>::type>(__x); -} -#endif - -template <class _Tp, class _Up> -using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, typename make_unsigned<_Up>::type, _Up>; - -/// Helper to promote an integral to smallest 32, 64, or 128 bit representation. -/// -/// The restriction is the same as the integral version of to_char. -template <class _Tp> -#if _LIBCPP_STD_VER > 17 - requires (is_signed_v<_Tp> || is_unsigned_v<_Tp> || is_same_v<_Tp, char>) -#endif -using __make_32_64_or_128_bit_t = - __copy_unsigned_t<_Tp, - __conditional_t<sizeof(_Tp) <= sizeof(int32_t), int32_t, - __conditional_t<sizeof(_Tp) <= sizeof(int64_t), int64_t, -#ifndef _LIBCPP_HAS_NO_INT128 - __conditional_t<sizeof(_Tp) <= sizeof(__int128_t), __int128_t, - /* else */ void> -#else - /* else */ void -#endif - > > - >; - -#if _LIBCPP_STD_VER > 17 -// Let COND_RES(X, Y) be: -template <class _Tp, class _Up> -using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>()); - -template <class _Tp, class _Up, class = void> -struct __common_type3 {}; - -// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..." -template <class _Tp, class _Up> -struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> -{ - using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>; -}; - -template <class _Tp, class _Up, class = void> -struct __common_type2_imp : __common_type3<_Tp, _Up> {}; -#else -template <class _Tp, class _Up, class = void> -struct __common_type2_imp {}; -#endif - -// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..." -template <class _Tp, class _Up> -struct __common_type2_imp<_Tp, _Up, - typename __void_t<decltype( - true ? declval<_Tp>() : declval<_Up>() - )>::type> -{ - typedef _LIBCPP_NODEBUG typename decay<decltype( - true ? declval<_Tp>() : declval<_Up>() - )>::type type; -}; - -template <class, class = void> -struct __common_type_impl {}; - -// Clang provides variadic templates in C++03 as an extension. -#if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__) -# define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__ -template <class... _Tp> -struct __common_types; -template <class... _Tp> -struct _LIBCPP_TEMPLATE_VIS common_type; -#else -# define _LIBCPP_OPTIONAL_PACK(...) -struct __no_arg; -template <class _Tp, class _Up, class = __no_arg> -struct __common_types; -template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg, - class _Unused = __no_arg> -struct common_type { - static_assert(sizeof(_Unused) == 0, - "common_type accepts at most 3 arguments in C++03"); -}; -#endif // _LIBCPP_CXX03_LANG - -template <class _Tp, class _Up> -struct __common_type_impl< - __common_types<_Tp, _Up>, - typename __void_t<typename common_type<_Tp, _Up>::type>::type> -{ - typedef typename common_type<_Tp, _Up>::type type; -}; - -template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> -struct __common_type_impl< - __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>, - typename __void_t<typename common_type<_Tp, _Up>::type>::type> - : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type, - _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > { -}; - -// bullet 1 - sizeof...(Tp) == 0 - -template <> -struct _LIBCPP_TEMPLATE_VIS common_type<> {}; - -// bullet 2 - sizeof...(Tp) == 1 - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> - : public common_type<_Tp, _Tp> {}; - -// bullet 3 - sizeof...(Tp) == 2 - -// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..." -template <class _Tp, class _Up> -struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> - : conditional< - _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value, - __common_type2_imp<_Tp, _Up>, - common_type<typename decay<_Tp>::type, typename decay<_Up>::type> - >::type -{}; - -// bullet 4 - sizeof...(Tp) > 2 - -template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> -struct _LIBCPP_TEMPLATE_VIS - common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> - : __common_type_impl< - __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {}; - -#undef _LIBCPP_OPTIONAL_PACK - -#if _LIBCPP_STD_VER > 11 -template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; -#endif - -// Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's -// top-level cv-qualifiers. -template <class _From, class _To> -struct __copy_cv -{ - using type = _To; -}; - -template <class _From, class _To> -struct __copy_cv<const _From, _To> -{ - using type = typename add_const<_To>::type; -}; - -template <class _From, class _To> -struct __copy_cv<volatile _From, _To> -{ - using type = typename add_volatile<_To>::type; -}; - -template <class _From, class _To> -struct __copy_cv<const volatile _From, _To> -{ - using type = typename add_cv<_To>::type; -}; - -template <class _From, class _To> -using __copy_cv_t = typename __copy_cv<_From, _To>::type; - -template <class _From, class _To> -struct __copy_cvref -{ - using type = __copy_cv_t<_From, _To>; -}; - -template <class _From, class _To> -struct __copy_cvref<_From&, _To> -{ - using type = typename add_lvalue_reference<__copy_cv_t<_From, _To> >::type; -}; - -template <class _From, class _To> -struct __copy_cvref<_From&&, _To> -{ - using type = typename add_rvalue_reference<__copy_cv_t<_From, _To> >::type; -}; - -template <class _From, class _To> -using __copy_cvref_t = typename __copy_cvref<_From, _To>::type; - - -// common_reference -#if _LIBCPP_STD_VER > 17 -// Let COND_RES(X, Y) be: -template <class _Xp, class _Yp> -using __cond_res = - decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()()); - -// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U` -// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type -// `U`. -// [Note: `XREF(A)` is `__xref<A>::template __apply`] -template <class _Tp> -struct __xref { - template<class _Up> - using __apply = __copy_cvref_t<_Tp, _Up>; -}; - -// Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>, -// and let COMMON-REF(A, B) be: -template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>> -struct __common_ref; - -template<class _Xp, class _Yp> -using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type; - -template<class _Xp, class _Yp> -using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>; - - -// If A and B are both lvalue reference types, COMMON-REF(A, B) is -// COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type. -template<class _Ap, class _Bp, class _Xp, class _Yp> -requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>> -struct __common_ref<_Ap&, _Bp&, _Xp, _Yp> -{ - using __type = __cv_cond_res<_Xp, _Yp>; -}; - -// Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ... -template <class _Xp, class _Yp> -using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&; - - -// .... If A and B are both rvalue reference types, C is well-formed, and -// is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C. -template<class _Ap, class _Bp, class _Xp, class _Yp> -requires - requires { typename __common_ref_C<_Xp, _Yp>; } && - is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> && - is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>> -struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp> -{ - using __type = __common_ref_C<_Xp, _Yp>; -}; - -// Otherwise, let D be COMMON-REF(const X&, Y&). ... -template <class _Tp, class _Up> -using __common_ref_D = __common_ref_t<const _Tp&, _Up&>; - -// ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and -// is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D. -template<class _Ap, class _Bp, class _Xp, class _Yp> -requires requires { typename __common_ref_D<_Xp, _Yp>; } && - is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>> -struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp> -{ - using __type = __common_ref_D<_Xp, _Yp>; -}; - -// Otherwise, if A is an lvalue reference and B is an rvalue reference, then -// COMMON-REF(A, B) is COMMON-REF(B, A). -template<class _Ap, class _Bp, class _Xp, class _Yp> -struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {}; - -// Otherwise, COMMON-REF(A, B) is ill-formed. -template<class _Ap, class _Bp, class _Xp, class _Yp> -struct __common_ref {}; - -// Note C: For the common_reference trait applied to a parameter pack [...] - -template <class...> -struct common_reference; - -template <class... _Types> -using common_reference_t = typename common_reference<_Types...>::type; - -// bullet 1 - sizeof...(T) == 0 -template<> -struct common_reference<> {}; - -// bullet 2 - sizeof...(T) == 1 -template <class _Tp> -struct common_reference<_Tp> -{ - using type = _Tp; -}; - -// bullet 3 - sizeof...(T) == 2 -template <class _Tp, class _Up> struct __common_reference_sub_bullet3; -template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {}; -template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {}; - -// sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then -// the member typedef `type` denotes that type. -template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {}; - -template <class _Tp, class _Up> -requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; } -struct __common_reference_sub_bullet1<_Tp, _Up> -{ - using type = __common_ref_t<_Tp, _Up>; -}; - -// sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type -// is well-formed, then the member typedef `type` denotes that type. -template <class, class, template <class> class, template <class> class> struct basic_common_reference {}; - -template <class _Tp, class _Up> -using __basic_common_reference_t = typename basic_common_reference< - remove_cvref_t<_Tp>, remove_cvref_t<_Up>, - __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type; - -template <class _Tp, class _Up> -requires requires { typename __basic_common_reference_t<_Tp, _Up>; } -struct __common_reference_sub_bullet2<_Tp, _Up> -{ - using type = __basic_common_reference_t<_Tp, _Up>; -}; - -// sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed, -// then the member typedef `type` denotes that type. -template <class _Tp, class _Up> -requires requires { typename __cond_res<_Tp, _Up>; } -struct __common_reference_sub_bullet3<_Tp, _Up> -{ - using type = __cond_res<_Tp, _Up>; -}; - - -// sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed, -// then the member typedef `type` denotes that type. -// - Otherwise, there shall be no member `type`. -template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {}; - -// bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if -// any, as `common_reference_t<C, Rest...>`. -template <class _Tp, class _Up, class _Vp, class... _Rest> -requires requires { typename common_reference_t<_Tp, _Up>; } -struct common_reference<_Tp, _Up, _Vp, _Rest...> - : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...> -{}; - -// bullet 5 - Otherwise, there shall be no member `type`. -template <class...> struct common_reference {}; - -#endif // _LIBCPP_STD_VER > 17 - #ifndef _LIBCPP_CXX03_LANG // First of all, we can't implement this check in C++03 mode because the {} // default initialization syntax isn't valid. diff --git a/contrib/llvm-project/libcxx/include/vector b/contrib/llvm-project/libcxx/include/vector index 14f586c9bfd7..30030f85e43c 100644 --- a/contrib/llvm-project/libcxx/include/vector +++ b/contrib/llvm-project/libcxx/include/vector @@ -291,6 +291,8 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20 #include <__iterator/reverse_iterator.h> #include <__iterator/wrap_iter.h> #include <__memory/allocate_at_least.h> +#include <__memory/pointer_traits.h> +#include <__memory/swap_allocator.h> #include <__split_buffer> #include <__utility/forward.h> #include <__utility/move.h> @@ -895,9 +897,11 @@ template <class _Tp, class _Allocator> void vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) { - __annotate_delete(); - _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, this->__end_, __v.__begin_); + using _RevIter = std::reverse_iterator<pointer>; + __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept( + __alloc(), _RevIter(__end_), _RevIter(__begin_), _RevIter(__v.__begin_)) + .base(); _VSTD::swap(this->__begin_, __v.__begin_); _VSTD::swap(this->__end_, __v.__end_); _VSTD::swap(this->__end_cap(), __v.__end_cap()); @@ -912,8 +916,11 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a { __annotate_delete(); pointer __r = __v.__begin_; - _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, __p, __v.__begin_); - _VSTD::__construct_forward_with_exception_guarantees(this->__alloc(), __p, this->__end_, __v.__end_); + using _RevIter = std::reverse_iterator<pointer>; + __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept( + __alloc(), _RevIter(__p), _RevIter(__begin_), _RevIter(__v.__begin_)) + .base(); + __v.__end_ = std::__uninitialized_allocator_move_if_noexcept(__alloc(), __p, __end_, __v.__end_); _VSTD::swap(this->__begin_, __v.__begin_); _VSTD::swap(this->__end_, __v.__end_); _VSTD::swap(this->__end_cap(), __v.__end_cap()); @@ -1001,8 +1008,8 @@ typename enable_if >::type vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n) { - _ConstructTransaction __tx(*this, __n); - _VSTD::__construct_range_forward(this->__alloc(), __first, __last, __tx.__pos_); + _ConstructTransaction __tx(*this, __n); + __tx.__pos_ = std::__uninitialized_allocator_copy(__alloc(), __first, __last, __tx.__pos_); } // Default constructs __n objects starting at __end_ diff --git a/contrib/llvm-project/libcxx/src/assert.cpp b/contrib/llvm-project/libcxx/src/assert.cpp index 54459800728b..c218645f1771 100644 --- a/contrib/llvm-project/libcxx/src/assert.cpp +++ b/contrib/llvm-project/libcxx/src/assert.cpp @@ -8,14 +8,57 @@ #include <__assert> #include <__config> +#include <cstdarg> #include <cstdio> #include <cstdlib> +#ifdef __BIONIC__ +# include <android/api-level.h> +# include <syslog.h> +extern "C" void android_set_abort_message(const char* msg); +#endif + +#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>) +# include <CrashReporterClient.h> +#endif + _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_WEAK -void __libcpp_assertion_handler(char const* __file, int __line, char const* __expression, char const* __message) { - std::fprintf(stderr, "%s:%d: libc++ assertion '%s' failed. %s\n", __file, __line, __expression, __message); +void __libcpp_assertion_handler(char const* format, ...) { + // Write message to stderr. We do this before formatting into a + // buffer so that we still get some information out if that fails. + { + va_list list; + va_start(list, format); + std::vfprintf(stderr, format, list); + va_end(list); + } + + // Format the arguments into an allocated buffer for CrashReport & friends. + // We leak the buffer on purpose, since we're about to abort() anyway. + char* buffer; (void)buffer; + va_list list; + va_start(list, format); + +#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>) + // Note that we should technically synchronize accesses here (by e.g. taking a lock), + // however concretely we're only setting a pointer, so the likelihood of a race here + // is low. + vasprintf(&buffer, format, list); + CRSetCrashLogMessage(buffer); +#elif defined(__BIONIC__) + // Show error in tombstone. + vasprintf(&buffer, format, list); + android_set_abort_message(buffer); + + // Show error in logcat. + openlog("libc++", 0, 0); + syslog(LOG_CRIT, "%s", buffer); + closelog(); +#endif + va_end(list); + std::abort(); } |