Commit Graph

2825 Commits

Author SHA1 Message Date
Arthur O'Dwyer 67151d029b [libc++] [ranges] Implement P2415R2 owning_view.
"What is a view?"
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2415r2.html
https://github.com/cplusplus/draft/pull/5010/files

This was a late-breaking (Oct 2021) change to C++20.
The only thing missing from this patch is that we're supposed
to bump the feature-test macro from
    #define __cpp_lib_ranges 202106L
to
    #define __cpp_lib_ranges 202110L
but we can't do that because we don't implement all of 202106 Ranges yet.

Differential Revision: https://reviews.llvm.org/D116894
2022-01-13 12:29:41 -05:00
Louis Dionne c7aa8b2962 [libc++][NFC] Remove duplication of distance_apriori_sentinel 2022-01-13 12:23:33 -05:00
Arthur O'Dwyer 483f7f5536 [libc++] [ranges] Implement ranges::cdata.
Differential Revision: https://reviews.llvm.org/D117044
2022-01-12 22:07:13 -05:00
Konstantin Varlamov b9bc3c107c [libc++][ranges] Implement `construct_at` and `destroy{,_at}`.
Differential Revision: https://reviews.llvm.org/D116078
2022-01-12 16:01:04 -08:00
Arthur O'Dwyer 9be193bc58 [libc++] [ranges] Finish ADL-proofing ranges::data.
This should have been part of D116239.
2022-01-12 18:16:22 -05:00
Arthur O'Dwyer 4163f61f29 [libc++] [ranges] Fix a missing auto(x) cast in ranges::data.
Also remove some bogus `std::forward`s. My impression is that these
forwards were actually harmless, because `ranges::begin(FWD(t))` is
always identical to `ranges::begin(t)` (except when it's ill-formed,
and that can't happen in this case). However, they're also superfluous
and don't reflect the wording in the standard, so let's eliminate them.

Differential Revision: https://reviews.llvm.org/D117043
2022-01-12 18:16:15 -05:00
Konstantin Varlamov 57092f87b2 Revert "[libc++] Temporarily disable the in_out_result test on Fuchsia."
This reverts commit 9e634b35ff.
2022-01-12 13:10:30 -08:00
Arthur O'Dwyer a70fe03961 [libc++] [ranges] SFINAE away ranges::cbegin(const T&&) for non-borrowed T.
Fixes #52952.

Differential Revision: https://reviews.llvm.org/D116991
2022-01-12 13:25:41 -05:00
Louis Dionne d202c76441 [libc++] Start using `arc4random()` to implement `std::random_device` on Apple
On Apple platforms, arc4random is faster than /dev/urandom, and it is
the recommended user-space RNG according to Apple's own OS folks.

This commit adds an ABI switch to guard ABI-break-protections in
std::random_device, and starts using arc4random instead of /dev/urandom
to implement std::random_device on Apple platforms.

Note that previously, `std::random_device` would allow passing a custom
token to its constructor, and that token would be interpreted as the name
of a file to read entropy from. This was implementation-defined and
undocumented. After this change, Apple platforms will be using arc4random()
instead, and any custom token passed to the constructor will be ignored.
This behavioral change will also impact other platforms that use the
arc4random() implementation, such as OpenBSD. This should be fine since
that is effectively a relaxation of the constructor's requirements.

rdar://86638350

Differential Revision: https://reviews.llvm.org/D116045
2022-01-12 11:24:23 -05:00
Konstantin Varlamov fe958b140a [libc++] Quick fix to remove a narrowing conversion from the in_out_result test.
This needs a proper solution in a follow-up. The issue is that the
Standard defines conversions between `in_out_result` classes with
different template types as just `return {in, out};`. Because the
expression uses list initialization, it will fail to compile if the
conversion happens to be narrowing -- which is probably unintended.

Surprisingly, this error wasn't caught by the CI.

Differential Revision: https://reviews.llvm.org/D117089
2022-01-12 01:49:46 -08:00
Joe Loser 0d1365e380
[libc++][test] Move iter_swap into iterator.cust.swap. NFC.
Move `iter_swap.pass.cpp` into a new subdirectory: `iterator.cust.swap`
for symmetry with the neighboring subdirectory `iterator.cust.move`.

Differential Revision: https://reviews.llvm.org/D116992
2022-01-11 19:56:35 -05:00
Konstantin Varlamov 9e634b35ff [libc++] Temporarily disable the in_out_result test on Fuchsia. 2022-01-11 15:05:43 -08:00
Louis Dionne 7c7d59a35d [libc++] Use TEST_HAS_NO_UNICODE instead of _LIBCPP_HAS_NO_UNICODE in the test suite
Differential Revision: https://reviews.llvm.org/D116973
2022-01-11 10:34:59 -05:00
Konstantin Varlamov 8d23b7420c [libc++][ranges] Implement `uninitialized_copy{,_n}` and `uninitialized_move{,_n}`.
Also implement `in_out_result` which is a prerequisite.

Differential Revision: https://reviews.llvm.org/D116023
2022-01-10 22:49:50 -08:00
Louis Dionne 84654f2733 [libc++] Refactor the tests for std::random_device
That will make it easier to change the behavior of the arc4random()
based implementation. Note that in particular, the eval.pass.cpp test
used to work with non "/dev/random" based implementations because we'd
throw an exception upon constructing the random_device. This patch makes
the intent of the test clearer.
2022-01-10 16:34:16 -05:00
Arthur O'Dwyer 07a0b0ee94 [libc++] Properly handle specializations of std::is_placeholder.
Before this patch, the user needed to specialize both of
`is_placeholder<MyType>` and `is_placeholder<const MyType>`.
After this patch, only the former is needed (although the
latter is harmless if provided).

The new tests don't actually fail unless return type deduction
is used, which is a C++14 feature. Specializing `is_placeholder`
is still allowed in C++11, though.

Fixes #51095.

Differential Revision: https://reviews.llvm.org/D116388
2022-01-10 12:38:59 -05:00
Louis Dionne 7893bb7408 [libc++] Refactor the test for join_view's default constructor
In particular, this removes the need for adding a ad-hoc `operator==`
to forward_iterator.

Differential Revision: https://reviews.llvm.org/D116614
2022-01-10 09:02:45 -05:00
Casey Carter 4cd768ed5e [libcxx][test] `_VSTD` doesn't belong in test code 2022-01-08 21:33:52 -08:00
Arthur O'Dwyer 8a21e0c10c [libc++] [test] Remove `UNSUPPORTED: stdlib=msvc` from lock.pass.cpp.
Casey Carter says, "We run std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp
on every CI and it works fine with MSVC STL. I'm guessing this annotation predates
Billy's rewrite of std::lock in 2017-ish."

Differential Revision: https://reviews.llvm.org/D116712
2022-01-08 16:03:30 -05:00
Arthur O'Dwyer 004ebe22f8 [libc++] Add missing templated version of `std::lerp`.
Fixes #50806.

Differential Revision: https://reviews.llvm.org/D116295
2022-01-07 09:55:33 -05:00
Nikolas Klauser bec50db2ed [libc++] Implement P1072R10 (std::basic_string::resize_and_overwrite)
Reviewed By: Quuxplusone, #libc, Mordante

Spies: mzeren-vmw, ckennelly, arichardson, ldionne, Mordante, libcxx-commits, Quuxplusone

Differential Revision: https://reviews.llvm.org/D113013
2022-01-07 00:09:16 +01:00
Nikolas Klauser 16232611ec [libc++][NFC] Remove using declarations in common_reference.compile.pass.cpp
Remove using declarations in common_reference.compile.pass.cpp

Reviewed By: Quuxplusone, Mordante, #libc, jloser

Spies: jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D116744
2022-01-06 21:39:17 +01:00
Arthur O'Dwyer 9e35e61aa4 [libc++] [ranges] Simplify our idiom for testing niebloid-ness.
In the test files, replace the old-style tests with a simple static_assert,
matching the current style as depicted in e.g.
`ranges_uninitialized_default_construct.pass.cpp`.

Preserve `is_function_like` (but renamed to `is_niebloid`) at
ldionne's request. The removal of this test helper will happen
in D116570 if at all.

Differential Revision: https://reviews.llvm.org/D116384
2022-01-06 14:20:44 -05:00
Nikolas Klauser f3aed36981 [libc++] Implement P1425R4 (Iterator pair constructors for std::stack and std::queue)
Implement P1425R4

Reviewed By: Quuxplusone, #libc, Mordante

Spies: Mordante, jloser, libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D115977
2022-01-06 18:55:11 +01:00
Arthur O'Dwyer 570ed38b6e [libc++] [test] XFAIL "span.cons/initializer_list.pass.cpp" for apple-clang-12.
This should have been done in 6a6a80e88e, but buildkite was down so I
hadn't noticed. This brings this test file into line with several others
in this directory.
2022-01-06 12:15:28 -05:00
Nico Weber 085f078307 Revert "Revert D109159 "[amdgpu] Enable selection of `s_cselect_b64`.""
This reverts commit 859ebca744.
The change contained many unrelated changes and e.g. restored
unit test failes for the old lld port.
2022-01-05 13:10:25 -05:00
David Salinas 859ebca744 Revert D109159 "[amdgpu] Enable selection of `s_cselect_b64`."
This reverts commit 640beb38e7.

That commit caused performance degradtion in Quicksilver test QS:sGPU and a functional test failure in (rocPRIM rocprim.device_segmented_radix_sort).
Reverting until we have a better solution to s_cselect_b64 codegen cleanup

Change-Id: Ibf8e397df94001f248fba609f072088a46abae08

Reviewed By: kzhuravl

Differential Revision: https://reviews.llvm.org/D115960

Change-Id: Id169459ce4dfffa857d5645a0af50b0063ce1105
2022-01-05 17:57:32 +00:00
Mark de Wever de731efd4c [libc++][format] Improve an exception message.
The fix in D116381 makes an existing exception message wrong. This
improves the message and fixes the associated unit tests.

Note other message can be also be improved, but that will be done later.
Changing these messages may cause merge conflicts with other patches
that are under review or WIP.

Depends on D116381

Reviewed By: #libc, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D116495
2022-01-05 17:43:11 +01:00
Mark de Wever f2b40ba400 [libc++][format] Fix precision parser conformance.
@CaseyCarter reported that the tests for the std-format-spec rejects leading
zeroes for precision, which the Standard does not require. The Standard allows
them. Only for precision, not for the width or an arg-id.

Fixes the precision parser and adds some test for the arg-id since they
were missing.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D116381
2022-01-05 17:41:36 +01:00
Nikolas Klauser 1e1e97a326 [libc++][test] Allow multiple tries in some thread tests 2022-01-04 23:47:43 +01:00
Nikolas Klauser 6d722801d1 [libc++][ranges] Add indirectly_comparable concept
Add `indirectly_comparable` concept

Reviewed By: Quuxplusone, Mordante, #libc

Spies: mgorny, libcxx-commits

Differential Revision: https://reviews.llvm.org/D116268
2022-01-04 23:40:57 +01:00
Arthur O'Dwyer 855d7bedb7 [libc++] [P0887] Add newest feature-test macros; mark `type_identity` as implemented.
`__cpp_lib_type_identity` was implemented way back in cf49ccd0 (Clang 8),
probably before the feature-test macro had been settled on.

`__cpp_lib_string_resize_and_overwrite` will be added by D113013 so I didn't add it here.

Fixes #46605.

Differential Revision: https://reviews.llvm.org/D116433
2022-01-04 17:23:37 -05:00
Arthur O'Dwyer 8507383631 [libc++] [ranges] ADL-proof the [range.access] CPOs.
For example, `std::ranges::range<Holder<Incomplete>*>` should be
well-formed false, not a hard error at compile time.

Differential Revision: https://reviews.llvm.org/D116239
2022-01-04 17:15:42 -05:00
Arthur O'Dwyer 1716c36d84 [libc++] [test] More test coverage for ranges::{data,size}.
Reviewed as part of D116239.
2022-01-04 17:15:26 -05:00
Arthur O'Dwyer 502e5df0e0 [libc++] Implement `ranges::{cbegin,cend}` per the spec.
The big change here is that they now work as intended for rvalues,
e.g. `ranges::cbegin(std::string_view("hello"))`.
Also, add tests verifying their return types.

Differential Revision: https://reviews.llvm.org/D116199
2022-01-04 16:18:41 -05:00
Louis Dionne 4a47ac7d51 [libc++] Remove incorrect default constructor in cpp17_input_iterator
AFAICT, Cpp17InputIterators are not required to be default constructible,
since that requirement is added in Cpp17ForwardIterator. Hence, our
archetype for Cpp17InputIterator should not be default constructible.
Removing that constructor has a ripple effect on a couple of tests that
were making incorrect assumptions. Notably:

- Some tests were using cpp17_input_iterator as a sentinel for itself.
  That is not valid, because a cpp17_input_iterator is not semiregular
  anymore after the change (and hence it doesn't satisfy sentinel_for).

- Some tests were using a stride-counted cpp17_input_iterator as the
  sentinel for a range. This doesn't work anymore because of the problem
  above, so these tests were changed not to check stride counts for
  input iterators.

- Some tests were default constructing cpp17_input_iterator when a simple
  alternative was available -- those have been changed to use that alternative.

Differential Revision: https://reviews.llvm.org/D115806
2022-01-04 14:33:51 -05:00
Arthur O'Dwyer 6a6a80e88e [libc++] [test] Add tests for std::span construction from initializer lists.
Differential Revision: https://reviews.llvm.org/D116481
2022-01-04 14:25:32 -05:00
Arthur O'Dwyer 5a3c276365 [libc++] [test] Remove IFNDR uses of std::invocable.
libstdc++'s implementation diagnoses these with hard errors.

Fixes #50059.

Differential Revision: https://reviews.llvm.org/D116293
2022-01-04 14:12:54 -05:00
Louis Dionne e24ddb6027 [libc++] Use std::addressof in std::function::target
This guards against hostile overloads of operator&. Thanks to Peter Dimov
for the report in https://github.com/boostorg/lambda/issues/24.

Differential Revision: https://reviews.llvm.org/D116380
2022-01-04 12:31:45 -05:00
Louis Dionne c31cf74c3c [libc++] Add `return 0` to some main() functions
This unbreaks the tests when running in freestanding mode.
2022-01-04 09:18:08 -05:00
Nikolas Klauser c9dbf0f2a1 [libc++] Fix __wrap_iter copy-assignment in constexpr contexts
Fixes https://github.com/llvm/llvm-project/issues/52902

In debug mode during constant evaluation the iterator was never assigend. There seem to be no other instances of this bug.

Reviewed By: Quuxplusone, Mordante, #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D116346
2022-01-04 11:05:53 +01:00
Arthur O'Dwyer eda5bbfb9d [libc++] [test] Remove an erroneously copy-paste in the hypot() tests. NFC.
Line 1140 is a duplicate of line 1119; it tests the two-argument version
of std::hypot, whereas all the lines in this section are supposed to be
testing the C++17 three-argument version. Remove the erroneous duplicated line.

Split out of D116295.
2022-01-02 12:49:55 -05:00
Louis Dionne ee8e81b40e [libc++][NFC] Fix incorrect synopsis in transform_view test 2021-12-30 15:43:27 -05:00
Joe Loser 7f410251e8
[libcxx][test] Remove redundant semiregular checks for CPOs
Some individual test files verify the CPO under test satisfies
`semiregular` concept.  This is redundant since it is already part of the test
in verifying whether the entity is indeed a CPO in
`libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp`.

Differential Revision: https://reviews.llvm.org/D116173
2021-12-28 22:09:12 -05:00
Chuanqi Xu 6441536c27 [libcxx] [Coroutines] Support noop_coroutine for GCC
We didn't support noop_coroutine for GCC in previous conforming patch.
So that GCC couldn't use noop_coroutine() defined in <coroutine>. And
after this patch, GCC should be able to compile the whole <coroutine>
header.

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D116144
2021-12-27 13:53:21 +08:00
Arthur O'Dwyer 4191a93ea4 [libc++] [test] Eliminate `== true` and `== false`. NFC.
As suggested in D115312.
2021-12-23 14:56:23 -05:00
Arthur O'Dwyer a2a9a5c7d3 [libc++] [ranges] Fix bugs in ranges::empty().
It was missing the cast to `bool` in `bool(__t.empty())`.
It was wrongly using `std::forward` in some places.

Differential Revision: https://reviews.llvm.org/D115312
2021-12-23 14:56:23 -05:00
Arthur O'Dwyer 6842f52a0b [libc++] [test] Flatten the directory structure a bit. NFC.
Differential Revision: https://reviews.llvm.org/D116198
2021-12-23 14:56:23 -05:00
Nikolas Klauser 1d50cf98b5 [libc++] IWYU in <filesystem> tests
Add headers in `<filesystem>` tests that were transitively included
through `<filesystem>`

Reviewed as part of D116146
2021-12-23 12:03:36 +01:00
Nikolas Klauser fcc0964ed4 Revert "[libc++] Remove unused headers from <filesystem>"
This reverts commit 352945dd36.
2021-12-23 11:55:38 +01:00