Skip to content

Update libcxx & libcxxabi to LLVM 17.0.4 #20707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions system/lib/libcxx/CREDITS.TXT
Original file line number Diff line number Diff line change
@@ -92,6 +92,11 @@ E: [email protected]
E: [email protected]
D: Implemented floating-point to_chars.

N: Damien Lebrun-Grandie
E: [email protected]
E: [email protected]
D: Implementation of mdspan.

N: Microsoft Corporation
D: Contributed floating-point to_chars.

@@ -149,6 +154,10 @@ N: Stephan Tolksdorf
E: [email protected]
D: Minor <atomic> fix

N: Christian Trott
E: [email protected]
D: Implementation of mdspan.

N: Ruben Van Boxem
E: vanboxem dot ruben at gmail dot com
D: Initial Windows patches.
5 changes: 5 additions & 0 deletions system/lib/libcxx/include/__algorithm/adjacent_find.h
Original file line number Diff line number Diff line change
@@ -20,6 +20,9 @@
# pragma GCC system_header
#endif

_LIBCPP_PUSH_MACROS
#include <__undef_macros>

_LIBCPP_BEGIN_NAMESPACE_STD

template <class _Iter, class _Sent, class _BinaryPredicate>
@@ -50,4 +53,6 @@ adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {

_LIBCPP_END_NAMESPACE_STD

_LIBCPP_POP_MACROS

#endif // _LIBCPP___ALGORITHM_ADJACENT_FIND_H
2 changes: 1 addition & 1 deletion system/lib/libcxx/include/__algorithm/all_of.h
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD

template <class _InputIterator, class _Predicate>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
for (; __first != __last; ++__first)
if (!__pred(*__first))
3 changes: 1 addition & 2 deletions system/lib/libcxx/include/__algorithm/binary_search.h
Original file line number Diff line number Diff line change
@@ -37,8 +37,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
return std::binary_search(__first, __last, __value,
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
return std::binary_search(__first, __last, __value, __less<>());
}

_LIBCPP_END_NAMESPACE_STD
6 changes: 3 additions & 3 deletions system/lib/libcxx/include/__algorithm/clamp.h
Original file line number Diff line number Diff line change
@@ -19,14 +19,14 @@

_LIBCPP_BEGIN_NAMESPACE_STD

#if _LIBCPP_STD_VER > 14
#if _LIBCPP_STD_VER >= 17
template<class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
_LIBCPP_INLINE_VISIBILITY constexpr
const _Tp&
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
{
_LIBCPP_ASSERT(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
_LIBCPP_ASSERT_UNCATEGORIZED(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v;

}
@@ -37,7 +37,7 @@ _LIBCPP_INLINE_VISIBILITY constexpr
const _Tp&
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
{
return _VSTD::clamp(__v, __lo, __hi, __less<_Tp>());
return _VSTD::clamp(__v, __lo, __hi, __less<>());
}
#endif

47 changes: 14 additions & 33 deletions system/lib/libcxx/include/__algorithm/comp.h
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@
#define _LIBCPP___ALGORITHM_COMP_H

#include <__config>
#include <__type_traits/integral_constant.h>
#include <__type_traits/predicate_traits.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -24,41 +26,20 @@ struct __equal_to {
}
};

template <class _T1, class _T2 = _T1>
struct __less
{
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
template <class _Lhs, class _Rhs>
struct __is_trivial_equality_predicate<__equal_to, _Lhs, _Rhs> : true_type {};

_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}
// The definition is required because __less is part of the ABI, but it's empty
// because all comparisons should be transparent.
template <class _T1 = void, class _T2 = _T1>
struct __less {};

_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}

_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}
};

template <class _T1>
struct __less<_T1, _T1>
{
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
};

template <class _T1>
struct __less<const _T1, _T1>
{
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
};

template <class _T1>
struct __less<_T1, const _T1>
{
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
template <>
struct __less<void, void> {
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __lhs, const _Up& __rhs) const {
return __lhs < __rhs;
}
};

_LIBCPP_END_NAMESPACE_STD
13 changes: 6 additions & 7 deletions system/lib/libcxx/include/__algorithm/comp_ref_type.h
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@
#ifndef _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
#define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H

