Commit Graph

8475 Commits

Author SHA1 Message Date
Arthur O'Dwyer a8f1a715f0 [libc++] _Uglify some template parameter names. NFCI. 2022-01-14 10:32:04 -05:00
Louis Dionne 5726e55981 [libc++] Modularize <chrono>
I didn't split the calendar bits more than this because there was little
benefit to doing it, and I know our calendar support is incomplete.
Whoever picks up the missing calendar bits can organize these headers
at their leisure.

Differential Revision: https://reviews.llvm.org/D116965
2022-01-14 09:55:29 -05:00
Konstantin Varlamov b6d87773fe [libc++] LWG3171: implement operator<< for filesystem::directory_entry.
Differential Revision: https://reviews.llvm.org/D116642
2022-01-13 20:44:18 -08:00
Nikolas Klauser d3729bb384 [libc++][ranges] Add ranges::in_in_result
Add `std::ranges::in_in_result`

Reviewed By: Quuxplusone, Mordante, #libc

Spies: ldionne, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D116278
2022-01-14 02:56:33 +01:00
Casey Carter cb71d77cc8 [libcxx][test] Add missing includes and suppress warnings
... from testing with MSVC's STL. Mostly truncation warnings and variables that are only used in `LIBCPP_ASSERT`.

Differential Revision: https://reviews.llvm.org/D116878
2022-01-13 17:34:04 -08:00
Louis Dionne 3d40508169 [libc++][NFC] Fix placement of some XFAILs 2022-01-13 15:28:41 -05:00
Louis Dionne e7b07a6538 [libc++][NFC] Add missing 'return 0' in main() functions 2022-01-13 14:32:41 -05:00
Louis Dionne b476039e8b [libc++] Refactor the tests for ranges::{advance,next,prev}
This makes all the tests consistent and improves code coverage. This also
uncovers a bug with negative indices in advance() (which also impacts
prev()) -- I'll fix that in a subsequent patch.

I chose to only count operations in the tests for ranges::advance because
doing so in prev() and next() too was reaching diminishing returns, and
didn't meaningfully improve our test coverage.
2022-01-13 13:57:55 -05:00
Louis Dionne c0671e2c9b [libc++] Move assignable_sentinel to a common header where it can be reused 2022-01-13 12:59:16 -05:00
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 42185ad870 [libc++] Add tests verifying alphabetical order for several things.
These things are header #includes, CMakeLists.txt, and module.modulemap.

Differential Revision: https://reviews.llvm.org/D116958
2022-01-13 09:58:56 -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
Nikolas Klauser fcfc0e7ad3 [libc++] Introduce __fits_in_sso()
Introduce `__fits_in_sso()` to put the constexpr tests into a central place.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D116487
2022-01-11 23:20:15 +01:00
Nikolas Klauser d5b5fc06b8 [libc++] Add Status page for P2321R2 (Zip)
Add a status page for P2321R2

Reviewed By: ldionne, Mordante, #libc

Spies: jloser, libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D116691
2022-01-11 23:13:31 +01:00
Nikolas Klauser e3cf70502c [libc++] Introduce __debug_db_insert_c()
There are a lot of
```
#if _LIBCPP_DEBUG_LEVEL == 2
    __get_db()->__insert_c(this);
#endif
```

This patch introduces `__debug_db_insert_c()` to put the `#if` in one central place.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D116947
2022-01-11 23:11:26 +01:00
John Ericson 0a8d15ad55 [libc++][libc++abi][libunwind] Dedup install path var definitions
In D116873 I did this for libunwind prior to defining a new install path
variable. But I think the change is good on its own, and libc++{,abi}
could also use it.

libc++ needed the base header var defined above the conditional part to
use it for the prefi+ed headers in the non-target-specific case. For
consistency, I therefore put the unconditional ones above for all 3
libs, which is why I touched the libunwind code (seeing that it had the
core change already)

Reviewed By: phosek, #libunwind, #libc, #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D116988
2022-01-11 18:24:50 +00: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
Casey Carter 1d3964d2ad [libcxx][test] Make LIBCPP_STATIC_ASSERT usable at namespace scope
... even when `!defined(_LIBCPP_VERSION)`. (Note that the previous definition for this case - `((void)0);` - is ill-formed at namespace scope.) Ditto for `LIBCPP_ASSERT`, `LIBCPP_ASSERT_NOEXCEPT`, `LIBCPP_ASSERT_NOT_NOEXCEPT`, and `LIBCPP_ONLY`.

Differential Revision: https://reviews.llvm.org/D116880
2022-01-10 16:35:31 -08:00
Nikolas Klauser 2154dbaa59 [libc++][NFC] Use _LIBCPP_DEBUG_ASSERT in <list>
Use `_LIBCPP_DEBUG_ASSERT` in `<list>`

