Skip to content

Commit 7e0cc1e

Browse files
authored
Update libcxx and libcxxabi to LLVM 20.1.4 (#24346)
This updates libcxx and libcxxabi to LLVM 20.1.4: https://github.com/llvm/llvm-project/releases/tag/llvmorg-20.1.4 Before going into each additional change of the PR, these are some noteworthy changes from this LLVM release: - Freezing C++03 headers - RFC: https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc/77319 - PRs: - llvm/llvm-project#108999 - llvm/llvm-project#109000 - llvm/llvm-project#109001 - llvm/llvm-project#109002 - This copies libc++ headers of the last LLVM 19 release into a separate directory (https://github.com/llvm/llvm-project/tree/main/libcxx/include/__cxx03) and redirects all C++03 workflow there. The motivation is not to fix C++03 related changes unless they are critical bugs, and simplifies the main headers. So the main headers are like ``` #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) # include <__cxx03/algorithm> #else ... main header content ... ``` As you can see it looks like we can avoid opting into this by not defining `_LIBCPP_USE_FROZEN_CXX03_HEADERS` at the moment. I think their eventual goal is to remove C++03 support from the main headers but it hasn't seem to have happened yet and I don't know what their timeline for that is. Adding that `__cxx03` directory increases the header size by 10MB. We can get away not using them by not defining `_LIBCPP_USE_FROZEN_CXX03_HEADERS` in this release, so this update does not include that directory. - Sharing of headers between libc++ and libc (Project Hand in Hand) - RFC: https://discourse.llvm.org/t/rfc-project-hand-in-hand-llvm-libc-libc-code-sharing/77701 - PR: llvm/llvm-project#91651 (More are likely to come) This tries to share some libc headers from libcxx. libcxx's source files can depend on headers from `libc/shared`, `libc/src/__support`, `libc/include/llvm-libc-macros`, and `libc/include/llvm-libc-types`. And it turns out libcxx can also depend on `libc/hdr`, even though the directory is not in the diagram in the RFC. These headers can be only included from `libcxx/src` and not `libcxx/include`, to prevent libcxx's API from changing. So these headers don't need to be copied into `cache/`. - Locale API reimplementation It doesn't seem to have an RFC, but the PRs are: - llvm/llvm-project#113737 - llvm/llvm-project#115176 - llvm/llvm-project#115752 - llvm/llvm-project#122489 It looks this aims provide a new way to define locale API for each platform. Currently Apple, FreeBSD, MSVCRT, and Fuschia are using the new API and the others are still using the old one: https://github.com/llvm/llvm-project/blob/ec28b8f9cc7f2ac187d8a617a6d08d5e56f9120e/libcxx/include/__locale_dir/locale_base_api.h#L116-L138 For our purpose, adding `if defined(__EMSCRIPTEN__)` entry to the list of "old" list seems to work for the moment, but we may need to move to the new way eventually later. --- Additional changes: - Copy `vendor/llvm/default_assertion_handler.in` to `__assertion_handler`: aa53648 Our previous `__assertion_handler` was copied from `libcxx/vendor/llvm/default_assertion_handler.in`. This updates our `__assertion_handler` to the new `libcxx/vendor/llvm/default_assertion_handler.in`. For what this file is, see the PR description of #22994, with which the file was added. - Remove `libcxx/include/__cxx03` directory: d646f6b As I described in "Freezing C++ headers" above, C++03 headers were copied to `include/cxx03` to be "frozen". But by not defining `_LIBCPP_USE_FROZEN_CXX03_HEADERS` we can still use the main headers. This new `__cxx03` header directory is almost 10M and we are not using it in this update, this deletes it. - Define more variables in `__config_site`: 9912236 libcxx decides to almost all configuration macros to be defined. So before it tested whether a macro was defined/undefined, and now it assumes it is defined and tests whether its value is 1/0. Before llvm/llvm-project#112094 `_config_site.in` used to use `#cmakedefine`, which only defined variables when they were enabled, but now it uses `#cmakedefine01`, which always defines variables and assigns 1 or 0 depending on whether the feature is enabled. So this change adds `#define` to each variable that `_config_site.in` has an entry of. The value assigned is 1 if it was defined in our previous Emscripten environment and 0 if not. - Fix Emscripten's locale: 2ae01b0 Before, the code was like https://github.com/emscripten-core/emscripten/blob/dc1abd514b1bade135a01a4453a9ff6def0793b6/system/lib/libcxx/include/__locale_dir/locale_base_api.h#L12-L30 But now they are divided into two parts, one using the new API and the other using old. See "Locale API reimplementation" above. https://github.com/llvm/llvm-project/blob/ec28b8f9cc7f2ac187d8a617a6d08d5e56f9120e/libcxx/include/__locale_dir/locale_base_api.h#L116-L138 This adds Emscripten in the beginning of the "old" API list. (This has to be the beginning; see #23414) - Import libc headers used by libcxx: 12a4ee4, 12a4ee4 and 43c8ce4 This imports a part of libc headers into `system/lib/llvm-libc`. The imported directories are: - `libc/shared` - `libc/src/__support` - `libc/include/llvm-libc-macros` - `libc/include/llvm-libc-types` - `libc/hdr` See "sharing of headers between libc+ and libc" above for details. This also applies llvm/llvm-project#133999, which is a bugfix that has not be backported, which fixes the bug of including from a wrong directory. - `std::uncaught_exception` -> `std::uncaught_exceptions`: 1bf4e78 `std::uncaught_exception` has been deprecated in C++17, so it generates a warning (which we treat as an error). Replaced it with `std::uncaught_exceptions`, which returns the number of uncaught exceptions (but can still be used as a boolean in the test). - Remove `ryu_constants.h` and `ryu_long_double_constants.h` from libc: 5767ac4 These are not used from libcxx and `ryu_long_double_constants.h` is huge (12M).
1 parent 9a9791c commit 7e0cc1e

File tree

1,464 files changed

+68617
-21887
lines changed

Some content is hidden

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

1,464 files changed

+68617
-21887
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ See docs/process.md for more on how version tagging works.
2020

2121
4.0.10 (in development)
2222
----------------------
23+
- libcxx and libcxxabi were updated to LLVM 20.1.4. (#24346)
2324
- The `-sASYNCIFY_LAZY_LOAD_CODE` setting was deprecated. This setting was
2425
added as an experiment a long time ago and as far we know has no active users.
2526
In addition, it cannot work with JSPI (the future of ASYNCIFY). (#24383)

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
1212

1313
#include <__algorithm/comp.h>
14-
#include <__algorithm/iterator_operations.h>
1514
#include <__config>
16-
#include <__iterator/iterator_traits.h>
15+
#include <__functional/identity.h>
16+
#include <__type_traits/invoke.h>
1717
#include <__utility/move.h>
1818

1919
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -25,28 +25,30 @@ _LIBCPP_PUSH_MACROS
2525

2626
_LIBCPP_BEGIN_NAMESPACE_STD
2727

28-
template <class _Iter, class _Sent, class _BinaryPredicate>
29-
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
30-
__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
28+
template <class _Iter, class _Sent, class _Pred, class _Proj>
29+
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
30+
__adjacent_find(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
3131
if (__first == __last)
3232
return __first;
33+
3334
_Iter __i = __first;
3435
while (++__i != __last) {
35-
if (__pred(*__first, *__i))
36+
if (std::__invoke(__pred, std::__invoke(__proj, *__first), std::__invoke(__proj, *__i)))
3637
return __first;
3738
__first = __i;
3839
}
3940
return __i;
4041
}
4142

4243
template <class _ForwardIterator, class _BinaryPredicate>
43-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
44+
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
4445
adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
45-
return std::__adjacent_find(std::move(__first), std::move(__last), __pred);
46+
__identity __proj;
47+
return std::__adjacent_find(std::move(__first), std::move(__last), __pred, __proj);
4648
}
4749

4850
template <class _ForwardIterator>
49-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
51+
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
5052
adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
5153
return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());
5254
}

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,32 @@
1111
#define _LIBCPP___ALGORITHM_ALL_OF_H
1212