#include <__assert>
#include <__config>
#include <__debug>
#include <__utility/declval.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -23,11 +23,10 @@ template <class _Compare>
struct __debug_less
{
_Compare &__comp_;
_LIBCPP_CONSTEXPR_SINCE_CXX14
__debug_less(_Compare& __c) : __comp_(__c) {}
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI __debug_less(_Compare& __c) : __comp_(__c) {}

template <class _Tp, class _Up>
_LIBCPP_CONSTEXPR_SINCE_CXX14
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
bool operator()(const _Tp& __x, const _Up& __y)
{
bool __r = __comp_(__x, __y);
@@ -37,7 +36,7 @@ struct __debug_less
}

template <class _Tp, class _Up>
_LIBCPP_CONSTEXPR_SINCE_CXX14
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
bool operator()(_Tp& __x, _Up& __y)
{
bool __r = __comp_(__x, __y);
@@ -52,7 +51,7 @@ struct __debug_less
decltype((void)std::declval<_Compare&>()(
std::declval<_LHS &>(), std::declval<_RHS &>()))
__do_compare_assert(int, _LHS & __l, _RHS & __r) {
_LIBCPP_DEBUG_ASSERT(!__comp_(__l, __r),
_LIBCPP_ASSERT_UNCATEGORIZED(!__comp_(__l, __r),
"Comparator does not induce a strict weak ordering");
(void)__l;
(void)__r;
@@ -66,7 +65,7 @@ struct __debug_less

// Pass the comparator by lvalue reference. Or in debug mode, using a
// debugging wrapper that stores a reference.
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
#if _LIBCPP_ENABLE_DEBUG_MODE
template <class _Comp>
using __comp_ref_type = __debug_less<_Comp>;
#else
40 changes: 19 additions & 21 deletions system/lib/libcxx/include/__algorithm/copy.h
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_COPY_H

#include <__algorithm/copy_move_common.h>
#include <__algorithm/for_each_segment.h>
#include <__algorithm/iterator_operations.h>
#include <__algorithm/min.h>
#include <__config>
@@ -44,36 +45,34 @@ struct __copy_loop {
return std::make_pair(std::move(__first), std::move(__result));
}

template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
operator()(_InIter __first, _InIter __last, _OutIter __result) const {
template <class _InIter, class _OutIter>
struct _CopySegment {
using _Traits = __segmented_iterator_traits<_InIter>;
auto __sfirst = _Traits::__segment(__first);
auto __slast = _Traits::__segment(__last);
if (__sfirst == __slast) {
auto __iters = std::__copy<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
return std::make_pair(__last, std::move(__iters.second));
}

__result = std::__copy<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__sfirst), std::move(__result)).second;
++__sfirst;
while (__sfirst != __slast) {
__result =
std::__copy<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__end(__sfirst), std::move(__result)).second;
++__sfirst;
_OutIter& __result_;

_LIBCPP_HIDE_FROM_ABI _CopySegment(_OutIter& __result) : __result_(__result) {}

_LIBCPP_HIDE_FROM_ABI void
operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) {
__result_ = std::__copy<_AlgPolicy>(__lfirst, __llast, std::move(__result_)).second;
}
__result =
std::__copy<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__local(__last), std::move(__result)).second;
};

template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
operator()(_InIter __first, _InIter __last, _OutIter __result) const {
std::__for_each_segment(__first, __last, _CopySegment<_InIter, _OutIter>(__result));
return std::make_pair(__last, std::move(__result));
}

template <class _InIter,
class _OutIter,
__enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
__enable_if_t<__has_random_access_iterator_category<_InIter>::value &&
!__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
operator()(_InIter __first, _InIter __last, _OutIter __result) {
operator()(_InIter __first, _InIter __last, _OutIter __result) const {
using _Traits = __segmented_iterator_traits<_OutIter>;
using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;

@@ -98,8 +97,7 @@ struct __copy_loop {

struct __copy_trivial {
// At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
template <class _In, class _Out,
__enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
operator()(_In* __first, _In* __last, _Out* __result) const {
return std::__copy_trivial_impl(__first, __last, __result);
4 changes: 2 additions & 2 deletions system/lib/libcxx/include/__algorithm/copy_backward.h
Original file line number Diff line number Diff line change
@@ -76,11 +76,11 @@ struct __copy_backward_loop {

template <class _InIter,
class _OutIter,
__enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
__enable_if_t<__has_random_access_iterator_category<_InIter>::value &&
!__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
operator()(_InIter __first, _InIter __last, _OutIter __result) {
operator()(_InIter __first, _InIter __last, _OutIter __result) const {
using _Traits = __segmented_iterator_traits<_OutIter>;
auto __orig_last = __last;
auto __segment_iterator = _Traits::__segment(__result);
33 changes: 4 additions & 29 deletions system/lib/libcxx/include/__algorithm/copy_move_common.h
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__memory/pointer_traits.h>
#include <__string/constexpr_c_functions.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_always_bitcastable.h>
#include <__type_traits/is_constant_evaluated.h>
@@ -61,7 +62,8 @@ template <class _In, class _Out>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
__copy_trivial_impl(_In* __first, _In* __last, _Out* __result) {
const size_t __n = static_cast<size_t>(__last - __first);
::__builtin_memmove(__result, __first, __n * sizeof(_Out));

std::__constexpr_memmove(__result, __first, __element_count(__n));

return std::make_pair(__last, __result + __n);
}
@@ -72,7 +74,7 @@ __copy_backward_trivial_impl(_In* __first, _In* __last, _Out* __result) {
const size_t __n = static_cast<size_t>(__last - __first);
__result -= __n;

::__builtin_memmove(__result, __first, __n * sizeof(_Out));
std::__constexpr_memmove(__result, __first, __element_count(__n));

return std::make_pair(__last, __result);
}
@@ -119,16 +121,6 @@ __unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) {
return _Algorithm()(std::move(__first), std::move(__last), std::move(__out_first));
}

template <class _IterOps, class _InValue, class _OutIter, class = void>
struct __can_copy_without_conversion : false_type {};

template <class _IterOps, class _InValue, class _OutIter>
struct __can_copy_without_conversion<
_IterOps,
_InValue,
_OutIter,
__enable_if_t<is_same<_InValue, typename _IterOps::template __value_type<_OutIter> >::value> > : true_type {};

template <class _AlgPolicy,
class _NaiveAlgorithm,
class _OptimizedAlgorithm,
@@ -137,23 +129,6 @@ template <class _AlgPolicy,
class _OutIter>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
__dispatch_copy_or_move(_InIter __first, _Sent __last, _OutIter __out_first) {
#ifdef _LIBCPP_COMPILER_GCC
// GCC doesn't support `__builtin_memmove` during constant evaluation.
if (__libcpp_is_constant_evaluated()) {
return std::__unwrap_and_dispatch<_NaiveAlgorithm>(std::move(__first), std::move(__last), std::move(__out_first));
}
#else
// In Clang, `__builtin_memmove` only supports fully trivially copyable types (just having trivial copy assignment is
// insufficient). Also, conversions are not supported.
if (__libcpp_is_constant_evaluated()) {
using _InValue = typename _IterOps<_AlgPolicy>::template __value_type<_InIter>;
if (!is_trivially_copyable<_InValue>::value ||
!__can_copy_without_conversion<_IterOps<_AlgPolicy>, _InValue, _OutIter>::value) {
return std::__unwrap_and_dispatch<_NaiveAlgorithm>(std::move(__first), std::move(__last), std::move(__out_first));
}
}
#endif // _LIBCPP_COMPILER_GCC

using _Algorithm = __overload<_NaiveAlgorithm, _OptimizedAlgorithm>;
return std::__unwrap_and_dispatch<_Algorithm>(std::move(__first), std::move(__last), std::move(__out_first));
}
8 changes: 4 additions & 4 deletions system/lib/libcxx/include/__algorithm/copy_n.h
Original file line number Diff line number Diff line change
@@ -12,8 +12,8 @@
#include <__algorithm/copy.h>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__type_traits/enable_if.h>
#include <__utility/convert_to_integral.h>
#include <type_traits>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -25,8 +25,8 @@ template<class _InputIterator, class _Size, class _OutputIterator>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
__is_cpp17_input_iterator<_InputIterator>::value &&
!__is_cpp17_random_access_iterator<_InputIterator>::value,
__has_input_iterator_category<_InputIterator>::value &&
!__has_random_access_iterator_category<_InputIterator>::value,
_OutputIterator
>::type
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
@@ -51,7 +51,7 @@ template<class _InputIterator, class _Size, class _OutputIterator>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
__is_cpp17_random_access_iterator<_InputIterator>::value,
__has_random_access_iterator_category<_InputIterator>::value,
_OutputIterator
>::type
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
Loading