Commit Graph

8523 Commits

Author SHA1 Message Date
Martin Storsjö fd64544fbe [libcxx] [test] Remove a leftover unused function in config.py. NFC.
While there's little value in polishing the old config system,
I ran into this function and was confused for a while, while grepping
around and trying to wrap my head around things.

Differential Revision: https://reviews.llvm.org/D116131
2021-12-22 15:16:14 +02:00
Martin Storsjö 516882a8f2 [libcxx] [test] Prepare the ctime.timespec test for mingw CI env upgrades
The test is currently marked XFAIL for mingw environments, but latest
mingw-w64 got support for timespec_get:
e62a0a987c

The CI environment will probably be upgraded to a state where this
test is passing only after 14.x is branched in the llvm-project monorepo.

If we'd just go from having an XFAIL to no marking at all (when CI is
passing), we'd have to update both main and 14.x branches in sync
exactly when the CI runners are updated to a newer version.

Instead, mark the test as temporarily unsupported (so it doesn't
cause failed builds when the CI environment is updated); after the
CI environments are upgraded to such a state, we can remove the
UNSUPPORTED marking to start requiring it to pass on the main branch,
without needing to synchronize that change to anything else.

Differential Revision: https://reviews.llvm.org/D116132
2021-12-22 15:14:55 +02:00
Nikolas Klauser 7056250f51 [libc++][NFC] Granularize <filesystem>
Granularize the `<filesystem>` header

Reviewed By: Quuxplusone, ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D115578
2021-12-22 02:31:17 +01:00
Arthur O'Dwyer 1fe897dffd [libc++] [test] Simplify some ranges tests.
Eliminate a bogus operator== overload.
Also, check more intermediate steps in the logic we're checking here.
Some of this simplification is possible only now that we've implemented
more of <ranges>.

Differential Revision: https://reviews.llvm.org/D116002
2021-12-21 20:16:35 -05:00
Martin Storsjö d67b25e7f6 [libcxx] [test] Extend test for bash for executor-has-no-bash
If %{exec} sets "--env PATH=single-dir", the directory containing
bash and related shell utils is omitted from the path, which means
that most shell scripts would fail.

(Setting PATH is needed for DLL builds on Windows; PATH fills the same
role as e.g. LD_LIBRARY_PATH on Linux.)

This condition is missed in the current test, because the executor
run.py first resolves the executable to run using the original path,
then invokes that executable with an environment with a restricted
path. Thus the executor is able to run bash, but that bash is then
unable to run further shell commands (other than bash builtins).

Extend the test from "bash --version" to "bash -c 'bash --version'".
This correctly identifies the executor-has-no-bash condition in the
current Windows CI configs, allowing removing 6 cases of
LIBCXX-WINDOWS-FIXME.

Another longterm fix would be to extend run.py with an option like
"--env-prepend PATH=dir", to allow keeping the current path while
adding a directory to it.

Differential Revision: https://reviews.llvm.org/D116117
2021-12-22 00:43:29 +02:00
Martin Storsjö f68e89044a [libcxx] Add LIBCXX_EXTRA_SITE_DEFINES for adding extra defines in __config_site
This is similar to the existing setting LIBCXX_ABI_DEFINES, with
the difference that this also allows setting other defines than
ones that start with "_LIBCPP_ABI_", and allows setting defines
to a specific value.

This allows avoiding using LIBCXX_TEST_COMPILER_FLAGS in two
CI configurations.

Differential Revision: https://reviews.llvm.org/D116109
2021-12-22 00:43:29 +02:00
Martin Storsjö c1a14a5c3e [libcxx] Use LIBCXX_EXECUTOR in new test configs
This allows cross-testing (by setting LIBCXX_EXECUTOR to point
to ssh.py) without making an entirely new test config file.

Implicitly, this also fixes quoting of the python executable name
(which is quoted in test/CMakeLists.txt).

Differential Revision: https://reviews.llvm.org/D115398
2021-12-22 00:43:28 +02:00
Louis Dionne beff71520b [libc++] Partially revert 346ef5e587
This moves the macro definitions back to __config, but keeps the
improved documentation. 346ef5e587 had broken the MinGW build.
2021-12-21 23:58:17 +02:00
Louis Dionne 346ef5e587 [libc++][NFC] Improve documentation of the various random_device implementations
Also, move the setting of the macro closer to its point of use, which
also has the benefit of uncluttering `__config`.
2021-12-21 15:32:09 -05:00
Louis Dionne e03ce65190 [libc++][NFC] Reformatting in random_device.h and random.cpp 2021-12-21 13:32:56 -05:00
Martin Storsjö 008849d7a5 [libcxx] [test] Don't rerun supportsVerify for each individual test
We can't just memoize _supportsVerify in place in format.py, as it
previously was executed in each of the individual processes.

Instead use hasCompileFlag() and add a feature flag for it instead,
which can be used both by tests (that already have such a flag,
locally for one set of tests) and for the testing framework itself.

By using hasCompileFlag(), this also implicitly fixes two other issues:
Previously, _supportsVerify called subprocess.call() directly, which can
interpret command line quoting differently than lit.TestRunner.

(In particular, TestRunner handles arguments quoted by a single quote,
while launching Windows processes with subprocess.call() only supports
double quotes. This allows using shlex.quote(), which uses single quotes,
everywhere - as all commands now go through TestRunner. This should make
41d7909368 redundant.)

Secondly, the old _supportsVerify method didn't include %{flags) or
%{compile_flags}.

Differential Revision: https://reviews.llvm.org/D116010
2021-12-21 19:40:30 +02:00
Louis Dionne d5b3cb0711 [libc++][NFC] Fix links to https://llvm.org/PR20183 in the tests 2021-12-21 10:34:08 -05:00
Joe Loser 8dbc7745e5
[libcxx][test] Verify customization point object properties
Add test for various customization point object properties as defined by
the Standard. Test various CPOs from `<ranges>`, `<iterator>`,
`<concepts>`, etc.

The test is mostly from https://reviews.llvm.org/D107036 and split up
into this.

Differential Revision: https://reviews.llvm.org/D115588
2021-12-21 10:12:19 -05:00
Arthur O'Dwyer 9233675466 [libc++] Rename __s1/__s2 to __dest/__source in __copy_constexpr. NFC.
This consistently completes the renaming started in D115986.
2021-12-21 08:36:44 -05:00
Nikolas Klauser edb4698008 [libc++] Allow __move_constexpr to work with unrelated pointers
Allow `__move_constexpr` to work with unrelated pointers and `_LIBCPP_ASSERT` that `__copy_constexpr`, `__move_constexpr` and `__assign_constexpr` are only run during constant evaluation

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D115986
2021-12-21 14:03:39 +01:00
Raul Tambre 4e730aeb73 [libcxx] Add deprecation notices to macros deprecated in P0883R2
When P0883R2 was initially implemented in D103769 #pragma clang deprecated didn't exist yet.
We also forgot to cleanup usages in libc++ itself.

This takes care of both.

Differential Revision: https://reviews.llvm.org/D115995
2021-12-20 20:30:00 +02:00
Louis Dionne d4a69ef841 [libc++][NFC] Bump Dockerfile to get latest nightly Clang 2021-12-20 11:25:08 -05:00
Louis Dionne 37e6bd8bc8 [libc++] Add a helper class to write code with the strong exception guarantee
__transaction is a helper class that allows rolling back code in case an
exception is thrown. The main goal is to reduce the clutter when code
needs to be guarded with `#if _LIBCPP_NO_EXCEPTIONS`.

Differential Revision: https://reviews.llvm.org/D115730
2021-12-20 11:17:29 -05:00
Konstantin Varlamov 754ea6fd4d [libc++][ranges] Implement `uninitialized_value_construct{,_n}` and `uninitialized_fill{,_n}`.
Also:
- refactor out `__voidify`;
- use the `destroy` algorithm internally;
- refactor out helper classes used in tests for `uninitialized_*`
  algorithms.

Differential Revision: https://reviews.llvm.org/D115626
2021-12-20 00:24:27 -08:00
Martin Storsjö 2ec75a0869 [lit] Flush stderr manually on Windows after printing messages
When run in a git bash terminal, sys.stderr isn't flushed implicitly
after printing each line. Manually flush it after each printout,
to avoid getting broken/misordered output.

A similar fix had been done in the old libcxx test config, committed
as part of 7e3ee09ad2 / D28725; this
generalizes the fix, making it available in the new libcxx test
configs too, and for any other test that uses lit_config.note().

Differential Revision: https://reviews.llvm.org/D115761
2021-12-18 21:41:40 +02:00
Konstantin Boyarinov ff94bd1bc9 [libcxx][test][NFC] noexcept tests for std::array
Minor change - add tests that std::array methods (data, (c/r)begin,
(c/r)end) are noexcept

Reviewed By: ldionne, rarutyun, #libc

Differential Revision: https://reviews.llvm.org/D115717
2021-12-18 16:06:56 +03:00
Louis Dionne 2722ac65f6 [libc++] Add a bunch of missing inline and _LIBCPP_HIDE_FROM_ABI in __threading_support
The inline keyword is required on those functions because they are defined
in the headers, so we need them to be inline to avoid ODR violations.
While we're at it, slap _LIBCPP_HIDE_FROM_ABI on them because they are
implementation details and we don't want them to be part of our ABI under
any circumstances.

Differential Revision: https://reviews.llvm.org/D115906
2021-12-17 12:02:32 -05:00
Nikolas Klauser 5675b6112a [libc++] Disable _LIBCPP_DEBUG_ASSERT during constant evaluation
Disable `_LIBCPP_DEBUG_ASSERT` and debug iterators in <string> during constant evaluation

Reviewed By: ldionne, #libc

Spies: goncharov, libcxx-commits

Differential Revision: https://reviews.llvm.org/D115788
2021-12-17 11:15:53 +01:00
Konstantin Varlamov f195fd915e [libc++][ranges][NFC] Remove extraneous cleanup checks.
There is no need to check the counters on `Counted` after destroying
elements in the range because these tests are not testing `destroy`.

Differential Revision: https://reviews.llvm.org/D115839
2021-12-16 14:47:59 -08:00
Arthur O'Dwyer 2a04decc4a [libc++] [test] Simplify sentinel_wrapper and sized_sentinel.
Remove `s.base()`; every test that wants to get the base of a "test sentinel"
should use the ADL `base(s)` from now on.

Differential Revision: https://reviews.llvm.org/D115766
2021-12-16 12:02:58 -05:00
Nikolas Klauser 148ef80f89 [libc++] Add GCC workaround in std::char_traits<char>::length()
GCC currently does not allow `__builtin_strlen()` during constant evaluation. This PR adds a workaround in `std::char_traits<char>::length()`

Reviewed By: Quuxplusone, ldionne, #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D115795
2021-12-16 14:27:51 +01:00
Arthur O'Dwyer 5c0ea7488b [libc++] Enable the optimized _IsSame on GCC as well as Clang.
However, there's a problem on both GCC and Clang: they can't mangle
`__is_same(T,U)` if it appears anywhere that affects mangling. That's
a hard error. And it turns out that GCC puts dependent return types
into the mangling more aggressively than Clang, so for GCC's benefit
we need to avoid using raw `_IsSame` in the return type of
`swap(tuple&, tuple&)`. Therefore, make `__all` into a named type
instead of an alias.