Reviewed By: Quuxplusone, ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D116938
2022-01-10 23:19:16 +01:00
Casey Carter a765eea153 [libcxx][test] Auto-detect _LIBCPP_HAS_NO_UNICODE for MSVC STL
... by examining `_MSVC_EXECUTION_CHARACTER_SET` in the force-include header.

Differential Revision: https://reviews.llvm.org/D116883
2022-01-10 13:56:22 -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 4d81a46f7f [libc++] Alphabetize header #includes. NFCI.
The NFC part of D116809. We still want to enforce this in CI,
but the mechanism for that is still to-be-determined.

Differential Revision: https://reviews.llvm.org/D116809
2022-01-10 16:30:38 -05:00
Roland McGrath ce167c6fb2 [libcxx] Use Fuchsia-native monotonic clock for std::chrono::steady_clock
Use the zx_clock_get_monotonic system call directly rather than
going through the POSIX clock_gettime function.  The libc function
is a trivial wrapper around the system call, and is not a standard C
function.  Avoiding it reduces the Fuchsia libc ABI surface that
libc++ depends on.

Reviewed By: phosek, ldionne, #libc

Differential Revision: https://reviews.llvm.org/D116606
2022-01-10 13:14:50 -08:00
Arthur O'Dwyer c9f83a8af9 [libc++] Alphabetize CMakeLists.txt and module.modulemap. NFC.
The NFC part of D116958. We still want to enforce this in CI,
but the mechanism for that is still to-be-determined.
2022-01-10 15:38:40 -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
Arthur O'Dwyer 4b5d59ffd0 [libc++] libcxx/utils: s/preambule/preamble/g. NFC. 2022-01-10 11:38:25 -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
Louis Dionne c01260a781 [libc++] Add missing `return 0` to main() functions in the tests 2022-01-10 08:38:18 -05:00
Louis Dionne e6d7b2f0de [libc++] Fix link to bug tracker 2022-01-10 08:33:28 -05:00
Louis Dionne 49b9b9dc9c [libc++] Fix the documentation and re-enable documentation CI
The documentation CI job is very cheap, so we can afford to keep it
around even with reduced capacity. This commit fixes the documentation
(which had an invalid reference in it) and re-enables that CI step.

Differential Revision: https://reviews.llvm.org/D116897
2022-01-10 08:05:58 -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 6ce732cbad [libc++] [ranges] Add namespace __cpo to ranges::{advance,next,prev}.
The reason for those nested namespaces is explained in D115315:

> AIUI, this keeps the CPO's own type from ADL'ing into the `std::ranges`
> namespace; e.g. `foobar(std::ranges::uninitialized_default_construct)`
> should not consider `std::ranges::foobar` a candidate, even if
> `std::ranges::foobar` is not a CPO itself. Also, of course, consistency
> (Chesterton's Fence, the economist's hundred-dollar bill): if it were
> safe to omit the namespace, we'd certainly want to do it everywhere,
> not just here.

This makes these three niebloids more consistent with the other Ranges
niebloids we've already implemented, such as the `ranges::begin` group
and the `ranges::uninitialized_default_construct` group.

FWIW, we still have three different indentation-and-comment styles
among these three groups.

Differential Revision: https://reviews.llvm.org/D116569
2022-01-08 12:47:54 -05:00
Ben Wagner fb1582f6c5 [libc++] Disable coverage with sanitize-coverage=0
When building libcxx, libcxxabi, and libunwind the build environment may
specify any number of sanitizers. For some build feature tests these
sanitizers must be disabled to prevent spurious linking errors. With
-fsanitize= this is straight forward with -fno-sanitize=all. With
-fsanitize-coverage= there is no -fno-sanitize-coverage=all, but there
is the equivalent undocumented but tested -fsanitize-coverage=0.

The current build rules fail to disable 'trace-pc-guard'. By disabling
all sanitize-coverage flags, including 'trace-pc-guard', possible
spurious linker errors are prevented. In particular, this allows libcxx,
libcxxabi, and libunwind to be built with HonggFuzz.

CMAKE_REQUIRED_FLAGS is extra compile flags when running CMake build
configuration steps (like check_cxx_compiler_flag). It does not affect
the compile flags for the actual build of the project (unless of course
these flags change whether or not a given source compiles and links or
not). So libcxx, libcxxabi, and libunwind will still be built with any
specified sanitize-coverage as before. The build configuration steps
(which are mostly checking to see if certain compiler flags are
available) will not try to compile and link "int main() { return 0;}"
(or other specified source) with sanitize-coverage (which can fail to
link at this stage in building, since the final compile flags required
are yet to be determined).

The change to LIBFUZZER_CFLAGS was done to keep it consistent with the
obvious intention of disabling all sanitize-coverage. This appears to
be intentional, preventing the fuzzer driver itself from showing up in
any coverage calculations.

Reviewed By: #libunwind, #libc, #libc_abi, ldionne, phosek

Differential Revision: https://reviews.llvm.org/D116050
2022-01-07 17:53:21 -08: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