1313
#include <__config>
14+
#include <__functional/identity.h>
15+
#include <__type_traits/invoke.h>
1416

1517
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1618
# pragma GCC system_header
1719
#endif
1820

1921
_LIBCPP_BEGIN_NAMESPACE_STD
2022

21-
template <class _InputIterator, class _Predicate>
22-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
23-
all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
24-
for (; __first != __last; ++__first)
25-
if (!__pred(*__first))
23+
template <class _Iter, class _Sent, class _Proj, class _Pred>
24+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
25+
__all_of(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
26+
for (; __first != __last; ++__first) {
27+
if (!std::__invoke(__pred, std::__invoke(__proj, *__first)))
2628
return false;
29+
}
2730
return true;
2831
}
2932

33+
template <class _InputIterator, class _Predicate>
34+
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
35+
all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
36+
__identity __proj;
37+
return std::__all_of(__first, __last, __pred, __proj);
38+
}
39+
3040
_LIBCPP_END_NAMESPACE_STD
3141

3242
#endif // _LIBCPP___ALGORITHM_ALL_OF_H

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,32 @@
1111
#define _LIBCPP___ALGORITHM_ANY_OF_H
1212

1313
#include <__config>
14+
#include <__functional/identity.h>
15+
#include <__type_traits/invoke.h>
1416