If we ever need to support a compiler without the __is_same builtin,
we can make this an alias template for `is_same<T,U>::type`.

Differential Revision: https://reviews.llvm.org/D115100
2021-12-15 20:19:56 -05:00
Arthur O'Dwyer 5e86f8abd1 [libc++] Reorder a comment pertaining to `struct __two`. NFC. 2021-12-15 19:21:51 -05:00
Nikolas Klauser 17cfc57d14 [libc++] Implement P0798R8 (Monadic operations for std::optional)
Implement P0798R8

Reviewed By: #libc, ldionne, Quuxplusone

Spies: tcanens, Quuxplusone, ldionne, Wmbat, arichardson, Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D113408
2021-12-15 22:49:03 +01:00
Nikolas Klauser af88bc153d [libc++][NFC] Use _LIBCPP_DEBUG_ASSERT in <string>
Use `_LIBCPP_DEBUG_ASSERT` instead of `_LIBCPP_ASSERT` and guarding it with `LIBCPP_DEBUG_LEVEL == 2`

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D115765
2021-12-15 08:39:42 +01:00
Stephan T. Lavavej 8bd106a891 [NFC] Fix typos in release notes.
Reviewed By: ldionne, Mordante, MaskRay

Differential Revision: https://reviews.llvm.org/D115685
2021-12-14 14:19:42 -08:00
Konstantin Varlamov 3f630cff65 [libc++][ranges] Implement ranges::uninitialized_default_construct{,_n}.
Defined in [`specialized.algorithms`](wg21.link/specialized.algorithms).

Also:
- refactor the existing non-range implementation so that most of it
  can be shared between the range-based and non-range-based algorithms;
- remove an existing test for the non-range version of
  `uninitialized_default_construct{,_n}` that likely triggered undefined
  behavior (it read the values of built-ins after default-initializing
  them, essentially reading uninitialized memory).

Reviewed By: #libc, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D115315
2021-12-14 14:11:46 -08:00
Louis Dionne 87fe0709d4 [libc++] Allow detecting whether the executor supports Bash
A few tests in the test suite require support for Bash. For example,
tests that run a program and send data through stdin to it require some
way of piping the data in, and we use a Bash script for that.

However, some executors (e.g. an embedded systems simulator) do not
support Bash, so these tests will fail. This commit adds a Lit feature
that tries to detect whether Bash is available through conventional
means, and disables the tests that require it otherwise.

Differential Revision: https://reviews.llvm.org/D114612
2021-12-14 16:54:13 -05:00
Mark de Wever 0b9b1c8c49 [libc++] Remove C++ version guards in the dylib.
The library is always build using C++20 so these guards are not needed.

Reviewed By: #libc, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D115644
2021-12-14 17:37:52 +01:00
Louis Dionne bf39e7dc6c [libc++] Fix wrongly non-inline basic_string::shrink_to_fit
As explained in https://stackoverflow.com/a/70339311/627587, the fact
that shrink_to_fit wasn't defined as inline lead to issues when explicitly
instantiating basic_string. While explicit instantiations are always
somewhat brittle, this one was clearly a bug on our end.

Differential Revision: https://reviews.llvm.org/D115656
2021-12-14 11:12:04 -05:00
Nikolas Klauser 10a356c47a [libc++] Make __swap_allocator constexpr
Make `__swap_allocator` constexpr

Reviewed By: Quuxplusone, ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D115719
2021-12-14 15:41:56 +01:00
Nikolas Klauser a376a3f354 [libc++] Make __compressed_pair fully constexpr
Make `__compressed_pair` fully constexpr

Reviewed By: ldionne, #libc, nilayvaish

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D115687
2021-12-14 15:39:46 +01:00
Nikolas Klauser f2eab339b9 [libc++][NFC] Remove goto from std::string
Remove `goto` from `std::string`

Reviewed By: Quuxplusone, ldionne, #libc, nilayvaish

Spies: nilayvaish, libcxx-commits

Differential Revision: https://reviews.llvm.org/D115598
2021-12-14 12:35:02 +01:00
Nikolas Klauser 3d510343c4 [libc++] Make ThrowingIterator constexpr
Make ThrowingIterator constexpr

Reviewed By: Quuxplusone, ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D115579
2021-12-14 01:13:21 +01:00
Arthur O'Dwyer 4dd901f4d3 [libc++] Fix the noexceptness of __decay_copy.
When `a` was an array type, `__decay_copy(a)` was incorrectly marking itself
noexcept(false), because it is false that `int[10]` is nothrow convertible to `int[10]`
(in fact it is not convertible at all).

We have no tests explicitly for `__decay_copy`, but the new ranges::begin
and ranges::end tests fail before this patch.

Differential Revision: https://reviews.llvm.org/D115658
2021-12-13 17:55:38 -05:00
Louis Dionne 515afe8b13 [libc++] Change workaround for init_priority((100)) outside of system headers
We had previously been using a different workaround for pretending that
we were inside a system header, however it had some undesirable effects
on dependency parsing for build systems, as explained in [1].

This patch changes the workaround to use `#pragma GCC system_header`,
which shouldn't suffer from the same issue. Unfortunately, it is a lot
more verbose. The issue is that `#pragma GCC system_header` is ignored
when we are inside a source file, so we have to create a header just for
the sake of using it. IMO this seems like an artificial restriction
without much benefit, but investigating that is a different story.
For now, this should at least solve build system problems at the
cost of some readability.

[1]: https://reviews.llvm.org/D95972#3178968

Differential Revision: https://reviews.llvm.org/D115334
2021-12-13 14:37:54 -05:00
John Ericson ddcc02dbcc Quote some more destination paths with variables
Just defensive CMake-ing. I pulled this from D115544 and D99484 which
are blocked on some lldb CI failures I don't yet understand. Hoping to land
something smaller in the meantime.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D115566
2021-12-13 17:29:08 +00:00
Muiez Ahmed b8c12af9dd [SystemZ][z/OS] Fix handling of dirs with filesystem tests
The aim of this patch is to fix the post processing that is happening on the temporary test directories upon scope exit. In particular, ~scoped_test_env aims to chmod and remove the temporary directories; however,

bad symlinks are followed and we get "No such file or directory". FIX: use find as alternative to chmod and avoid -follow option.
Attempting to remove read-only files on z/OS prompts a message asking for confirmation. FIX: use the -f option to delete read-only files immediately without asking for confirmation.
Some libcxx tests such as libcxx/test/std/input.output/filesystems/cl ass.directory_entry/directory_entry.cons/path.pass.cpp set the dir permissions to none. In turn, recursively doing chmod (-R) does not set the file permissions needed to be able to remove the dir on z/OS only. FIX: use find as alternative to chmod -R, which does not run into this issue on z/OS.

Differential Revision: https://reviews.llvm.org/D108326
2021-12-13 11:02:23 -05:00
Mark de Wever abb5dd6e99 Microsoft's floating-point to_chars powered by Ryu and Ryu Printf
Microsoft would like to contribute its implementation of floating-point to_chars to libc++. This uses the impossibly fast Ryu and Ryu Printf algorithms invented by Ulf Adams at Google. Upstream repos: https://github.com/microsoft/STL and https://github.com/ulfjack/ryu .

Licensing notes: MSVC's STL is available under the Apache License v2.0 with LLVM Exception, intentionally chosen to match libc++. We've used Ryu under the Boost Software License.

This patch contains minor changes from Jorg Brown at Google, to adapt the code to libc++. He verified that it works in Google's Linux-based environment, but then I applied more changes on top of his, so any compiler errors are my fault. (I haven't tried to build and test libc++ yet.) Please tell me if we need to do anything else in order to follow https://llvm.org/docs/DeveloperPolicy.html#attribution-of-changes .

Notes:

