Skip to content

Commit 97f37e1

Browse files
authored
Update libcxx & libcxxabi to LLVM 17.0.4 (#20707)
On top of the main library code changes, each fix that was necessary for Emscripten has own commit message within the PR.
1 parent 8aed097 commit 97f37e1

File tree

968 files changed

+49640
-24498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

968 files changed

+49640
-24498
lines changed

system/lib/libcxx/CREDITS.TXT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ E: stl@microsoft.com
9292
E: stl@nuwen.net
9393
D: Implemented floating-point to_chars.
9494

95+
N: Damien Lebrun-Grandie
96+
E: dalg24@gmail.com
97+
E: lebrungrandt@ornl.gov
98+
D: Implementation of mdspan.
99+
95100
N: Microsoft Corporation
96101
D: Contributed floating-point to_chars.
97102

@@ -149,6 +154,10 @@ N: Stephan Tolksdorf
149154
E: st@quanttec.com
150155
D: Minor <atomic> fix
151156

157+
N: Christian Trott
158+
E: crtrott@sandia.gov
159+
D: Implementation of mdspan.
160+
152161
N: Ruben Van Boxem
153162
E: vanboxem dot ruben at gmail dot com
154163
D: Initial Windows patches.

system/lib/libcxx/include/__algorithm/adjacent_find.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
# pragma GCC system_header
2121
#endif
2222

23+
_LIBCPP_PUSH_MACROS
24+
#include <__undef_macros>
25+
2326
_LIBCPP_BEGIN_NAMESPACE_STD
2427

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

5154
_LIBCPP_END_NAMESPACE_STD
5255

56+
_LIBCPP_POP_MACROS
57+
5358
#endif // _LIBCPP___ALGORITHM_ADJACENT_FIND_H

system/lib/libcxx/include/__algorithm/all_of.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
_LIBCPP_BEGIN_NAMESPACE_STD
2020

2121
template <class _InputIterator, class _Predicate>
22-
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
22+
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2323
all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2424
for (; __first != __last; ++__first)
2525
if (!__pred(*__first))

system/lib/libcxx/include/__algorithm/binary_search.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
3737
bool
3838
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
3939
{
40-
return std::binary_search(__first, __last, __value,
41-
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
40+
return std::binary_search(__first, __last, __value, __less<>());
4241
}
4342

4443
_LIBCPP_END_NAMESPACE_STD

system/lib/libcxx/include/__algorithm/clamp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919

2020
_LIBCPP_BEGIN_NAMESPACE_STD
2121

22-
#if _LIBCPP_STD_VER > 14
22+
#if _LIBCPP_STD_VER >= 17
2323
template<class _Tp, class _Compare>
2424
_LIBCPP_NODISCARD_EXT inline
2525
_LIBCPP_INLINE_VISIBILITY constexpr
2626
const _Tp&
2727
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
2828
{
29-
_LIBCPP_ASSERT(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
29+
_LIBCPP_ASSERT_UNCATEGORIZED(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
3030
return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v;
3131

3232
}
@@ -37,7 +37,7 @@ _LIBCPP_INLINE_VISIBILITY constexpr
3737
const _Tp&
3838
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
3939
{
40-
return _VSTD::clamp(__v, __lo, __hi, __less<_Tp>());
40+
return _VSTD::clamp(__v, __lo, __hi, __less<>());
4141
}
4242
#endif
4343

system/lib/libcxx/include/__algorithm/comp.h

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#define _LIBCPP___ALGORITHM_COMP_H
1111

1212
#include <__config>
13+
#include <__type_traits/integral_constant.h>
14+
#include <__type_traits/predicate_traits.h>
1315

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

27-
template <class _T1, class _T2 = _T1>
28-
struct __less
29-
{
30-
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
31-
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
29+
template <class _Lhs, class _Rhs>
30+
struct __is_trivial_equality_predicate<__equal_to, _Lhs, _Rhs> : true_type {};
3231

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

36-
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
37-
bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}
38-
39-
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
40-
bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}
41-
};
42-
43-
template <class _T1>
44-
struct __less<_T1, _T1>
45-
{
46-
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
47-
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
48-
};
49-
50-
template <class _T1>
51-
struct __less<const _T1, _T1>
52-
{
53-
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
54-
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
55-
};
56-
57-
template <class _T1>
58-
struct __less<_T1, const _T1>
59-
{
60-
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
61-
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
37+
template <>
38+
struct __less<void, void> {
39+
template <class _Tp, class _Up>
40+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __lhs, const _Up& __rhs) const {
41+
return __lhs < __rhs;
42+
}
6243
};
6344

6445
_LIBCPP_END_NAMESPACE_STD

system/lib/libcxx/include/__algorithm/comp_ref_type.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#ifndef _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
1010
#define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
1111

12+
#include <__assert>
1213
#include <__config>
13-
#include <__debug>
1414
#include <__utility/declval.h>
1515

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

2928
template <class _Tp, class _Up>
30-
_LIBCPP_CONSTEXPR_SINCE_CXX14
29+
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
3130
bool operator()(const _Tp& __x, const _Up& __y)
3231
{
3332
bool __r = __comp_(__x, __y);
@@ -37,7 +36,7 @@ struct __debug_less
3736
}
3837

3938
template <class _Tp, class _Up>
40-
_LIBCPP_CONSTEXPR_SINCE_CXX14
39+
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
4140
bool operator()(_Tp& __x, _Up& __y)
4241
{
4342
bool __r = __comp_(__x, __y);
@@ -52,7 +51,7 @@ struct __debug_less
5251
decltype((void)std::declval<_Compare&>()(
5352
std::declval<_LHS &>(), std::declval<_RHS &>()))
5453
__do_compare_assert(int, _LHS & __l, _RHS & __r) {
55-
_LIBCPP_DEBUG_ASSERT(!__comp_(__l, __r),
54+
_LIBCPP_ASSERT_UNCATEGORIZED(!__comp_(__l, __r),
5655
"Comparator does not induce a strict weak ordering");
5756
(void)__l;
5857
(void)__r;
@@ -66,7 +65,7 @@ struct __debug_less
6665

6766
// Pass the comparator by lvalue reference. Or in debug mode, using a
6867
// debugging wrapper that stores a reference.
69-
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
68+
#if _LIBCPP_ENABLE_DEBUG_MODE
7069
template <class _Comp>
7170
using __comp_ref_type = __debug_less<_Comp>;
7271
#else

system/lib/libcxx/include/__algorithm/copy.h

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define _LIBCPP___ALGORITHM_COPY_H
1111

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

47-
template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
48-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
49-
operator()(_InIter __first, _InIter __last, _OutIter __result) const {
48+
template <class _InIter, class _OutIter>
49+
struct _CopySegment {
5050
using _Traits = __segmented_iterator_traits<_InIter>;
51-
auto __sfirst = _Traits::__segment(__first);
52-
auto __slast = _Traits::__segment(__last);
53-
if (__sfirst == __slast) {
54-
auto __iters = std::__copy<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
55-
return std::make_pair(__last, std::move(__iters.second));
56-
}
5751

58-
__result = std::__copy<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__sfirst), std::move(__result)).second;
59-
++__sfirst;
60-
while (__sfirst != __slast) {
61-
__result =
62-
std::__copy<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__end(__sfirst), std::move(__result)).second;
63-
++__sfirst;
52+
_OutIter& __result_;
53+
54+
_LIBCPP_HIDE_FROM_ABI _CopySegment(_OutIter& __result) : __result_(__result) {}
55+
56+
_LIBCPP_HIDE_FROM_ABI void
57+
operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) {
58+
__result_ = std::__copy<_AlgPolicy>(__lfirst, __llast, std::move(__result_)).second;
6459
}
65-
__result =
66-
std::__copy<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__local(__last), std::move(__result)).second;
60+
};
61+
62+
template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
63+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
64+
operator()(_InIter __first, _InIter __last, _OutIter __result) const {
65+
std::__for_each_segment(__first, __last, _CopySegment<_InIter, _OutIter>(__result));
6766
return std::make_pair(__last, std::move(__result));
6867
}
6968

7069
template <class _InIter,
7170
class _OutIter,
72-
__enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
71+
__enable_if_t<__has_random_access_iterator_category<_InIter>::value &&
7372
!__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
7473
int> = 0>
7574
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
76-
operator()(_InIter __first, _InIter __last, _OutIter __result) {
75+
operator()(_InIter __first, _InIter __last, _OutIter __result) const {
7776
using _Traits = __segmented_iterator_traits<_OutIter>;
7877
using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;
7978

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

9998
struct __copy_trivial {
10099
// At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
101-
template <class _In, class _Out,
102-
__enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
100+
template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
103101
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
104102
operator()(_In* __first, _In* __last, _Out* __result) const {
105103
return std::__copy_trivial_impl(__first, __last, __result);

system/lib/libcxx/include/__algorithm/copy_backward.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ struct __copy_backward_loop {
7676

7777
template <class _InIter,
7878
class _OutIter,
79-
__enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
79+
__enable_if_t<__has_random_access_iterator_category<_InIter>::value &&
8080
!__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
8181
int> = 0>
8282
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
83-
operator()(_InIter __first, _InIter __last, _OutIter __result) {
83+
operator()(_InIter __first, _InIter __last, _OutIter __result) const {
8484
using _Traits = __segmented_iterator_traits<_OutIter>;
8585
auto __orig_last = __last;
8686
auto __segment_iterator = _Traits::__segment(__result);

system/lib/libcxx/include/__algorithm/copy_move_common.h

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <__config>
1616
#include <__iterator/iterator_traits.h>
1717
#include <__memory/pointer_traits.h>
18+
#include <__string/constexpr_c_functions.h>
1819
#include <__type_traits/enable_if.h>
1920
#include <__type_traits/is_always_bitcastable.h>
2021
#include <__type_traits/is_constant_evaluated.h>
@@ -61,7 +62,8 @@ template <class _In, class _Out>
6162
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
6263
__copy_trivial_impl(_In* __first, _In* __last, _Out* __result) {
6364
const size_t __n = static_cast<size_t>(__last - __first);
64-
::__builtin_memmove(__result, __first, __n * sizeof(_Out));
65+
66+
std::__constexpr_memmove(__result, __first, __element_count(__n));
6567

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

75-
::__builtin_memmove(__result, __first, __n * sizeof(_Out));
77+
std::__constexpr_memmove(__result, __first, __element_count(__n));
7678

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

122-
template <class _IterOps, class _InValue, class _OutIter, class = void>
123-
struct __can_copy_without_conversion : false_type {};
124-
125-
template <class _IterOps, class _InValue, class _OutIter>
126-
struct __can_copy_without_conversion<
127-
_IterOps,
128-
_InValue,
129-
_OutIter,
130-
__enable_if_t<is_same<_InValue, typename _IterOps::template __value_type<_OutIter> >::value> > : true_type {};
131-
132124
template <class _AlgPolicy,
133125
class _NaiveAlgorithm,
134126
class _OptimizedAlgorithm,
@@ -137,23 +129,6 @@ template <class _AlgPolicy,
137129
class _OutIter>
138130
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
139131
__dispatch_copy_or_move(_InIter __first, _Sent __last, _OutIter __out_first) {
140-
#ifdef _LIBCPP_COMPILER_GCC
141-
// GCC doesn't support `__builtin_memmove` during constant evaluation.
142-
if (__libcpp_is_constant_evaluated()) {
143-
return std::__unwrap_and_dispatch<_NaiveAlgorithm>(std::move(__first), std::move(__last), std::move(__out_first));
144-
}
145-
#else
146-
// In Clang, `__builtin_memmove` only supports fully trivially copyable types (just having trivial copy assignment is
147-
// insufficient). Also, conversions are not supported.
148-
if (__libcpp_is_constant_evaluated()) {
149-
using _InValue = typename _IterOps<_AlgPolicy>::template __value_type<_InIter>;
150-
if (!is_trivially_copyable<_InValue>::value ||
151-
!__can_copy_without_conversion<_IterOps<_AlgPolicy>, _InValue, _OutIter>::value) {
152-
return std::__unwrap_and_dispatch<_NaiveAlgorithm>(std::move(__first), std::move(__last), std::move(__out_first));
153-
}
154-
}
155-
#endif // _LIBCPP_COMPILER_GCC
156-
157132
using _Algorithm = __overload<_NaiveAlgorithm, _OptimizedAlgorithm>;
158133
return std::__unwrap_and_dispatch<_Algorithm>(std::move(__first), std::move(__last), std::move(__out_first));
159134
}

0 commit comments

Comments
 (0)