1517
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1618
# pragma GCC system_header
1719
#endif
1820

1921
_LIBCPP_BEGIN_NAMESPACE_STD
2022

21-
template <class _InputIterator, class _Predicate>
22-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
23-
any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
24-
for (; __first != __last; ++__first)
25-
if (__pred(*__first))
23+
template <class _Iter, class _Sent, class _Proj, class _Pred>
24+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
25+
__any_of(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
26+
for (; __first != __last; ++__first) {
27+
if (std::__invoke(__pred, std::__invoke(__proj, *__first)))
2628
return true;
29+
}
2730
return false;
2831
}
2932

33+
template <class _InputIterator, class _Predicate>
34+
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
35+
any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
36+
__identity __proj;
37+
return std::__any_of(__first, __last, __pred, __proj);
38+
}
39+
3040
_LIBCPP_END_NAMESPACE_STD
3141

3242
#endif // _LIBCPP___ALGORITHM_ANY_OF_H

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <__algorithm/comp_ref_type.h>
1414
#include <__algorithm/lower_bound.h>
1515
#include <__config>
16-
#include <__iterator/iterator_traits.h>
1716

1817
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1918
# pragma GCC system_header
@@ -22,14 +21,14 @@
2221
_LIBCPP_BEGIN_NAMESPACE_STD
2322

2423
template <class _ForwardIterator, class _Tp, class _Compare>
25-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
24+
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2625
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
2726
__first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp);
2827
return __first != __last && !__comp(__value, *__first);
2928
}
3029

3130
template <class _ForwardIterator, class _Tp>
32-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
31+
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
3332
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
3433
return std::binary_search(__first, __last, __value, __less<>());
3534
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <__config>
1313
#include <__type_traits/desugars_to.h>
14+
#include <__type_traits/is_integral.h>
1415