* libc++'s integer charconv is unchanged (except for a small refactoring). MSVC's integer charconv hasn't been tuned for performance yet, so you're not missing anything.
* Floating-point from_chars isn't part of this patch because Jorg found that MSVC's implementation (derived from our CRT's strtod) was slower than Abseil's. If you're unable to use Abseil or another implementation due to licensing or technical considerations, Microsoft would be delighted if you used MSVC's from_chars (and you can just take it, or ask us to provide a patch like this). Ulf is also working on a novel algorithm for from_chars.
* This assumes that float is IEEE 32-bit, double is IEEE 64-bit, and long double is also IEEE 64-bit.
* I have added MSVC's charconv tests (the whole thing: integer/floating from_chars/to_chars), but haven't adapted them to libcxx's harness at all. (These tests will be available in the microsoft/STL repo soon.)
* Jorg added int128 codepaths. These were originally present in upstream Ryu, and I removed them from microsoft/STL purely for performance reasons (MSVC doesn't support int128; Clang on Windows does, but I found that x64 intrinsics were slightly faster).
* The implementation is split into 3 headers. In MSVC's STL, charconv contains only Microsoft-written code. xcharconv_ryu.h contains code derived from Ryu (with significant modifications and additions). xcharconv_ryu_tables.h contains Ryu's large lookup tables (they were sufficiently large to make editing inconvenient, hence the separate file). The xmeow.h convention is MSVC's for internal headers; you may wish to rename them.
* You should consider separately compiling the lookup tables (see https://github.com/microsoft/STL/issues/172 ) for compiler throughput and reduced object file size.
* See https://github.com/StephanTLavavej/llvm-project/commits/charconv for fine-grained history. (If necessary, I can perform some rebase surgery to show you what Jorg changed relative to the microsoft/STL repo; currently that's all fused into the first commit.)

Differential Revision: https://reviews.llvm.org/D70631
2021-12-12 16:34:50 +01:00
Konstantin Varlamov 805488358a [libc++][ranges] Add subsumption tests to `[special.mem.concepts]`.
Test that `nothrow-forward-iterator` subsumes `nothrow-input-iterator`,
`nothrow-forward-range` subsumes `nothrow-input-range`, and
`nothrow-sentinel-for` and `sentinel_for` subsume each other.

This is a follow-up to [D114761](https://reviews.llvm.org/D114761).

Differential Revision: https://reviews.llvm.org/D115422
2021-12-12 00:37:23 -08:00
Konstantin Boyarinov 82ff94a59c [libcxx][test][NFC] Extend testing for vector.cons
Extending std::vector tests in vector.cons module:

- std::vector::assign when source range is bigger than destination
  capacity
- construction of empty vector using copy ctor, initializer_list ctor and
  others

Reviewed By: ldionne, rarutyun, #libc

Differential Revision: https://reviews.llvm.org/D114954
2021-12-10 15:05:22 +03:00
Konstantin Boyarinov ab018330f3 [libcxx][test][NFC] Tests for set comparisons
Add tests for std::set and std::multiset comparisons that were missed by
D111738 and D112424.

Reviewed By: ldionne, rarutyun, #libc

Differential Revision: https://reviews.llvm.org/D115136
2021-12-10 14:51:24 +03:00
Martin Storsjö 529a79302b Reapply #2 of [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler implied -lunwind
This does mostly the same as D112126, but for the runtimes cmake files.
Most of that is straightforward, but the interdependency between
libcxx and libunwind is tricky:

Libunwind is built at the same time as libcxx, but libunwind is not
installed yet. LIBCXXABI_USE_LLVM_UNWINDER makes libcxx link directly
against the just-built libunwind, but the compiler implicit -lunwind
isn't found. This patch avoids that by adding --unwindlib=none if
supported, if we are going to link explicitly against a newly built
unwinder anyway.

Since the previous attempt, this no longer uses
llvm_enable_language_nolink (and thus doesn't set
CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY during the compiler
sanity checks). Setting CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
during compiler sanity checks makes cmake not learn about some
aspects of the compiler, which can make further find_library or
find_package fail. This caused OpenMP to not detect libelf and libffi,
disabling some OpenMP target plugins.

Instead, require the caller to set CMAKE_{C,CXX}_COMPILER_WORKS=YES
when building in a configuration with an incomplete toolchain.

Differential Revision: https://reviews.llvm.org/D113253
2021-12-09 21:38:14 +02:00
Martin Storsjö 62cff45d76 Revert "Reapply [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler implied -lunwind"
This reverts commit 317dc31e53.

After that change, OpenMP doesn't find dependencies in the host
system (it fails do find e.g. /usr/lib/x86_64-linux-gnu/libelf.so
which it found before), which causes some OpenMP target offloading
plugins to not be found. This doesn't break the build, but just
causes the AMDGPU OpenMP target plugin to be omitted. See
https://reviews.llvm.org/D113253#3181934 for the report of this
issue.
2021-12-09 12:56:57 +02:00
Joe Loser ec63930c06
[libc++][NFC] Remove test/support/tracked_value.h
No tests are using `libcxx/test/support/tracked_value.h`. So, remove it.

Differential Revision: https://reviews.llvm.org/D115411
2021-12-08 21:18:58 -05:00
Arthur O'Dwyer f638c4d6e4 [libc++] [test] Refactor range.prim/empty.pass.cpp.
No decrease in test coverage intended. The original goal here
was just to get rid of the global name `sentinel` so that we can
rename the `sentinel_wrapper` in "test_iterators.h" to `sentinel`;
but then I took a closer look at the offending tests and saw
that some of them probably weren't testing what they intended.

Also, add one `/*explicit*/` and one #if'ed out test indicating
bugs in the current ranges::empty (to be fixed by D115312 or
some equivalent patch).

Reviewed as part of D115272.
2021-12-08 16:41:02 -05:00
Arthur O'Dwyer c19d8f955a [libc++] [test] Use sized_sentinel<int*> in range.prim/ssize.pass.cpp.
Reviewed as part of D115272.
2021-12-08 16:41:02 -05:00
Arthur O'Dwyer 67c43d87cd [libc++] [test_iterators] Make all ADL base() functions into hidden friends. NFCI.
This follows up on my addition of base(cpp20_input_iterator) in D115177,
making all the ADL base() functions consistent.
Also align cpp20_input_iterator with the other test iterators' style.

Reviewed as part of D115272.
2021-12-08 16:41:01 -05:00
Nikolas Klauser feb80aa96b [libc++] `= delete` member functions with // = delete;
Use `= delete` for member functions that are marked with `// = delete;`

Reviewed By: ldionne, Quuxplusone, #libc

Spies: jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D115291
2021-12-08 19:29:44 +01:00
Mark de Wever ade336dee4 Revert "[libc++][ci] Disable generating debug information."
The bug this patch works around prevents D70631 to land.
Remove the work-around since it's no longer needed.
2021-12-08 17:58:51 +01:00
Louis Dionne a6e5563dfa [libc++][release] Do not force building the runtimes with -fPIC
There's a lot of history behind this, so here's a summary:

1. I stopped forcing -fPIC when building the runtimes in 30f305efe2,
   before the LLVM 9 release back in 2019.

2. Someone complained that libc++.a couldn't be used in shared libraries
   built without -fPIC (http://llvm.org/PR43604) since the LLVM 9 release.
   This had been caused by my removal of -fPIC when building libc++.a in (1).

3. I suggested two ways of fixing the issue, the first being to force
   -fPIC back unconditionally (http://llvm.org/D104328), and the second
   being to specify that option explicitly when building the LLVM release
   (http://llvm.org/D104327). We converged on the first solution.

4. I landed D104328, which forced building the runtimes with -fPIC.
   This was included in the LLVM 13.0 release.

5. People complained about that and requested that we be able to
   customize this setting (basically we should have done the second
   solution).

This patch makes it such that the LLVM release script will specifically
ask for building with -fPIC using CMAKE_POSITION_INDEPENDENT_CODE,
however by default the runtimes will not force that option onto users.

This patch has the unintended effect that Clang and the LLVM libraries
(not only the runtime ones like libc++) will also be built with -fPIC
in the release. It would be better if we could specify that -fPIC is to
be used only when building the runtimes, however this is left as a
future improvement. The release should probably be using a bootstrapping
build and passing those options to the stage that builds the runtimes
only, see https://reviews.llvm.org/D112748 for that change.

Differential Revision: https://reviews.llvm.org/D110261
2021-12-08 11:34:35 -05:00
Louis Dionne 9678d25a97 [libc++] Bump Dockerfile 2021-12-08 08:57:24 -05:00
Louis Dionne 81eda008e9 [libc++] Extract __clamp_to_integral to its own header
In addition to being more consistent with our approach for helpers, this
solves an actual issue where <cmath> was using numeric_limits but never
including the <limits> header directly. In a normal setup, this is not
an issue because the <math.h> header included by <cmath> does include
<limits>. However, I did stumble upon some code where that didn't work,
most likely because they were placing their own <math.h> header in front
of ours. I didn't bother investigating further.

Differential Revision: https://reviews.llvm.org/D115282
2021-12-08 08:33:37 -05:00
Mircea Trofin 5dda2efde5 Re-Reland "[benchmarks] Move libcxx's fork of google/benchmark and llvm/utils'"
This reverts commit b2fbd45d23. D114922
fixed the reason of the 2nd revert.

This patch also re-applies 39e9f5d368.

Differential Revision: https://reviews.llvm.org/D112012
2021-12-07 17:10:41 -08:00
Martin Storsjö 317dc31e53 Reapply [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler implied -lunwind
This does mostly the same as D112126, but for the runtimes cmake files.
Most of that is straightforward, but the interdependency between
libcxx and libunwind is tricky:

Libunwind is built at the same time as libcxx, but libunwind is not
installed yet. LIBCXXABI_USE_LLVM_UNWINDER makes libcxx link directly
against the just-built libunwind, but the compiler implicit -lunwind
isn't found. This patch avoids that by adding --unwindlib=none if
supported, if we are going to link explicitly against a newly built
unwinder anyway.

Reapplying this after
db32c4f456, which should fix the issues
that were reported last time this was applied.

Differential Revision: https://reviews.llvm.org/D113253
2021-12-08 00:32:40 +02:00
Nikolas Klauser 4955095fe6 [libc++] Remove _LIBCPP_DEFAULT
clang has `= default` as an extension in c++03, so just use it.

Reviewed By: ldionne, Quuxplusone, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D115275
2021-12-07 22:18:38 +01:00
Arthur O'Dwyer b108cd7b45 [libc++] [test] Rationalize the nodiscard tests for range adaptors.
Reviewed as part of D115177.
2021-12-07 13:59:42 -05:00
Arthur O'Dwyer bd0c0e5b8c [libc++] [ranges] SFINAE-friendly "write it three times" in views::counted.
Before this patch, the new test's `CountedInvocable<int*, int*>`
would hard-error instead of SFINAEing and cleanly returning false.

Notice that views::counted specifically does NOT work with pipes;
`counted(42)` is ill-formed. This is because `counted`'s first argument
is supposed to be an iterator, not a range.

Also, mark `views::counted(it, n)` as [[nodiscard]], and test that.
(We have a general policy now that range adaptors are consistently
marked [[nodiscard]], so that people don't accidentally think that
they have side effects. This matters mostly for `reverse` and
`transform`, arguably `drop`, and just generally let's be consistent.)

Differential Revision: https://reviews.llvm.org/D115177
2021-12-07 13:59:41 -05:00
Arthur O'Dwyer 7a06a14f62 [libc++] Remove unneeded `std::` qualifications from <compare>. NFCI.
Reviewed as part of D115177.
2021-12-07 13:59:41 -05:00
Arthur O'Dwyer 04d74aaff9 [libc++] std::move should be _VSTD::move in one place. NFCI.
Reviewed as part of D115177.
2021-12-07 13:59:41 -05:00
Louis Dionne e7f53ec78f [libc++] Bump Dockerfile 2021-12-07 07:30:46 -05:00
Louis Dionne c49a13a45a [libc++] Fix atomic test for _BitInt
In 6c75ab5f66, Clang deprecated _ExtInt in favor of _BitInt, which
made this test fail. This patch disables the test on older compilers
and uses the new _BitInt type instead.

Differential Revision: https://reviews.llvm.org/D115194
2021-12-07 07:30:09 -05:00
Petr Hosek ae53d02f55 Revert "Microsoft's floating-point to_chars powered by Ryu and Ryu Printf"
This reverts commit a8025e06fc since
it triggers PR52584 with debug info enabled.
2021-12-07 00:10:14 -08:00
Louis Dionne 2db67e9771 [libc++] Fix the return value of max_size()
I assume nobody ever uses std::string_view::max_size() outside of
testing. However, we should still return a value that is based on
something with a reasonable rationale. Previously, we would forget
to take into account the size of the character type stored in the
string, and this patch takes that into account.

Thanks to @mclow.lists for pointing out this issue.

Differential Revision: https://reviews.llvm.org/D114395
2021-12-06 13:53:25 -05:00
Louis Dionne 5871969048 [libc++][NFC] Fix release note indentation 2021-12-06 13:44:15 -05:00
Arthur O'Dwyer dcdb07abce [libc++] Work around a Clang bug in transform_view, and regression-test.
Clang trunk rejects the new test case, but this is a Clang bug
(PR47414, 47509, 50864, 44833).

```
In module 'std' imported from /Users/aodwyer/llvm-project/libcxx/test/std/ranges/range.adaptors/range.transform/general.pass.cpp:17:
/Users/aodwyer/llvm-project/build2/include/c++/v1/__ranges/transform_view.h:85:44: error: constraints not satisfied for alias template 'range_reference_t' [with _Rp = const NonConstView]
             regular_invocable<const _Fn&, range_reference_t<const _View>>
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/aodwyer/llvm-project/build2/include/c++/v1/__ranges/transform_view.h:416:25: note: in instantiation of template class 'std::ranges::transform_view<NonConstView, (lambda at /Users/aodwyer/llvm-project/libcxx/test/std/ranges/range.adaptors/range.transform/general.pass.cpp:73:71)>' requested here
      -> decltype(      transform_view(_VSTD::forward<_Range>(__range), _VSTD::forward<_Fn>(__f)))
                        ^
```

We can work around this by adding a layer of indirection: put the
problematic constraint into a named concept and Clang becomes more
amenable to SFINAE'ing instead of hard-erroring.

Drive-by simplify `range.transform/general.pass.cpp` to make it clearer
what it's actually testing in this area.

Differential Revision: https://reviews.llvm.org/D115116
2021-12-06 11:20:08 -05:00
Nikolas Klauser f50be8eb0a [libc++][NFC] Disable clang-tidy checks
Disable clang-tidy checks as discussed in D114915

Reviewed By: ldionne, #libc

Spies: cjdb, aheejin, libcxx-commits

Differential Revision: https://reviews.llvm.org/D114985
2021-12-06 01:51:23 +01:00
Arthur O'Dwyer 2f16b87b4b [libc++] Remove space-alignment of trailing braces in module.modulemap. NFC.
As discussed on the Discord, 2021-12-01 through 2021-12-05.
Our new consistent style for this is "don't align the right-braces"
(but still align the left-braces, as shown).
2021-12-05 18:56:58 -05:00
Arthur O'Dwyer 4c2fef74dd [libc++] Adjust space-alignment in module.modulemap. NFC. 2021-12-05 13:22:19 -05:00
Arthur O'Dwyer 413c3c4f81 [libc++] Add missing `#pragma GCC system_header` in a few headers. NFCI. 2021-12-05 13:22:19 -05:00
Arthur O'Dwyer 0b609efd4f [libc++] Fix an include-guard comment. NFC. 2021-12-05 13:22:19 -05:00
Mark de Wever 8783f53fb2 [libc++][doc] Update format implementation status. 2021-12-05 17:44:24 +01:00
Nilay Vaish 3536e18a6c Remove duplicate comment
The same comment appears in the very next line.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D115018
2021-12-05 14:03:44 +01:00
Mark de Wever a8025e06fc Microsoft's floating-point to_chars powered by Ryu and Ryu Printf
Microsoft would like to contribute its implementation of floating-point to_chars to libc++. This uses the impossibly fast Ryu and Ryu Printf algorithms invented by Ulf Adams at Google. Upstream repos: https://github.com/microsoft/STL and https://github.com/ulfjack/ryu .

Licensing notes: MSVC's STL is available under the Apache License v2.0 with LLVM Exception, intentionally chosen to match libc++. We've used Ryu under the Boost Software License.

This patch contains minor changes from Jorg Brown at Google, to adapt the code to libc++. He verified that it works in Google's Linux-based environment, but then I applied more changes on top of his, so any compiler errors are my fault. (I haven't tried to build and test libc++ yet.) Please tell me if we need to do anything else in order to follow https://llvm.org/docs/DeveloperPolicy.html#attribution-of-changes .

Notes:

* libc++'s integer charconv is unchanged (except for a small refactoring). MSVC's integer charconv hasn't been tuned for performance yet, so you're not missing anything.
* Floating-point from_chars isn't part of this patch because Jorg found that MSVC's implementation (derived from our CRT's strtod) was slower than Abseil's. If you're unable to use Abseil or another implementation due to licensing or technical considerations, Microsoft would be delighted if you used MSVC's from_chars (and you can just take it, or ask us to provide a patch like this). Ulf is also working on a novel algorithm for from_chars.
* This assumes that float is IEEE 32-bit, double is IEEE 64-bit, and long double is also IEEE 64-bit.
* I have added MSVC's charconv tests (the whole thing: integer/floating from_chars/to_chars), but haven't adapted them to libcxx's harness at all. (These tests will be available in the microsoft/STL repo soon.)
* Jorg added int128 codepaths. These were originally present in upstream Ryu, and I removed them from microsoft/STL purely for performance reasons (MSVC doesn't support int128; Clang on Windows does, but I found that x64 intrinsics were slightly faster).
* The implementation is split into 3 headers. In MSVC's STL, charconv contains only Microsoft-written code. xcharconv_ryu.h contains code derived from Ryu (with significant modifications and additions). xcharconv_ryu_tables.h contains Ryu's large lookup tables (they were sufficiently large to make editing inconvenient, hence the separate file). The xmeow.h convention is MSVC's for internal headers; you may wish to rename them.
* You should consider separately compiling the lookup tables (see https://github.com/microsoft/STL/issues/172 ) for compiler throughput and reduced object file size.
* See https://github.com/StephanTLavavej/llvm-project/commits/charconv for fine-grained history. (If necessary, I can perform some rebase surgery to show you what Jorg changed relative to the microsoft/STL repo; currently that's all fused into the first commit.)

Differential Revision: https://reviews.llvm.org/D70631
2021-12-05 13:25:33 +01:00
Mark de Wever 15495be014 [libc++][ci] Disable generating debug information.
In the bootstrap build generating debug information causes an ICE.
This is a work-around for llvm.org/PR52584
2021-12-05 13:22:58 +01:00
Konstantin Varlamov 2d9efcfeec [libc++][ranges] Implement [special.mem.concepts].
Implement the exposition-only concepts specified in
`[special.mem.concepts]`. These are all thin wrappers over other
concepts.

Reviewed By: #libc, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D114761
2021-12-02 17:58:04 -08:00
David Blaikie 1f2492b7da libcxx pretty printers: remove non-lazy_string fallback
This has been supported on gdb for something like ~10 years, so doesn't
seem necessary to carry a fallback.

Differential Revision: https://reviews.llvm.org/D114986
2021-12-02 14:31:08 -08:00
Nikolas Klauser d2b0df35af [libc++][NFC] Update namespace comments in include/
update the namspace comments in include/

Reviewed By: ldionne, #libc

Spies: smeenai, libcxx-commits

Differential Revision: https://reviews.llvm.org/D114947
2021-12-02 21:06:59 +01:00
David Blaikie ff618a963a Simplify the libcxx std::string_view gdb pretty printer
Seems better to rely on the existing formatting, makes the output
smaller/simpler - this is consistent with libstdc++'s std::string_view
pretty printing too.

Differential Revision: https://reviews.llvm.org/D113244
2021-12-02 11:36:38 -08:00
Joe Loser c16b13ebf9
[libc++] Implement P1989R2: range constructor for string_view
Implement P1989R2 which adds a range constructor for `string_view`.

Adjust `operator/=` in `path` to avoid atomic constraints caching issue
getting provoked from this PR.

Add defaulted template argument to `string_view`'s "sufficient
overloads" to avoid mangling issues in `clang-cl` builds. It is a
MSVC mangling bug that this works around.

Differential Revision: https://reviews.llvm.org/D113161
2021-12-01 23:16:36 -05:00
Konstantin Boyarinov 8c6b24899e [libcxx][test][NFC] Various tests for std::vector
Add missing tests for std::vector funcionality to improve code coverage:

  - Rewrote access tests to check modification of the container using
    the reference returned by the non-const overload
  - Added tests for reverse iterators: rbegin, rend, etc.
  - Added exception test for vector::reserve
  - Extended test cases for vector copy assignment
  - Fixed insert_iter_value.pass.cpp to use insert overload with const
    value_type& (not with value_type&& which is tested in
    iter_rvalue.pass.cpp test)

Reviewed By: Quuxplusone, rarutyun, #libc

Differential Revision: https://reviews.llvm.org/D112438
2021-12-02 02:11:45 +03:00
Nikolas Klauser 6146e4cf89 [libc++] Make __wrap_iter constexpr
`__wrap_iter` is currently only constexpr if it's not a debug built, but it isn't used in a constexpr context currently. Making it always constexpr and disabling the debugging utilities at constant evaluation is more usful since it has to be always constexpr to be used in a constexpr context.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D114733
2021-12-01 23:29:22 +01:00
Christopher Di Bella a0efb17500 [libcxx][modularisation] modularises <numeric> header
Differential Revision: https://reviews.llvm.org/D114836
2021-12-01 20:40:21 +00:00
Arthur O'Dwyer 0efd9a03fa [libc++] [test] Refactor string_view comparison tests for comprehensiveness.
Differential Revision: https://reviews.llvm.org/D114658
2021-12-01 15:04:33 -05:00
Arthur O'Dwyer b4a13e4c98 [libc++] [test] C++14/17-friendly `TEST_IS_CONSTANT_EVALUATED` macro.
Reviewed as part of D114658.
Ultimately this will probably have to be flipped around and renamed
`TEST_IS_RUNTIME`, and extended with `TEST_IS_RUNTIME_OR_CXX20` (once
constexpr std::string support is added) and so on for every new C++
version. But we don't need that flexibility yet, so we're not adding it.
2021-12-01 15:02:54 -05:00
Arthur O'Dwyer a0b50c56d1 [libc++] [test] C++03-friendly MAKE_STRING macro.
Reviewed as part of D114658.
2021-12-01 15:02:53 -05:00
Konstantin Varlamov 7da4ee6f23 [libcxx][NFC] Make sequence containers slightly more SFINAE-friendly during CTAD.
Disable the constructors taking `(size_type, const value_type&,
allocator_type)` if `allocator_type` is not a valid allocator.
Otherwise, these constructors are considered when resolving e.g.
`(int*, int*, NotAnAllocator())`, leading to a hard error during
instantiation. A hard error makes the Standard's requirement to not
consider deduction guides of the form `(Iterator, Iterator,
BadAllocator)` during overload resolution essentially non-functional.

The previous approach was to SFINAE away `allocator_traits`. This patch
SFINAEs away the specific constructors instead, for consistency with
`basic_string` -- see [LWG3076](wg21.link/lwg3076) which describes
a very similar problem for strings (note, however, that unlike LWG3076,
no valid constructor call is affected by the bad instantiation).

Differential Revision: https://reviews.llvm.org/D114311
2021-12-01 11:56:51 -08:00
Louis Dionne dc1244dc4e [runtimes] Move WARNING to FATAL_ERROR for folks using FOO_BUILD_32_BITS 2021-12-01 12:57:30 -05:00
Louis Dionne fa1c077b41 [runtimes] Remove support for GCC-style 32 bit multilib builds
This patch removes the ability to build the runtimes in the 32 bit
multilib configuration, i.e. using -m32. Instead of doing this, one
should cross-compile the runtimes for the appropriate target triple,
like we do for all other triples.

As it stands, -m32 has several issues, which all seem to be related to
the fact that it's not well supported by the operating systems that
libc++ support. The simplest path towards fixing this is to remove
support for the configuration, which is also the best course of action
if there is little interest for keeping that configuration. If there
is a desire to keep this configuration around, we'll need to do some
work to figure out the underlying issues and fix them.

Differential Revision: https://reviews.llvm.org/D114473
2021-12-01 12:57:01 -05:00
Mark de Wever 0e9979affe [libc++][format][1/6] Reduce binary size.
This removes the `format_args_t` from `<format>` and adjusts the type of
the `format_args` for the `vformat_to` overloads.

The `format_context` uses a `back_insert_iterator<string>` therefore the
new `output_iterator` function uses a `string` as its temporary storage
buffer. This isn't ideal. The next patches in this series will improve
this. These improvements make it easy to also improve `format_to_n` and
`formatted_size`.

This addresses P2216 `6. Binary size`.
P2216 `5. Compile-time checks` are not part of this change.

Implements parts of:
- P2216 std::format improvements

Depends on D103670

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D110494
2021-12-01 17:50:17 +01:00
Fabian Wolff b254c2e2c4 [libc++] Fix `uniform_int_distribution` for 128-bit result type
Fixes https://llvm.org/PR51520. The problem is that `uniform_int_distribution`
currently uses an unsigned integer with at most 64 bits internally, which
is then casted to the desired result type. If the result type is `int64_t`,
this will produce a negative number if the most significant bit is set,
but if the result type is `__int128_t`, the value remains non-negative
and will be out of bounds for the example in PR#51520. (The reason why
it also seems to work if the upper or lower bound is changed is
because the branch at [1] will then no longer be taken, and proper
rejection sampling takes place.)

The bigger issue here is probably that `uniform_int_distribution` can be
instantiated with `__int128_t` but will silently produce incorrect results
(only the lowest 64 bits can ever be set). libstdc++ also supports `__int128_t`
as a result type, so I have simply extended the maximum width of the
internal intermediate result type.

[1]: https://github.com/llvm/llvm-project/blob/6d28dffb6/libcxx/include/__random/uniform_int_distribution.h#L266-L267

Differential Revision: https://reviews.llvm.org/D114129
2021-12-01 11:03:29 -05:00
Konstantin Boyarinov 8d25da78aa [libcxx][test][NFC] Extend get_allocator() testing for containers
Add dedicated tests for get_allocator() method for sequence, ordered and
unordered associative containers including constness coverage.

Reviewed by: ldionne, Mordante, rarutyun, #libc

Differential revision: https://reviews.llvm.org/D114785
2021-12-01 16:15:19 +03:00
Kent Ross 7d18267cfe [libcxx][doc] Document recent spaceship projects progress
Update a couple authors, differentials, and completed projects for operator<=> implementation

Reviewed By: #libc, Mordante, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D114682
2021-11-30 18:47:19 -08:00
Louis Dionne a34f246899 [libc++][ABI BREAK] Do not use the C++03 emulation for std::nullptr_t by default
We only support Clangs that implement nullptr as an extension in C++03 mode,
and we don't support GCC in C++03 mode. Hence, this patch disables the
use of the std::nullptr_t emulation in C++03 mode by default. Doing that
is technically an ABI break since it changes the mangling for std::nullptr_t.
However:

(1) The only affected users are those compiling in C++03 mode that have
    std::nullptr_t as part of their ABI, which should be reasonably rare.

(2) Those users already have a lingering problem in that their code will
    be incompatible in C++03 and C++11 modes because of that very ABI break.
    Hence, the only users that could really be inconvenienced about this
    change is those that planned on compiling in C++03 mode forever - for
    other users, we're just breaking them now instead of letting them break
    themselves later on when they try to upgrade to C++11.

(3) The ABI break will cause a linker error since the mangling changed,
    and will not result in an obscure runtime error.

Furthermore, if anyone is broken by this, they can define the
_LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION macro to return to the
previous behavior. We will then remove that macro after shipping
this for one release if we haven't seen widespread issues.

Concretely, the motivation for making this change is to make our own ABI
consistent in C++03 and C++11 modes and to remove complexity around the
definition of nullptr.

Furthermore, we could investigate making nullptr a keyword in C++03 mode
as a Clang extension -- I don't think that would break anyone, since
libc++ already defines nullptr as a macro to something else. Only users
that do not use libc++ and compile in C++03 mode could potentially be
broken by that.

Differential Revision: https://reviews.llvm.org/D109459
2021-11-30 06:01:45 -05:00
Louis Dionne a8278a747d [libc++] Fix incorrect REQUIRES on a locale-dependent test
The test doesn't depend specifically on the en_US.UTF-8 locale, instead
it depends on whether localization support exists, period.

Differential Revision: https://reviews.llvm.org/D114708
2021-11-29 13:42:57 -05:00
Mark de Wever cb68fc814a [libc++] Add myself to the credits.
Noticed while updating the credits for the to_chars patch.
2021-11-28 15:24:45 +01:00
Mark de Wever 730dccb986 [libc++] Remove support for Clang 9 and older.
I encountered this while reviewing an unrelated patch. Will land after
the CI passes.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D114673
2021-11-28 15:17:05 +01:00
Mark de Wever 01631ffcfc [libc++][format] Adds formatting benchmarks.
These benchmarks will be used to test the performance inpact of the next
set of optimization patches.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D110501
2021-11-28 13:12:53 +01:00
Konstantin Boyarinov 56c8ad237a [libcxx][NFC] Add tests for associative containers key_comp and value_comp
Add missing tests to improve associative containers code coverage:
 - Tests for key_comp() and value_comp() observers
 - Tests for std::map and std::multimap value_compare member class

Reviewed by: ldionne, rarutyun, #libc

Differential Revision: https://reviews.llvm.org/D113998
2021-11-27 01:46:22 +03:00
Louis Dionne 5c454033dd [libc++] Trigger rebuild of the Docker image so we get a new nightly Clang 2021-11-26 12:57:30 -05:00
Louis Dionne f18f9ce366 [libc++] Properly handle errors happening during Lit configuration
Instead of silently swallowing errors that happen during Lit configuration
(for example trying to obtain compiler macros but compiling fails), raise
an exception with some amount of helpful information.

This should avoid the possibility of silently configuring Lit in a bogus
way, and also provides more helpful information when things fail.

Note that this requires a bit more finesse around how we handle some
failing configuration checks that we would previously return None for.

Differential Revision: https://reviews.llvm.org/D114010
2021-11-26 11:03:15 -05:00
Louis Dionne 7dc9a03cfd [libc++] Add missing __format__ attributes
-Wformat-nonliteral was turned on in https://reviews.llvm.org/D112927,
however we forgot to apply some __format__ attributes in Linux specific
code paths, which led to warnings when building on Linux. This patch
addresses that oversight.

Differential Revision: https://reviews.llvm.org/D113876
2021-11-26 11:03:14 -05:00
Mikhail Maltsev d8f3cdfed0 [libcxx] Implement three-way comparison for std::reverse_iterator
This patch implements operator<=> for std::reverse_iterator and
also adds a test that checks that three-way comparison of different
instantiations of std::reverse_iterator works as expected (related to
D113417).

Reviewed By: ldionne, Quuxplusone, #libc

Differential Revision: https://reviews.llvm.org/D113695
2021-11-26 10:12:19 +00:00
Louis Dionne ebfeeec4c4 [libunwind] Fix testing with sanitizers enabled
When testing with sanitizers enabled, we need to link against a plethora
of system libraries. Using `-nodefaultlibs` like we used to breaks this,
and we would have to add all these system libraries manually, which is
not portable and error prone. Instead, stop using `-nodefaultlibs` so
that we get the libraries added by default by the compiler.

The only caveat with this approach is that we are now relying on the
fact that `-L <path-to-local-libunwind>` will cause the just built
libunwind to be selected before the system implementation (either of
libunwind or libgcc_s.so), which is somewhat fragile.

This patch also turns the 32 bit multilib build into a soft failure
since we are in the process of removing it anyway, see D114473 for
details. This patch is incompatible with the 32 bit multilib build
because Ubuntu does not provide a proper libstdc++ for 32 bits, and
that is required when running with sanitizers enabled.

Differential Revision: https://reviews.llvm.org/D114385
2021-11-25 15:28:17 -05:00
Louis Dionne 151a7dafd3 [libc++] Fix ssize test that made an assumption about ptrdiff_t being 'long'
On some platforms like armv7m, the size() method of containers returns
unsigned long, while ptrdiff_t is just int. Hence, std::ssize_t ends up
being long, which is not the same as ptrdiff_t. This is usually not an
issue because std::ptrdiff_t is long, so everything works out, but it
breaks on some more exotic architectures.

Differential Revision: https://reviews.llvm.org/D114563
2021-11-25 13:12:47 -05:00
Joe Loser 3e7452a812
[libc++] Avoid overload resolution in path comparison operators
Rework `std::filesystem::path::operator==` and friends to avoid overload
resolution and atomic constraint caching issues shown from
https://reviews.llvm.org/D113161.

Always call `__compare(string_view)` from the comparison operators which avoids
overload resolution.

Differential Revision: https://reviews.llvm.org/D114570
2021-11-25 11:40:55 -05:00
Joe Loser 68e7e76a9b
[libc++] Fix constraints for string_view's iterator/sentinel constructor
The `string_view` constructor taking an iterator/sentinel uses concepts
instead of type traits like the Standard states. Using `same_as` instead
of `is_same_v` should be harmless. Prefer `std::is_same_v` instead which is
cheaper to compile. Replace `convertible_to` with `is_convertible_v` as
well.

This observation came up while working on
https://reviews.llvm.org/D113161

Differential Revision: https://reviews.llvm.org/D114561
2021-11-25 11:39:59 -05:00
Johan Berg 68e2231f87 [libc++] Value-initialize unique_ptr's deleter_type
According to the C++ standard, the stored pointer and the stored deleter
should be value-initialized.

Differential Revision: https://reviews.llvm.org/D113612
2021-11-24 17:31:34 -05:00
Louis Dionne 7a0584fe3f [libc++] Fix backdeployment annotations for std::filesystem
In 1fa27f2a10, we made <filesystem>'s iterator types model concepts
from <ranges>, but we forgot to add the appropriate availability
annotations. This broke back-deployment to platforms that don't have
<filesystem> for which we have availability annotations.

For some reason, this wasn't caught by our back-deployment CI.
I believe this is due to the fact that we use a slightly older
compiler in the CI, and perhaps that compiler does not honour
our `#pragma clang attribute push` properly.

Differential Revision: https://reviews.llvm.org/D114456
2021-11-24 16:58:15 -05:00
Louis Dionne f244166c47 [libc++] Handle armv7m in two architecture dependent tests 2021-11-24 16:40:26 -05:00
Louis Dionne 3a183a49f2 [libc++] Fix two tests that were failing in freestanding mode
We were defining `main()` but never returning from it.
2021-11-24 16:40:26 -05:00
Louis Dionne 13fa4fcfe7 [libc++] Tidy up how %T and %t are created during configuration checks
Instead of having ad-hoc cleanup in various places, handle all creation
and removal of temporary files and directories inside _makeConfigTest.

As a fly-by, also remove testPrefix since we don't keep any source file
around anymore. Setting a prefix for the files is hence not useful anymore.

Differential Revision: https://reviews.llvm.org/D114390
2021-11-23 09:51:22 -05:00
Christopher Di Bella b8bba3d801 [libcxx][NFC] adds var-const@ as the owner for the uninitialised algos 2021-11-22 18:44:13 +00:00
Christopher Di Bella c5bf8d6f76 [libcxx][NFC] adds status entry for ranges algorithms
Differential Revision: https://reviews.llvm.org/D114295
2021-11-22 18:35:11 +00:00
Louis Dionne c0efe8f266 [libc++][NFC] Reformat comment about D68480 support 2021-11-22 13:34:18 -05:00
Arthur O'Dwyer d8380ad977 [libc++] [P1614] Implement [cmp.alg]'s std::{strong,weak,partial}_order.
This does not include `std::compare_*_fallback`; those are coming later.

There's still an open question of how to implement std::strong_order
for `long double`, which has 80 value bits and 48 padding bits on x86-64,
and which is presumably *not* IEEE 754-compliant on PPC64 and so on.
So that part is left unimplemented.

Differential Revision: https://reviews.llvm.org/D110738
2021-11-22 13:24:28 -05:00
Arthur O'Dwyer 344cef6695 [libc++] Granularize the <random> header. NFCI.
Actually there's one functional change here, which is that users can
no longer depend on <random> to include all of C++20 <concepts>. That
inclusion is so new that we believe nobody should be depending on it
yet, even in the presence of Hyrum's Law. We keep the includes of <vector>,
<algorithm>, etc., so as not to break pre-C++20 Hyrum's Law users.

Differential Revision: https://reviews.llvm.org/D114281
2021-11-22 13:24:27 -05:00
Louis Dionne e7cee55c9d [libc++] Remove uses of printf in some test support headers
In the test suite, we generally don't use printf or other reporting
utilities. It's not that it wouldn't be useful, it's just that some
platforms don't support IO.

Instead, we try to keep test cases small and self-contained so that
we can reasonably easily reproduce failures locally and debug them.
This patch removes printf in some of the last places in the test suite
that used it. The only remaining places are in a deque test and in the
filesystem tests. The filesystem tests are arguably fine to keep using
IO, since we're testing <filesystem>. The deque test will be handled
separately.

Differential Revision: https://reviews.llvm.org/D114282
2021-11-22 12:01:18 -05:00
Nikolas Klauser 04a6dc06a0 [libc++] [NFC] Mark P0858R0 as implemented
P0858R0 seems to be implemented. D93830 sets `__cpp_lib_string_view` and D80452 sets `__cpp_lib_array_constexpr`.

Reviewed By: Quuxplusone, Mordante, ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D114344
2021-11-22 17:58:22 +01:00
Mark de Wever cc9fdedba7 [libc++] Improve CMake include directory search.
This patch has been tested in D70631, but it should be reviewed
separately.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D114248
2021-11-22 17:35:49 +01:00
Joe Loser a60b63940a
[libc++][NFC] Sort includes in __ranges/concepts.h
Differential Revision: https://reviews.llvm.org/D114328
2021-11-21 19:34:02 -05:00
Nikolas Klauser 1dc62f2653 [libc++] Implement P1272R4 (std::byteswap)
Implement P1274R4

Reviewed By: Quuxplusone, Mordante, #libc

Spies: jloser, lebedev.ri, mgorny, libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D114074
2021-11-22 01:28:18 +01:00
Joe Loser dca681fee9
[libc++][NFC] Fix typo in ranges::iterator_t synopsis
The `iterator_t` alias template is on `T` not a `R` like the other
neighboring alias templates. Fix the typo.
2021-11-20 19:15:00 -05:00
Arthur O'Dwyer e74114add3 [libc++] [doc] Mark some spaceship-related LWG issues as "Complete."
LWG3330 has been "Completed" since D99309, which was in the 13.x timeframe.
Reviewed as part of D110738.
2021-11-20 18:16:22 -05:00
Arthur O'Dwyer 401b76fdf2 [libc++] [test] Eliminate libcpp-no-noexcept-function-type and libcpp-no-structured-bindings.
At this point, every supported compiler that claims a -std=c++17 mode
should also support these features.

Differential Revision: https://reviews.llvm.org/D113436
2021-11-20 11:44:57 -05:00
Louis Dionne e059329b83 [libc++][NFC] Add missing include in test 2021-11-19 16:01:55 -05:00
Arthur O'Dwyer b07b5bd727 [libc++] Test that our algorithms never copy a user-provided comparator.
This is not mandated by the standard, so it goes in libcxx/test/libcxx/.
It's certainly arguable that the algorithms changed here
(`is_heap`, `is_sorted`, `min`, `max`) are harmless and we should
just let them copy their comparators once. But at the same time,
it's nice to have all our algorithms be 100% consistent and never
copy a comparator, not even once.

Differential Revision: https://reviews.llvm.org/D114136
2021-11-19 15:03:24 -05:00
Louis Dionne e0f58444e1 [libc++] Fix feature test macro for __cpp_lib_to_chars
We would have been defining it in <utility> instead of <charconv>. For
the time being, this doesn't change anything since we don't implement
the feature test macro anyways.

Also, as a fly-by, this removes obsolete feature test macro tests. There
was a brief time back in the days when we wrote feature test macro tests
manually. In particular, we had test files for __cpp_lib_to_chars and
__cpp_lib_memory_resource. Since we now have a principled way of generating
these tests with scripts, this commit removes the obsolete (and empty)
tests for these two feature test macros.

Differential Revision: https://reviews.llvm.org/D114243
2021-11-19 14:26:34 -05:00
Louis Dionne e1ce3dabf0 [libc++] Fix some tests that were broken in the single-threaded configuration
We never noticed it because our CI doesn't actually build against a C
library that doesn't have threading functionality, however building
against a truly thread-free platform surfaces these issues.

Differential Revision: https://reviews.llvm.org/D114242
2021-11-19 14:24:15 -05:00
Louis Dionne 1b4c0cb391 [libc++] Avoid potential truncation warnings in std::abs test
One some platforms, -Wimplicit-int-conversion is enabled by default,
which can lead to additional warnings being triggered in this test.
Since we're only trying to test errors related to calling abs(), the
assignment is superfluous.

As a fly-by fix, correct one instance of ::abs to std::abs and made
the test a .verify.cpp test instead.

Differential Revision: https://reviews.llvm.org/D114244
2021-11-19 14:22:26 -05:00
Mark de Wever ed86610c7b [libc++][nfc] Move functions to a generic place.
This allows the floating-point formatter to use the same functions as
the integral formatter. This was tested in D114001.
2021-11-19 16:38:35 +01:00
Mark de Wever 3624c4d845 [libc++] Adds (to|from)_chars_result operator==.
Implements part of P1614 The Mothership has Landed.

Reviewed By: #libc, Quuxplusone, Mordante

Differential Revision: https://reviews.llvm.org/D112366
2021-11-19 16:29:33 +01:00
Kent Ross 870dfa6b08 [libc++][doc] Mark project for [cmp.concept] done
Mark [cmp.concept] implementation as completed in our documentation.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D114203
2021-11-18 20:15:54 -08:00
Konstantin Varlamov 3b463c4528 [libc++][NFC] Assign some Ranges tasks to varconst.
Specifically:
- [special.mem.concepts];
- [specialized.algorithms].
2021-11-18 15:15:21 -08:00
Fabian Wolff dc1c27149f [libc++] Cast to the right `difference_type` in various algorithms
Differential Revision: https://reviews.llvm.org/D113868
2021-11-18 17:07:36 -05:00
Muiez Ahmed 27ea67136e [SystemZ][z/OS] Fix filesystem testing
This patch resolves many of the failures in the `filesystems/` buckets in the libc++ tests. It adds the correct flag to `fopen` and marks a test case as unsupported. In particular, that test assumes time is stored as a 64 bit value when on MVS it is stored as 32 bit.

Differential Revision: https://reviews.llvm.org/D113298
2021-11-18 15:57:50 -05:00
Muiez Ahmed 049f6c29a6 [libc++] Resolve missing table_size symbol
The aim of this patch is to resolve the missing `table_size` symbol (see reduced test case). That const variable is declared and defined in //libcxx/include/locale//; however, the test case suggests that the symbol is missing. This is due to a C++ pitfall (highlighted [[ https://quuxplusone.github.io/blog/2020/09/19/value-or-pitfall/ | here ]]). In summary, assigning the reference of `table_size` doesn't enforce the const-ness and expects to find `table_size` in the DLL. The fix is to use `constexpr` or have an out-of-line definition in the src (for consistency).

Differential Revision: https://reviews.llvm.org/D110647
2021-11-18 15:49:45 -05:00
Arthur O'Dwyer 1ce516d43f [libc++] Minor fixups in the new introsort code.
Differential Revision: https://reviews.llvm.org/D114133
2021-11-18 11:01:41 -05:00
Arthur O'Dwyer 4a8734deb7 [libc++] [test] Add "robust_re_difference_type.compile.pass.cpp" for all the algorithms.
Also, mark these tests as compile-only. They actually are safe to run — notice that
the code "runs" at constexpr-time in C++20, without error — because both of the
input ranges are entirely filled with nullptr, so no matter how you shuffle the
elements, they remain sorted and partitioned and heapified and everything.
But there's no real reason to run them at runtime, so let's just avoid the distraction.

Test cases that fail in trunk right now are commented out with `TODO FIXME`.

Differential Revision: https://reviews.llvm.org/D113906
2021-11-18 00:12:41 -05:00
Louis Dionne 92832e4889 [libc++] Enable <atomic> when threads are disabled
std::atomic is, for the most part, just a thin veneer on top of compiler
builtins. Hence, it should be available even when threads are not available
on the system, and in fact there has been requests for such support.

This patch:
- Moves __libcpp_thread_poll_with_backoff to its own header so it can
  be used in <atomic> when threads are disabled.
- Adds a dummy backoff policy for atomic polling that doesn't know about
  threads.
- Adjusts the <atomic> feature-test macros so they are provided even when
  threads are disabled.
- Runs the <atomic> tests when threads are disabled.

rdar://77873569

Differential Revision: https://reviews.llvm.org/D114109
2021-11-17 23:02:58 -05:00
Chuanqi Xu af9f3c6d86 [Coroutine] Warn deprecated 'std::experimental::coro' uses
Since we've decided the to not support std::experimental::coroutine*, we
should tell the user they need to update.

Reviewed By: Quuxplusone, ldionne, Mordante

Differential Revision: https://reviews.llvm.org/D113977
2021-11-18 09:41:01 +08:00
Louis Dionne eb8650a757 [runtimes][NFC] Remove filenames at the top of the license notice
We've stopped doing it in libc++ for a while now because these names
would end up rotting as we move things around and copy/paste stuff.
This cleans up all the existing files so as to stop the spreading
as people copy-paste headers around.
2021-11-17 16:30:52 -05:00
Louis Dionne 95741660b4 [libc++][NFC] Re-indent and re-order includes in uses_alloc_types.h 2021-11-17 16:13:58 -05:00
Louis Dionne 3e957e5d66 [libc++] Refactor tests for trivially copyable atomics
- Replace irrelevant synopsis by a comment
- Use a .verify.cpp test instead of .compile.fail.cpp
- Remove unnecessary includes in one of the tests (was a copy-paste error)

Differential Revision: https://reviews.llvm.org/D114094
2021-11-17 13:32:12 -05:00
Louis Dionne c0f87e8382 [libc++] Remove _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
All supported compilers support spaceship in C++20 nowadays.

Differential Revision: https://reviews.llvm.org/D113938
2021-11-17 10:59:57 -05:00
Martin Storsjö efbe9ae23f Revert "[runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler implied -lunwind"
This reverts commit 7c3d19ab7b.

This commit was reported as causing build problems for the amdgpu
buildbot in https://reviews.llvm.org/D113253#3137097.
2021-11-17 12:50:33 +02:00
Martin Storsjö f5ca3ac748 [libcxx] [ci] Add CI configurations for MinGW
Mention support for MinGW in the docs. Rename the existing windows
CI jobs to Clang-cl, as both Clang-cl and MinGW are equally much
"Windows", just different toolchain environments.

Add an XFAIL for a recently added test that fails in the MinGW DLL
configuration (with an explanation of what's causing the failure).

Differential Revision: https://reviews.llvm.org/D112215
2021-11-17 10:00:50 +02:00
Mircea Trofin b2fbd45d23 Revert "Reland "[benchmarks] Move libcxx's fork of google/benchmark and llvm/utils'"""
This reverts commit 1ee32055ea.

We hit additional bot failures; in particular, Fuchsia's seems to be
related to how CMakeLists are ingested, see https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8830380874445931681/overview
2021-11-16 16:35:06 -08:00
Martin Storsjö 7c3d19ab7b [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler implied -lunwind
This does mostly the same as D112126, but for the runtimes cmake files.
Most of that is straightforward, but the interdependency between
libcxx and libunwind is tricky:

Libunwind is built at the same time as libcxx, but libunwind is not
installed yet. LIBCXXABI_USE_LLVM_UNWINDER makes libcxx link directly
against the just-built libunwind, but the compiler implicit -lunwind
isn't found. This patch avoids that by adding --unwindlib=none if
supported, if we are going to link explicitly against a newly built
unwinder anyway.

Differential Revision: https://reviews.llvm.org/D113253
2021-11-16 23:04:06 +02:00
Danila Kutenin a45d2287ad [libc++] Unspecified behavior randomization in libc++
This effort is dedicated to deflake the tests of the users which depend
on the unspecified behavior of algorithms and containers. This also
might help updating the sorting algorithm in libcxx which has the
quadratic worst case in the future or at least create a new one under
flag.

For detailed design, please see the design doc I provide in the patch.

Differential Revision: https://reviews.llvm.org/D96946
2021-11-16 15:55:33 -05:00
Louis Dionne df0c2b917d [libc++] Adjust comment about ABI change and std::bad_function_call 2021-11-16 15:32:15 -05:00
Konstantin Varlamov 434dc0a5bc [libc++] Always define a key function for std::bad_function_call in the dylib
However, whether applications rely on the std::bad_function_call vtable
being in the dylib is still controlled by the ABI macro, since changing
that would be an ABI break.

Also separate preprocessor definitions for whether to use a key function
and whether to use a `bad_function_call`-specific `what` message
(`what` message is mandated by [LWG2233](http://wg21.link/LWG2233)).

Differential Revision: https://reviews.llvm.org/D92397
2021-11-16 11:23:27 -08:00
Nikolas Klauser 1ff87ec235 [libc++] [NFC] Disable clang-tidy's readability-identifier-naming check
In libc++ most of the names are not conforming to the llvm style. Removing the readability-identifier-naming check removes almost all clang-tidy warnings. For example in `<string>` the warning count goes from 1001 warnings down to 7.

Reviewed By: #libc, Mordante, ldionne

Spies: Mordante, Quuxplusone, aheejin, libcxx-commits, carlosgalvezp

Differential Revision: https://reviews.llvm.org/D113849
2021-11-16 20:14:07 +01:00
Mircea Trofin 1ee32055ea Reland "[benchmarks] Move libcxx's fork of google/benchmark and llvm/utils'""
This reverts commit e7568b68da and relands
c6f7b720ec.

The culprit was: missed that libc also had a dependency on one of the
copies of `google-benchmark`

Also opportunistically fixed indentation from prev. change.

Differential Revision: https://reviews.llvm.org/D112012
2021-11-16 10:33:31 -08:00
Louis Dionne 5c539ea9f0 [libc++] Perform the bootstrapping build before legacy builds in CI
This is to help reduce latency by running longer jobs before shorter ones.
2021-11-16 12:44:22 -05:00
Mircea Trofin e7568b68da Revert "[benchmarks] Move libcxx's fork of google/benchmark and llvm/utils'"
This reverts commit c6f7b720ec.

Some buildbots are failing, will investigate and reland.
Example:
  https://lab.llvm.org/buildbot#builders/138/builds/14067
  https://lab.llvm.org/buildbot#builders/73/builds/20159
2021-11-16 09:28:50 -08:00
Mircea Trofin c6f7b720ec [benchmarks] Move libcxx's fork of google/benchmark and llvm/utils'
under third-party

This change:
- moves the libcxx copy of `google/benchmark` to
`third-party/benchmkark`
- points the 2 uses of the library (libcxx and llvm/utils) to this copy

We picked the licxx copy because it is the most up to date.

Differential Revision: https://reviews.llvm.org/D112012
2021-11-16 09:16:11 -08:00
Nilay Vaish 7f287390d7 [libc++] Add introsort to avoid O(n^2) behavior
This commit adds a benchmark that tests std::sort on an adversarial inputs,
and uses introsort in std::sort to avoid O(n^2) behavior on adversarial
inputs.

Inputs where partitions are unbalanced even after 2 log(n) pivots have
been selected, the algorithm switches to heap sort to avoid the
possibility of spending O(n^2) time on sorting the input.
Benchmark results show that the intro sort implementation does
significantly better.

Benchmarking results before this change. Time represents the sorting
time required per element:

----------------------------------------------------------------------------------------------------------
Benchmark                                                                Time             CPU   Iterations
----------------------------------------------------------------------------------------------------------
BM_Sort_uint32_QuickSortAdversary_1                                   3.75 ns         3.74 ns    187432960
BM_Sort_uint32_QuickSortAdversary_4                                   3.05 ns         3.05 ns    231211008
BM_Sort_uint32_QuickSortAdversary_16                                  2.45 ns         2.45 ns    288096256
BM_Sort_uint32_QuickSortAdversary_64                                  32.8 ns         32.8 ns     21495808
BM_Sort_uint32_QuickSortAdversary_256                                  132 ns          132 ns      5505024
BM_Sort_uint32_QuickSortAdversary_1024                                 498 ns          497 ns      1572864
BM_Sort_uint32_QuickSortAdversary_16384                               3846 ns         3845 ns       262144
BM_Sort_uint32_QuickSortAdversary_262144                             61431 ns        61400 ns       262144
BM_Sort_uint64_QuickSortAdversary_1                                   3.93 ns         3.92 ns    181141504
BM_Sort_uint64_QuickSortAdversary_4                                   3.10 ns         3.09 ns    222560256
BM_Sort_uint64_QuickSortAdversary_16                                  2.50 ns         2.50 ns    283639808
BM_Sort_uint64_QuickSortAdversary_64                                  33.2 ns         33.2 ns     21757952
BM_Sort_uint64_QuickSortAdversary_256                                  132 ns          132 ns      5505024
BM_Sort_uint64_QuickSortAdversary_1024                                 478 ns          477 ns      1572864
BM_Sort_uint64_QuickSortAdversary_16384                               3932 ns         3930 ns       262144
BM_Sort_uint64_QuickSortAdversary_262144                             61646 ns        61615 ns       262144

Benchmarking results after this change:

----------------------------------------------------------------------------------------------------------
Benchmark                                                                Time             CPU   Iterations
----------------------------------------------------------------------------------------------------------
BM_Sort_uint32_QuickSortAdversary_1                                   6.31 ns         6.30 ns    107741184
BM_Sort_uint32_QuickSortAdversary_4                                   4.51 ns         4.50 ns    158859264
BM_Sort_uint32_QuickSortAdversary_16                                  3.00 ns         3.00 ns    223608832
BM_Sort_uint32_QuickSortAdversary_64                                  44.8 ns         44.8 ns     15990784
BM_Sort_uint32_QuickSortAdversary_256                                 69.0 ns         68.9 ns      9961472
BM_Sort_uint32_QuickSortAdversary_1024                                 118 ns          118 ns      6029312
BM_Sort_uint32_QuickSortAdversary_16384                                175 ns          175 ns      4194304
BM_Sort_uint32_QuickSortAdversary_262144                               210 ns          210 ns      3407872
BM_Sort_uint64_QuickSortAdversary_1                                   6.75 ns         6.73 ns    103809024
BM_Sort_uint64_QuickSortAdversary_4                                   4.53 ns         4.53 ns    160432128
BM_Sort_uint64_QuickSortAdversary_16                                  2.98 ns         2.97 ns    234356736
BM_Sort_uint64_QuickSortAdversary_64                                  44.3 ns         44.3 ns     15990784
BM_Sort_uint64_QuickSortAdversary_256                                 69.2 ns         69.2 ns     10223616
BM_Sort_uint64_QuickSortAdversary_1024                                 119 ns          119 ns      6029312
BM_Sort_uint64_QuickSortAdversary_16384                                173 ns          173 ns      4194304
BM_Sort_uint64_QuickSortAdversary_262144                               212 ns          212 ns      3407872

Differential Revision: https://reviews.llvm.org/D113413
2021-11-16 11:38:46 -05:00
Louis Dionne 4eda928660 [libc++] Add missed comment in https://reviews.llvm.org/D113910 2021-11-16 11:36:06 -05:00
Mark de Wever bfc253c000 [libc++][nfc] Improve standard conformance.
The return type of the deleted functions doesn't match the synopsis in
the standard.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D114000
2021-11-16 17:30:35 +01:00
Mark de Wever 3ddede8bfa [libc++][doc] Update format implementation status. 2021-11-16 17:29:40 +01:00
Nilay Vaish d17d89f4eb [libc++] Remove not needed call to __is_long()
The string is known to be long since __grow_by unconditionally calls
__set_long_cap().

Differential Revision: https://reviews.llvm.org/D113910
2021-11-16 11:26:13 -05:00
Matheus Izvekov 35f798d05d
[libcxx] CI: only build native target for bootstrapping-build
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D113950
2021-11-16 17:22:30 +01:00
Mark de Wever 0e50216f22 [libc++][format][nfc] Remove dead code.
This was an early part of the prototype. This has never been shipped
enabled and the final version of this code looks completely different.
2021-11-16 16:02:26 +01:00
Mark de Wever 59a98dc208 [libc++][doc] Fix copy pasted comment. 2021-11-16 15:56:59 +01:00
Mark de Wever f0bb6c760c [libc++][doc] Add a todo.
As suggested in D113831.
2021-11-16 15:56:29 +01:00
Mark de Wever 5baa4ee30b [libc++][NFC] Move format_to_n_result.
Places `format_to_n_result` to its own file. While working on D112361 it
turns out the type will be used outside the format header.

Reviewed By: #libc, Quuxplusone, Mordante

Differential Revision: https://reviews.llvm.org/D113831
2021-11-16 15:51:49 +01:00
Zbigniew Sarbinowski 422cf2b506 [SystemZ][z/OS] Fix warnings from unsigned int to long in 32-bit mode
This patch fixes the warnings which shows up when libcxx library started to be compiled in 32-bit mode on z/OS.
More specifically, the assignment from unsigned int to time_t aka long was flags as follows:
 ```
libcxx/include/c++/v1/__support/ibm/nanosleep.h:31:11: warning: implicit conversion changes signedness: 'unsigned int' to 'time_t' (aka 'long') [-Wsign-conversion]
  __sec = sleep(static_cast<unsigned int>(__sec));
        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libcxx/include/c++/v1/__support/ibm/nanosleep.h:36:36: warning: implicit conversion changes signedness: 'unsigned int' to 'long' [-Wsign-conversion]
      __rem->tv_nsec = __micro_sec * 1000;
                     ~ ~~~~~~~~~~~~^~~~~~
libcxx/include/c++/v1/__support/ibm/nanosleep.h:47:36: warning: implicit conversion changes signedness: 'unsigned int' to 'long' [-Wsign-conversion]
      __rem->tv_nsec = __micro_sec * 1000;
                     ~ ~~~~~~~~~~~~^~~~~~
3 warnings generated.
```

Here is a small test case illustrating the issue:

```
typedef long    time_t ;
unsigned int sleep(unsigned int );
int main() {
  time_t sec = 0;
#ifdef FIX
  sec = static_cast<time_t>(sleep(static_cast<unsigned int>(sec)));
#else
  sec = sleep(static_cast<unsigned int>(sec));
#endif
}
```
clang++ -c -Wsign-conversion -m32 t.C
```
t.C:8:9: warning: implicit conversion changes signedness: 'unsigned int' to 'time_t' (aka 'long') [-Wsign-conversion]
  sec = sleep(static_cast<unsigned int>(sec));
      ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reviewed By: ldionne, #libc, Quuxplusone, Mordante

Differential Revision: https://reviews.llvm.org/D112837
2021-11-16 13:51:35 +00:00
Chuanqi Xu 2e6ae1d3f2 [libcxx] [Coroutine] Conform Coroutine Implementation
Since coroutine is merged in C++ standard and the support for coroutine
seems relatively stable. It's the time to move the implementation of
coroutine out of the experimental directory and the std::experimental
namespace. This patch creates header <coroutine> with conformed
implementation with C++ standard. To avoid breaking user's code too
fast, the <experimental/coroutine> header is remained. Note that
<experimental/coroutine> is deprecated and it would be removed in
LLVM15.

Reviewed By: Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D109433
2021-11-16 14:13:13 +08:00
Matheus Izvekov c9e46219f3
[clang] retain type sugar in auto / template argument deduction
This implements the following changes:
* AutoType retains sugared deduced-as-type.
* Template argument deduction machinery analyses the sugared type all the way
down. It would previously lose the sugar on first recursion.
* Undeduced AutoType will be properly canonicalized, including the constraint
template arguments.
* Remove the decltype node created from the decltype(auto) deduction.

As a result, we start seeing sugared types in a lot more test cases,
including some which showed very unfriendly `type-parameter-*-*` types.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith, #libc, ldionne

Differential Revision: https://reviews.llvm.org/D110216
2021-11-15 23:07:45 +01:00
Louis Dionne 855a419b92 [libc++] Add missing _LIBCPP_HIDE_FROM_ABI to __rewrap_iter 2021-11-15 10:10:33 -05:00
Mikhail Maltsev 6938270fa6 [libcxx] Fix enable_if condition of std::reverse_iterator::operator=
The template std::is_assignable<T, U> checks that T is assignable from
U. Hence, the order of operands in the instantiation of
std::is_assignable in the std::reverse_iterator::operator= condition
should be reversed.

This issue remained unnoticed because std::reverse_iterator has an
implicit conversion constructor. This patch adds a test to check that
the assignment operator is used directly, without any implicit
conversions. The patch also adds a similar test for
std::move_iterator.

Reviewed By: Quuxplusone, ldionne, #libc

Differential Revision: https://reviews.llvm.org/D113417
2021-11-15 13:08:36 +00:00
Matheus Izvekov 6438a52df1
Revert "[clang] retain type sugar in auto / template argument deduction"
This reverts commit 4d8fff477e.
2021-11-15 00:29:05 +01:00
Mark de Wever b19e823ff9 [libc++][NFC] Fixes code alignment.
D112904 fixed some code alignment issues, but it seems only line was
omitted. (Found while resolving merge conflicts for my own patches.)
2021-11-13 19:11:24 +01:00
Matheus Izvekov 4d8fff477e
[clang] retain type sugar in auto / template argument deduction
This implements the following changes:
* AutoType retains sugared deduced-as-type.
* Template argument deduction machinery analyses the sugared type all the way
down. It would previously lose the sugar on first recursion.
* Undeduced AutoType will be properly canonicalized, including the constraint
template arguments.
* Remove the decltype node created from the decltype(auto) deduction.

As a result, we start seeing sugared types in a lot more test cases,
including some which showed very unfriendly `type-parameter-*-*` types.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D110216
2021-11-13 03:35:22 +01:00
David Tenty 4602f52d48 [libcxx][AIX] XFAIL tests enabled by locale.fr_FR.UTF-8
We missed the tests in the earlier XFAIL-ing because the locale.fr_FR.UTF-8
feature wasn't available, but since an upgrade these are now showing up
on the CI.

Differential Revision: https://reviews.llvm.org/D113791
2021-11-12 16:28:24 -05:00
Alfsonso Gregory f46f93b478 [libc++][NFC] Resolve Python 2 FIXME
We don't use Python 2 anymore, so let us do the recommended fix instead
of using the workaround made for Python 2.

Differential Revision: https://reviews.llvm.org/D107715
2021-11-12 13:55:22 -05:00
Brian Cain 2d0aede515 [libcxx] Change the type of __size to correspond
__size was declared as unsigned which was compatible with
2021-11-12 08:30:38 -08:00
Daniel McIntosh 75ecd1f38c [libcxx][format] Fix how we handle char traits in formatter<string> and formatter<string_view>
Right now we drop the char_traits template argument, which presumes that
string<_CharT, _Traits> and string<_CharT> are interchangeable.

Reviewed By: Mordante, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D112017
2021-11-11 14:49:40 -05:00
Louis Dionne dce5fc56b6 [libc++] Implement file_clock::{to,from}_sys
This is part of https://wg21.link/P0355R7. I am adding these methods
to provide an alternative for the {from,to}_time_t methods that were
removed in https://llvm.org/D113027.

Differential Revision: https://reviews.llvm.org/D113430
2021-11-11 14:17:02 -05:00
Louis Dionne 4e70b50b74 [libc++] Disallow running the libc++ benchmarks in standalone builds
We are trying to remove duplication of third-party code in
https://reviews.llvm.org/D112012, which will move the Google
Benchmark code outside of the `libcxx/` directory. That breaks
running the benchmarks in the Standalone build. Since we have
deprecated the Standalone build anyway, this patch just removes
support for the benchmark in Standalone mode until we remove that
mode entirely.

Differential Revision: https://reviews.llvm.org/D113503
2021-11-11 14:13:36 -05:00
Louis Dionne 3016ceb30d [libc++] Allow running the bootstrapping CI build on Darwin
Instead of hard-coding the target for our CI nodes, use the default
compiler triple. Also, allow building compiler-rt for the single
specified triple in case we're running on Darwin (otherwise, the
bootstrapping build complains).

Differential Revision: https://reviews.llvm.org/D113683
2021-11-11 14:12:34 -05:00
Nikolas Klauser b57c22ade8 [libc++] Implement P2186R2 (Remove Garbage Collection)
Reviewed By: Quuxplusone, #libc, ldionne

Differential Revision: https://reviews.llvm.org/D112869
2021-11-11 19:03:00 +01:00
Mark de Wever 4732dd3010 [libc++] Use addressof in list.
This addresses the usage of `operator&` in `<list>`.

(Note there are still more headers with the same issue.)

Reviewed By: #libc, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D112654
2021-11-11 18:56:08 +01:00
Mark de Wever f7345de64f [libc++] Use addressof in forward_list.
This addresses the usage of `operator&` in `<forward_list>`.

(Note there are still more headers with the same issue.)

Reviewed By: #libc, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D112660
2021-11-11 18:47:15 +01:00
Nikolas Klauser f0d5a60fc1 [libc++] Implement P1147R1 (Printing volatile T*)
Differential Revision: https://reviews.llvm.org/D113482
2021-11-11 11:10:29 -05:00
Louis Dionne 4d8db4a997 [libc++] Fix GDB pretty printer test on 32 bit targets
On 32 bit targets, size_t is unsigned int, not unsigned long, so
std::bitset's template argument gets printed with a `u` suffix,
not `ul`.
2021-11-11 11:09:36 -05:00
MarcoFalke faa019c0e3
[libc++] Fix segmentation fault in __do_put_integral
6 chars are not sufficient to represent all formats for 64 bit integers.

This was accidentally introduced in commit b889cbf366 (https://reviews.llvm.org/D112830).

This causes failures in downstream projects, for example:

* https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40817
* https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40841

Differential Revision: https://reviews.llvm.org/D113600
2021-11-10 21:26:05 +01:00
Sean Fertile e068c84762 [libc++][AIX] Alignment of bool on AIX is 1
Update test so that we check for a 1 byte alignment on AIX PPC32.

Differential Revision: https://reviews.llvm.org/D112087
2021-11-10 13:01:32 -05:00
David Tenty 2b416b4647 [libcxx][CI][AIX] Switch to LLVM_ENABLE_RUNTIMES
and to the new `runtimes` top level CMakeLists.txt since the old path is now deprecated. This requires a slight adjustment of the libcxxabi CMake, since there are required macro definitions we previously got via the `llvm/CMakeList.txt` path.

Reviewed By: ldionne, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D113403
2021-11-09 16:04:10 -05:00
Mark de Wever 65fceaebc7 [libc++] Adds missing forward_list merge tests.
During the review of D112660 it turned out the tests for
`std::forward_list::merge` are incomplete.

Adds tests for the rvalue reference overloads. The tests are extended to
better test the Effects [forward.list.ops]/25 and Remarks
[forward.list.ops]/27 of the function:
- x is empty after the merge.
- Pointers and references to the moved elements of x now refer to those
  same elements but as members of *this.
- Iterators referring to the moved elements will continue to refer to
  their elements, but they now behave as iterators into *this, not into x.
- The algorithm is stable.

Reviewed By: Quuxplusone, #libc, ldionne

Differential Revision: https://reviews.llvm.org/D113364
2021-11-09 20:12:02 +01:00
Louis Dionne 181763d475 [libc++] Simplify selftest to avoid passing arguments to it
This makes the test pass on executors that don't support passing additional
arguments.

Differential Revision: https://reviews.llvm.org/D113483
2021-11-09 13:18:23 -05:00
Louis Dionne a4ba780510 [libc++] Enable -Wformat-nonliteral when building libc++
Using user-provided data as a format string is a well known source of
security vulnerabilities. For this reason, it is a good idea to compile
our code with -Wformat-nonliteral, which basically warns if a non-constant
string is used as a format specifier. This is the compiler’s best signal
that a format string call may be insecure.

I audited the code after adding the warning and made sure that the few
places where we used a non-literal string as a format string were not
potential security issues. I either disabled the warning locally for
those instances or fixed the warning by using a literal. The idea is
that after we add the warning to the build, any new use of a non-literal
string in a format string will trigger a diagnostic, and we can either
get rid of it or disable the warning locally, which is a way of
acknowledging that it has been audited.

I also looked into enabling it in the test suite, which would perhaps
allow finding additional instances of it in our headers, however that
is not possible at the moment because Clang doesn't support putting
__attribute__((__format__(...))) on variadic templates, which would
be needed.

rdar://84571685

Differential Revision: https://reviews.llvm.org/D112927
2021-11-09 13:17:45 -05:00
Mark de Wever 1e78d5d008 [libc++] Fix lifetime issues of temporaries.
The ASAN build failed due to using pointers to a temporary whose
lifetime had expired.

Updating the libc++ Docker image to Ubuntu Focal caused some breakage.
This was temporary disabled in D112737. This re-enables two of these
tests.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D113137
2021-11-09 19:01:22 +01:00
Mark de Wever a948a0a23c [libc++] Mark a failing test.
The tests fails in debug mode since it manipulates an iterator to a
`std::string` returned from the dylib. This is a known issue for the
debug iterators.

Updating the libc++ Docker image to Ubuntu Focal caused some breakage.
This was temporary disabled in D112737. This re-enables one of these
tests.

Reviewed By: ldionne, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D113139
2021-11-09 19:00:09 +01:00