201 Commits

Author SHA1 Message Date
Hui
bcf172ec57
[libc++] LWG 3821 uses_allocator_construction_args should have overload for pair-like (#66939)
This change addresses LWG 3821 and LWG 3677.

- make `std::pair`'s constructor no longer takes `subrange`
- `uses_allocator_construction_args` constraint changes w.r.t to
`pair-like` types
- `uses_allocator_construction_args` constraints checks
`is-pair-like<remove_cv_t<T>>`
2023-10-09 13:50:27 +01:00
Louis Dionne
b09551f074
[libc++] Fix implementation of iota_view::size (#67819)
We were incorrectly deducing the return type of size() because we were
not using ternary operators in the implementation (as the spec says).
Instead of deducing the common type of the expressions in the spec, we
would deduce potentially different return types and fail to compile.

Fixes #67551
2023-10-04 18:34:43 -04:00
Louis Dionne
580d26ae46
[libc++] Remove the CI job testing Clang 15 (#66406)
Since LLVM 17 has been branched and is on the verge of being released,
we can drop the CI job that tests against Clang 15. I think the number
of cherry-picks to `release/17.x` will be a lot smaller now, so keeping
a Clang 15 job around for that purpose seems unnecessary.

As a fly-by, this patch also removes some Clang 15 workarounds and test
suite annotations as we usually do. It also removes some slightly older
gcc test suite annotations that were missed.
2023-09-25 17:55:59 -04:00
Louis Dionne
5f2da9c80d
[runtimes] Bump the supported AppleClang version to AppleClang 15 (#67065)
AppleClang 15 was released on September 18th and is now stable. Per our
policy, we're bumping the supported AppleClang compiler to the latest
release. This allows cleaning up the test suite, but most importantly
unblocking various other patches that are blocked on bumping the
compiler requirements.
2023-09-25 09:46:01 -04:00
Igor Zhukov
70248920fc [libc++][test] Add '-Wdeprecated-copy', '-Wdeprecated-copy-dtor' warnings to the test suite
This is a follow up to https://reviews.llvm.org/D144694.
Fixes https://github.com/llvm/llvm-project/issues/60977.

Differential Revision: https://reviews.llvm.org/D144775
2023-09-12 08:53:38 -04:00
Konstantin Varlamov
881718857f [libc++][ranges] Fix a split_view test accidentally using lazy_split 2023-09-11 16:17:34 -07:00
Mark de Wever
3401b308f8 [libc++] Renames modules-build.
This is a followup of D157625. Using the name clang-modules-build makes
it clear this is regarding the clang modules and not the C++23 std or
std.compat module.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158927
2023-09-06 17:11:13 +02:00
Jakub Mazurkiewicz
065dc485bd [libc++][ranges] Implement P2443R1: views::chunk_by
This patch implements https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2443r1.html (`views::chunk_by`).

Reviewed By: #libc, var-const

Differential Revision: https://reviews.llvm.org/D144767
2023-09-05 16:19:49 -07:00
Konstantin Varlamov
8b9a98661b [libc++][ranges] Fix ranges::to test.
- Make a test for an internal concept libc++-only;
- Make sure that `size` and `capacity` in a test container return the
  same type on all platforms.
2023-07-27 15:30:11 -07:00
varconst
c3648f37d0 [libc++][ranges] Implement ranges::to.
Differential Revision: https://reviews.llvm.org/D142335
2023-07-20 22:48:18 -07:00
yrong
a2160dd34d [libc++][ranges] Implement P2474R2(views::repeat).
- Implement https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2474r2.html
- Implement LWG3875(https://cplusplus.github.io/LWG/issue3875).

Depends on D151629

Reviewed By: #libc, Mordante, philnik, var-const

Differential Revision: https://reviews.llvm.org/D141699
2023-07-20 20:03:01 +08:00
Louis Dionne
60a6a0d17a [libc++] Add missing includes
Those were found while trying to enable configurations like no-threads
and no-localization with Clang modules enabled.

Differential Revision: https://reviews.llvm.org/D153977
2023-07-03 09:40:09 -04:00
yronglin
9f6439f1c5 [libc++][ranges] Implement P2494R2 (Relaxing range adaptors to allow for move only types)
Implement P2494R2 `Relaxing range adaptors to allow for move only types`

https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2494r2.html#wording-ftm

According to the words in P2494R2, I haven't add new test for `drop_while_view`, `take_while_view` and `filter_view`, because these views has the requirement that the predicate is an `indirect_unary_predicate`, which requires that the predicate is `copy_constructible`, so they still can't accept move only types as predicate.

```
[P2483R0] also suggests future work to relax the requirements on the predicate types stored by standard views. This paper does not perform this relaxation, as the copy constructibility requirement is enshrined in the indirect callable concepts ([indirectcallable.indirectinvocable]). Thus, while this paper modifies the views that currently use copyable-box for user provided predicates, it only does so to apply the rename of the exposition-only type to movable-box; it does not change any of the constraints on those views. It does, however, relax the requirements on invocables accepted by the transform family of views, because those are not constrained using the indirect callable concepts.
```

Reviewed By: #libc, var-const

Differential Revision: https://reviews.llvm.org/D151629
2023-06-25 08:15:52 +08:00
Hui
868591501c [libc++][ranges] Fix iota_view's constructor's incorrect constraint
One of the overload of the constructors should check Bound is not unreachable_sentinel_t, instead of the Start

Differential Revision: https://reviews.llvm.org/D150206
2023-05-12 19:22:13 +01:00
varconst
17bbb224f9 [libc++][ranges] Implement the changes to vector from P1206 (ranges::to):
- add the `from_range_t` constructors and the related deduction guides;
- add the `insert_range`/`assign_range`/etc. member functions.
(Note: this patch is split from https://reviews.llvm.org/D142335)

Differential Revision: https://reviews.llvm.org/D149826
2023-05-08 23:40:55 -07:00
Mark de Wever
d6cd4257e5 [libc++] Adds missing includes.
This patch makes are code less dependant on transitive includes.

This was part of D145800. This patch will be abandoned, but these
changes are still useful. I manually verified declarations of the new
includes are used in these files.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D148645
2023-04-19 17:35:38 +02:00
Hristo Hristov
40aaa272f1 [libc++][ranges] P2711R1 Making multi-param constructors of views explicit
Implemented [[ https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2711r1.html | P2711R1 ]] for existing views.
 (`join_with_view` is not yet implemented)

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D144822
2023-03-23 19:30:21 +02:00
Mark de Wever
d59a43fe2a [libc++] Qualifies intptr_t and uintptr_t.
This has been done using the following command

  find libcxx/test -type f -exec perl -pi -e 's|^([^/]+?)((?<!::)(?<!::u)u?intptr_t)|\1std::\2|' \{} \;

The std module doesn't export declarations in the global namespaace.
This is a preparation for that module.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D146643
2023-03-22 22:19:02 +01:00
Mark de Wever
d868135691 [libc++] Qualifies ptrdiff_t and max_align_t.
This has been done using the following commands
  find libcxx/test -type f -exec perl -pi -e 's|^([^/]+?)((?<!::)ptrdiff_t)|\1std::\2|' \{} \;
  find libcxx/test -type f -exec perl -pi -e 's|^([^/]+?)((?<!::)max_align_t)|\1std::\2|' \{} \;

The std module doesn't export declarations in the global namespaace.,
This is a preparation for that module.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D146550
2023-03-22 17:27:57 +01:00
Mark de Wever
fb855eb941 [libc++] Qualifies size_t.
This has been done using the following command

  find libcxx/test -type f -exec perl -pi -e 's|^([^/]+?)((?<!::)size_t)|\1std::\2|' \{} \;

And manually removed some false positives in std/depr/depr.c.headers.

The `std` module doesn't export `::size_t`, this is a preparation for that module.

Reviewed By: ldionne, #libc, EricWF, philnik

Differential Revision: https://reviews.llvm.org/D146088
2023-03-21 17:41:36 +01:00
Nikolas Klauser
0a4aa8a122 [libc++] Granularize <type_traits> includes
Reviewed By: ldionne, #libc, #libc_abi

Spies: #libc_vendors, smeenai, libcxx-commits

Differential Revision: https://reviews.llvm.org/D145320
2023-03-08 22:05:04 +01:00
Arthur O'Dwyer
f56dfb78aa [libc++] Fix modules issues on OS X
First, fix a collision with the Point type from MacTypes.h, which was
reported on Slack, 2022-07-31: https://cpplang.slack.com/archives/C2X659D1B/p1659284691275889

Second, rename the meta:: namespace to types::. OSX's "/usr/include/ncurses.h"
defines a `meta` function, and is (for some reason) included in
"<SDK>/usr/include/module.modulemap", so that identifier is off-limits
for us to use in anything that compiles with -fmodules:

    libcxx/test/support/type_algorithms.h:16:11: error: redefinition of 'meta' as different kind of symbol
    namespace meta {
               ^
    <SDK>/usr/include/ncurses.h:603:28: note: previous definition is here
    extern NCURSES_EXPORT(int) meta (WINDOW *,bool);                        /* implemented */
                                ^

Finally, add a CI configuration for modules on OS X to make sure it
does not regress.

Differential Revision: https://reviews.llvm.org/D144915
2023-03-01 10:33:40 -05:00
Igor Zhukov
a8ead9194c [libc++][ranges] Implement LWG-3860 range_common_reference_t is missing 2023-02-27 20:49:12 +07:00
Hui
01d68b13f5 [libcxx][ranges] mark new join view tests unsupported without experimental flag
Differential Revision: https://reviews.llvm.org/D143828
2023-02-11 20:42:00 +00:00
Hui
4c2ad195f8 [libc++][ranges] move all range iterators back in class
move all range iterators back in class, as out of class iterators
requires extra template parameters, which changes ADL

Differential Revision: https://reviews.llvm.org/D143324
2023-02-11 15:42:08 +00:00
Louis Dionne
3a0f88c4c2 [libc++] Add a CI configuration to test Modules with LSV enabled
Some clients use libc++ with modules and LSV (Local Submodule Visibility)
enabled, and we see frequent downstream breakage caused by that. Until
modules use LSV by default (which is apparently a desire), add a CI job
that tests this sub-configuration to avoid high cost downstream breakage.

For more information about LSV, see https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150504/128395.html.

Differential Revision: https://reviews.llvm.org/D143273
2023-02-03 17:14:07 -05:00
Konstantin Varlamov
3fe3f9c51c [libc++][ranges] Fix incorrect integer typedef in elements_view test.
Differential Revision: https://reviews.llvm.org/D142951
2023-01-31 15:29:00 -08:00
Louis Dionne
a845b5b4fb [libc++] Use bounded iterators in std::string_view when the debug mode is enabled
Differential Revision: https://reviews.llvm.org/D142903
2023-01-31 18:23:46 -05:00
Mark de Wever
87451cf05a [libc++] Partly addresses LWG3798.
LWG3798 Rvalue reference and iterator_category

The changes are only applied to `ranges::transform_view`, the other
views haven't been implemented yet.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D142815
2023-01-31 20:00:40 +01:00
varconst
c2b3986e39 [libc++][ranges] Temporarily mark ranges::join_view as experimental.
This is in anticipation of https://isocpp.org/files/papers/D2770R0.html,
which is ABI-breaking for `join_view`.

Differential Revision: https://reviews.llvm.org/D142520
2023-01-30 00:36:07 -08:00
Hui
a2b3ab8f77 [libc++][ranges] implement std::ranges::split_view
- implement `std::ranges::split_view` (last c++20 view)
- Work in process on testing iterator/sentinel, but since we are
getting closer to the deadline, I'd like to send the review early

Differential Revision: https://reviews.llvm.org/D142063
2023-01-24 09:03:33 +00:00
Nikolas Klauser
e4e0288f5b [libc++] Move iota_view::iterator and sentinel out of iota_view
This makes it a lot easier to specialize traits types for it, like __segmented_iterator_traits.

Reviewed By: var-const, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D141454
2023-01-20 17:12:05 +01:00
Nikolas Klauser
b40a3d73dc [libc++] Implement P2446R2 (views::as_rvalue)
Reviewed By: ldionne, var-const, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D137637
2023-01-20 06:00:40 +01:00
Konstantin Varlamov
d94b069a89 [libc++][ranges] Mark completed Ranges papers and issues as done, bump version macro
All C++20 Ranges papers and LWG issues are done, with the exception of
https://wg21.link/P2210R2 ("Superior String Splitting"), and marked as
such.

All of these were already implemented prior to this patch except bumping
the feature test macro `__cpp_lib_ranges` as required by
https://wg21.link/P2325R3 ("Views should not be required to be default
constructible"). Note that, even though P2325R3 was voted into C++23, it
was voted with a recommendation for vendors to retroactively apply the
change to C++20 (see https://github.com/cplusplus/papers/issues/1007).

Differential Revision: https://reviews.llvm.org/D139900
2023-01-17 22:54:00 -08:00
Hui Xie
94461822c7 [libc++][ranges] implement std::views::elements_view
`subrange` is also a `tuple-like`. To avoid the add entire `subrange` dependencies to `tuple-like`, we need forward declaration of `subrange`. However, the class template constraints of `subrange` currently requires `__iterator/concepts.h`, which requires `<concepts>`. The problem is that currently `tuple-like` is used in several different places, including libc++ extension for pair constructors. we don't want to add `<concepts>` to pair and other stuff. So this change also created several small headers that `subrange`'s declaration needed inside `__iterator/concepts/`

Differential Revision: https://reviews.llvm.org/D136268
2023-01-15 17:36:10 +00:00
Konstantin Varlamov
17e6bd8070 [libc++][ranges] Fix incorrect integer type in view_interface tests.
`ForwardIter() - ForwardIter()` returns `ptrdiff_t`, and converting it
to an unsigned type isn't guaranteed to produce the same type as
`size_t`.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D141456
2023-01-11 17:43:10 -08:00
Joe Loser
cf9ee8791e [libc++][test] Move common_input_iterator to test_iterators.h
There's a bit of duplication in use of `common_input_iterator` as noted in
https://reviews.llvm.org/D141216.  Lift `common_input_iterator` into
`test_iterators.h`.

Differential Revision: https://reviews.llvm.org/D141238
2023-01-10 17:15:04 -07:00
Casey Carter
96f1cd2427 [libc++][test] Silence MSVC warning
Our static analyzer likes to warn when loop bodies are never executed, which is true for `make_string<T>("")`. Build the result with `basic_string`'s iterator-pair constructor instead, which is simpler (one liner), faster (single pass), and doesn't trigger the warning.

Differential Revision: https://reviews.llvm.org/D141263
2023-01-09 15:05:31 -08:00
Casey Carter
ad41d1e26b [libc++][test] zip_view test cleanups
* The reference type of `common_input_iterator<const int*>` can't be `int&`, because an lvalue of type `const int` _can't_ bind to an `int&`. Fix by changing the return type of `operator*` to `decltype(auto)` to make it fully generic.
* `range.zip/iterator/compare.pass.cpp` verifies that the iterators of a `zip_view` don't support `<=>` when the underlying iterators do not; this is not true after LWG-3692.
* libc++ doesn't yet implement P2165R4 "Compatibility between tuple, pair and tuple-like objects", so the tests expect `zip_view` to use `pair` in places where the working draft requires `tuple`.

Differential Revision: https://reviews.llvm.org/D141216
2023-01-08 15:34:30 -08:00
Igor Zhukov
c45f382a12 Implement LWG-3646 std::ranges::view_interface::size returns a signed type
Reviewed By: Mordante, philnik, #libc

Differential Revision: https://reviews.llvm.org/D139791
2022-12-16 07:14:00 +07:00
Louis Dionne
396fbe264f [libc++] Bump AppleClang compiler requirement
Per our policy, the latest released AppleClang has been 14 for a while,
so libc++ is removing support for AppleClang 13. Our CI bots have been
moved to AppleClang 14 a few weeks ago.

Differential Revision: https://reviews.llvm.org/D138685
2022-11-25 09:51:44 -05:00
Louis Dionne
aeecef08c3 [libc++] Remove default definition of std::char_traits
This patch removes the base template implementation for std::char_traits.
If my reading of http://eel.is/c++draft/char.traits is correct, the
Standard mandates that the library provides specializations for several
types like char and wchar_t, but not any implementation in the base
template. Indeed, such an implementation is bound to be incorrect for
most types anyways, since things like `eof()` and `int_type` will definitely
have to be customized.

Since the base template implementation should not have worked for anyone,
this shouldn't be a breaking change (I expect that anyone defining a
custom character type today will already have to provide their own
specialization of char_traits). However, since we're aware of some users
of char_traits for unsigned char and signed char, we're keeping those two
specializations around for two releases to give people some time to migrate.

Differential Revision: https://reviews.llvm.org/D138307
2022-11-23 09:51:01 -05:00
Hui Xie
594fa1474f [libc++][ranges] implement std::ranges::drop_while_view
Differential Revision: https://reviews.llvm.org/D135460
2022-10-18 19:34:47 +01:00
Hui Xie
a2c6a1193f [libc++][ranges]implement std::views::take_while
Differential Revision: https://reviews.llvm.org/D134952
2022-10-09 08:10:19 +01:00
Hui Xie
96a509bca2 implement std::views::istream
implement `std::ranges::basic_istream_view` and `std::views::istream`. Although the view itself is constexpr,
the constructor argument is a base class std::istream where its ctor/dtor are not constexpr. So no tests are performed in
constexpr

Differential Revision: https://reviews.llvm.org/D133317
2022-10-06 22:57:37 +01:00
Louis Dionne
c2df707666 [libc++] Suppress -Wctad-maybe-unsupported on types w/o deduction guides
There are a handful of standard library types that are intended
to support CTAD but don't need any explicit deduction guides to
do so.

This patch adds a dummy deduction guide to those types to suppress
-Wctad-maybe-unsupported (which gets emitted in user code).

This is a re-application of the original patch by Eric Fiselier in
fcd549a7d828 which had been reverted due to reasons lost at this point.
I also added the macro to a few more types. Reviving this patch was
prompted by the discussion on https://llvm.org/D133425.

Differential Revision: https://reviews.llvm.org/D133535
2022-10-03 14:05:08 -04:00
Hui Xie
4851fbc3cf fix errors on passing input iterator to std::views::take
In the implementation of `std::views::take`, it uses `subrange<Iter>` as part of the return type. But in case of input iterator, `subrange<Iter>` can be ill-formed

Differential Revision: https://reviews.llvm.org/D133220
2022-09-25 15:41:13 +01:00
Nikolas Klauser
d5e26775d0 [libc++] Granularize the rest of memory
Reviewed By: ldionne, #libc

Spies: vitalybuka, paulkirth, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D132790
2022-09-05 12:36:41 +02:00
Vitaly Buka
bc8fd9c633 Revert "[libc++] Granularize the rest of memory"
Breaks buildbots.

This reverts commit 30adaa730c4768b5eb06719c808b2884fcf53cf3.
2022-09-02 19:42:49 -07:00
Nikolas Klauser
30adaa730c [libc++] Granularize the rest of memory
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D132790
2022-09-02 21:42:41 +02:00