1516
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1617
# pragma GCC system_header
@@ -44,6 +45,9 @@ struct __less<void, void> {
4445
template <class _Tp>
4546
inline const bool __desugars_to_v<__less_tag, __less<>, _Tp, _Tp> = true;
4647

48+
template <class _Tp>
49+
inline const bool __desugars_to_v<__totally_ordered_less_tag, __less<>, _Tp, _Tp> = is_integral<_Tp>::value;
50+
4751
_LIBCPP_END_NAMESPACE_STD
4852

4953
#endif // _LIBCPP___ALGORITHM_COMP_H

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ struct __debug_less {
5656
// Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference.
5757
#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
5858
template <class _Comp>
59-
using __comp_ref_type = __debug_less<_Comp>;
59+
using __comp_ref_type _LIBCPP_NODEBUG = __debug_less<_Comp>;
6060
#else
6161
template <class _Comp>
62-
using __comp_ref_type = _Comp&;
62+
using __comp_ref_type _LIBCPP_NODEBUG = _Comp&;
6363
#endif
6464

6565
_LIBCPP_END_NAMESPACE_STD

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111

1212
#include <__algorithm/copy_move_common.h>
1313
#include <__algorithm/for_each_segment.h>
14-
#include <__algorithm/iterator_operations.h>
1514
#include <__algorithm/min.h>
1615
#include <__config>
16+
#include <__iterator/iterator_traits.h>
1717
#include <__iterator/segmented_iterator.h>
1818
#include <__type_traits/common_type.h>
19+
#include <__type_traits/enable_if.h>
1920
#include <__utility/move.h>
2021
#include <__utility/pair.h>
2122

@@ -28,10 +29,9 @@ _LIBCPP_PUSH_MACROS
2829

2930
_LIBCPP_BEGIN_NAMESPACE_STD
3031

31-
template <class, class _InIter, class _Sent, class _OutIter>
32+
template <class _InIter, class _Sent, class _OutIter>
3233
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter);
3334

34-
template <class _AlgPolicy>
3535
struct __copy_impl {
3636
template <class _InIter, class _Sent, class _OutIter>
3737
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
@@ -47,7 +47,7 @@ struct __copy_impl {
4747

4848
template <class _InIter, class _OutIter>
4949
struct _CopySegment {
50-
using _Traits = __segmented_iterator_traits<_InIter>;
50+
using _Traits _LIBCPP_NODEBUG = __segmented_iterator_traits<_InIter>;
5151

5252
_OutIter& __result_;
5353

@@ -56,7 +56,7 @@ struct __copy_impl {
5656

5757
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
5858
operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) {
59-
__result_ = std::__copy<_AlgPolicy>(__lfirst, __llast, std::move(__result_)).second;
59+
__result_ = std::__copy(__lfirst, __llast, std::move(__result_)).second;
6060
}
6161
};
6262

@@ -85,7 +85,7 @@ struct __copy_impl {
8585
while (true) {
8686
auto __local_last = _Traits::__end(__segment_iterator);
8787
auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
88-
auto __iters = std::__copy<_AlgPolicy>(__first, __first + __size, __local_first);
88+
auto __iters = std::__copy(__first, __first + __size, __local_first);
8989
__first = std::move(__iters.first);
9090

9191
if (__first == __last)
@@ -103,17 +103,16 @@ struct __copy_impl {
103103
}
104104
};
105105

106-
template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
106+
template <class _InIter, class _Sent, class _OutIter>
107107
pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
108108
__copy(_InIter __first, _Sent __last, _OutIter __result) {
109-
return std::__copy_move_unwrap_iters<__copy_impl<_AlgPolicy> >(
110-
std::move(__first), std::move(__last), std::move(__result));
109+
return std::__copy_move_unwrap_iters<__copy_impl>(std::move(__first), std::move(__last), std::move(__result));
111110
}
112111

113112
template <class _InputIterator, class _OutputIterator>
114113
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
115114
copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
116-
return std::__copy<_ClassicAlgPolicy>(__first, __last, __result).second;
115+
return std::__copy(__first, __last, __result).second;
117116
}
118117

119118
_LIBCPP_END_NAMESPACE_STD

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
#include <__algorithm/iterator_operations.h>
1414
#include <__algorithm/min.h>
1515
#include <__config>
16+
#include <__iterator/iterator_traits.h>
1617
#include <__iterator/segmented_iterator.h>
1718
#include <__type_traits/common_type.h>
19+
#include <__type_traits/enable_if.h>
1820
#include <__type_traits/is_constructible.h>
1921
#include <__utility/move.h>
2022
#include <__utility/pair.h>

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,41 @@
1010
#define _LIBCPP___ALGORITHM_COPY_IF_H
1111

1212
#include <__config>
13+
#include <__functional/identity.h>
14+
#include <__type_traits/invoke.h>
15+
#include <__utility/move.h>
16+
#include <__utility/pair.h>
1317

1418
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1519
# pragma GCC system_header
1620
#endif
1721

22+
_LIBCPP_PUSH_MACROS
23+
#include <__undef_macros>
24+
1825
_LIBCPP_BEGIN_NAMESPACE_STD
1926

20-
template <class _InputIterator, class _OutputIterator, class _Predicate>
21-
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
22-
copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) {
27+
template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred>
28+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
29+
__copy_if(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) {
2330
for (; __first != __last; ++__first) {
24-
if (__pred(*__first)) {
31+
if (std::__invoke(__pred, std::__invoke(__proj, *__first))) {
2532
*__result = *__first;
2633
++__result;
2734
}
2835
}
29-
return __result;
36+
return std::make_pair(std::move(__first), std::move(__result));
37+
}
38+
39+
template <class _InputIterator, class _OutputIterator, class _Predicate>
40+
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
41+
copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) {
42+
__identity __proj;
43+
return std::__copy_if(__first, __last, __result, __pred, __proj).second;
3044
}
3145

3246
_LIBCPP_END_NAMESPACE_STD
3347

48+
_LIBCPP_POP_MACROS
49+
3450
#endif // _LIBCPP___ALGORITHM_COPY_IF_H

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
#ifndef _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
1010
#define _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
1111

12-
#include <__algorithm/iterator_operations.h>
1312
#include <__algorithm/unwrap_iter.h>
1413
#include <__algorithm/unwrap_range.h>
1514
#include <__config>
15+
#include <__cstddef/size_t.h>
1616
#include <__iterator/iterator_traits.h>
1717
#include <__memory/pointer_traits.h>
1818
#include <__string/constexpr_c_functions.h>
@@ -24,7 +24,6 @@
2424
#include <__type_traits/is_volatile.h>
2525
#include <__utility/move.h>
2626
#include <__utility/pair.h>
27-
#include <cstddef>
2827

2928
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3029
# pragma GCC system_header

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
#include <__bit/popcount.h>
1717
#include <__config>
1818
#include <__functional/identity.h>
19-
#include <__functional/invoke.h>
2019
#include <__fwd/bit_reference.h>
2120
#include <__iterator/iterator_traits.h>
21+
#include <__type_traits/enable_if.h>
22+
#include <__type_traits/invoke.h>
2223

2324
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2425
# pragma GCC system_header
@@ -43,7 +44,7 @@ __count(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
4344
// __bit_iterator implementation
4445
template <bool _ToCount, class _Cp, bool _IsConst>
4546
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bit_iterator<_Cp, _IsConst>::difference_type
46-
__count_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) {
47+
__count_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_type_traits<_Cp>::size_type __n) {
4748
using _It = __bit_iterator<_Cp, _IsConst>;
4849
using __storage_type = typename _It::__storage_type;
4950
using difference_type = typename _It::difference_type;
@@ -74,12 +75,14 @@ template <class, class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t
7475
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<__bit_iterator<_Cp, _IsConst> >
7576
__count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) {
7677
if (__value)
77-
return std::__count_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first));
78-
return std::__count_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first));
78+
return std::__count_bool<true>(
79+
__first, static_cast<typename __size_difference_type_traits<_Cp>::size_type>(__last - __first));
80+
return std::__count_bool<false>(
81+
__first, static_cast<typename __size_difference_type_traits<_Cp>::size_type>(__last - __first));
7982
}
8083

8184
template <class _InputIterator, class _Tp>
82-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator>
85+
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator>
8386
count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
8487
__identity __proj;
8588
return std::__count<_ClassicAlgPolicy>(__first, __last, __value, __proj);

0 commit comments

Comments
 (0)