Commit Graph

7339 Commits

Author SHA1 Message Date
Arthur O'Dwyer 4b7bad9eae [libc++] Implement D2351R0 "Mark all library static cast wrappers as [[nodiscard]]"
These [[nodiscard]] annotations are added as a conforming extension;
it's unclear whether the paper will actually be adopted and make them
mandatory, but they do seem like good ideas regardless.

https://isocpp.org/files/papers/D2351R0.pdf

This patch implements the paper's effect on:
- std::to_integer, std::to_underlying
- std::forward, std::move, std::move_if_noexcept
- std::as_const
- std::identity

The paper also affects (but libc++ does not yet have an implementation of):
- std::bit_cast

Differential Revision: https://reviews.llvm.org/D99895
2021-04-12 12:29:15 -04:00
Arthur O'Dwyer d7eb797ea5 [libc++] [test] Detect an improperly noexcept'ed __decay_copy.
`__decay_copy` is used by `std::thread`'s constructor to copy its arguments
into the new thread. If `__decay_copy` claims to be noexcept, but then
copying the argument does actually throw, we'd call std::terminate instead
of passing this test. (And I've verified that adding an unconditional `noexcept`
to `__decay_copy` does indeed fail this test.)

Differential Revision: https://reviews.llvm.org/D100277
2021-04-12 12:28:01 -04:00
Louis Dionne 8508b1c133 [libc++] Divorce the std Lit feature from the -std=XXX compiler flag
After this patch, we can use `--param std=c++20` even if the compiler only
supports -std=c++2a. The test suite will handle that for us. The only Lit
feature that isn't fully baked will always be the "in development" one,
since we don't know exactly what year the standard will be ratified in.

This is another take on https://reviews.llvm.org/D99789.

Differential Revision: https://reviews.llvm.org/D100210
2021-04-12 11:55:39 -04:00
Louis Dionne 344d381d9f [libc++] NFC: Remove duplicate synopsis from <__string> 2021-04-12 11:49:43 -04:00
Louis Dionne 6a1ac88fc1 [libc++] Split std::get_temporary_buffer out of <memory>
Differential Revision: https://reviews.llvm.org/D100216
2021-04-12 11:46:31 -04:00
Louis Dionne 0b439e4cc9 [libc++] Split std::allocator out of <memory>
Differential Revision: https://reviews.llvm.org/D100216
2021-04-12 11:46:29 -04:00
Louis Dionne 26beecfe47 [libc++] Split auto_ptr out of <memory>
Differential Revision: https://reviews.llvm.org/D100216
2021-04-12 11:46:25 -04:00
Mark de Wever ae103003b2 [libc++] [CI] Validate the output of the generated scripts.
This adds a CI job validating that the output of
utils/generate_feature_test_macro_components.py,
libcxx/utils/generate_header_inclusion_tests.py, and
utils/generate_header_tests.py are up to date.

The validation method has been copied from the Format job.

Differential Revision: https://reviews.llvm.org/D99862
2021-04-11 15:35:23 +02:00
Louis Dionne b125392259 [libc++] NFC: Move unused include of <limits> to allocator_traits.h
The include should have been moved when I split allocator_traits.h out
of memory.
2021-04-09 15:31:55 -04:00
Martin Storsjö 1e5f68d80a [libcxx] [test] Add more tests for renaming directories in fs.op.rename
This was requested during the review of D98640.

Differential Revision: https://reviews.llvm.org/D99982
2021-04-09 21:24:34 +03:00
Martin Storsjö 1f1f8e239b [libcxx] [test] Use GetWindowsInaccessibleDir() in a couple more tests
Differential Revision: https://reviews.llvm.org/D98443
2021-04-09 21:24:34 +03:00
Martin Storsjö b166441bbe [libcxx] [test] Use GetWindowsInaccessibleDir() instead of dirs with perms::none in fs.op.is_*
Differential Revision: https://reviews.llvm.org/D98442
2021-04-09 21:24:34 +03:00
jasonliu f3d7536b24 [libc++] Fix abs and div overload issue for compilers on AIX
Summary:
AIX system's stdlib.h provide different overload of abs and div
depending on compiler versions.

For example, std::div(long, long) and std::abs(long) are not available
from OS's stdlib.h when building with clang, but they are available
when building with xlclang compiler.

Therefore, we need to provide those extra overloads in libc++'s stdlib.h
when OS's stdlib.h does not.

Differential Revision: https://reviews.llvm.org/D99767
2021-04-09 14:47:13 +00:00
zoecarver 097d77d611 [libcxx] Allow shared_ptr's unique_ptr converting constructor to support array types.
Refs: https://bugs.llvm.org/show_bug.cgi?id=32147

Differential Revision: https://reviews.llvm.org/D80882
2021-04-08 22:04:57 -07:00
Mark de Wever 48fa06f70b [libc++] Update contributor documentation.
The document has the following updates:
- Rename 'feature test' to 'feature-test', the latter is the spelling
  used in the Standard.
- Add information how an ABI list can be downloaded from Buildkite.

Differential Revision: https://reviews.llvm.org/D99290
2021-04-07 18:33:27 +02:00
Christopher Di Bella 920c0f7e09 [libcxx] adds __cpp_lib_concepts feature-test macro
Also adjusts C++20 status paper to indicate full concepts support.

Depends on D96477, D99817.

Differential Revision: https://reviews.llvm.org/D99805
2021-04-07 16:14:45 +00:00
Christopher Di Bella c7ad020099 [libcxx] adds remaining callable concepts
* `std::predicate`
* `std::relation`
* `std::equivalence_relation`
* `std::strict_weak_order`

Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Differential Revision: https://reviews.llvm.org/D96477
2021-04-07 16:14:45 +00:00
Christopher Di Bella cedd07df51 [libcxx] fixes `common_reference` requirement for `swappable_with`
LWG3175 identifies that the `common_reference` requirement for
`swappable_with` is over-constraining and doesn't need to concern itself
with cv- or reference qualifiers.

Differential Revision: https://reviews.llvm.org/D99817
2021-04-07 05:51:36 +00:00
Louis Dionne 69190f95b1 [libc++] NFCI: Fix test pinning down RTTI implementation on Apple platforms
The test didn't handle arm64 correctly.
2021-04-06 16:15:48 -04:00
Arthur O'Dwyer 2d0f1fa472 [libc++] Header inclusion tests.
As mandated by the Standard's various synopses, e.g. [iterator.synopsis].
Searching the TeX source for '#include' is a good way to find all of these
mandates.

The new tests are all autogenerated by utils/generate_header_inclusion_tests.py.
I was SHOCKED by how many mandates there are, and how many of them
libc++ wasn't conforming with.

Differential Revision: https://reviews.llvm.org/D99309
2021-04-06 15:31:56 -04:00
Arthur O'Dwyer ae318beb35 [libc++] Post-commit review on D99928.
The "user-defined conversion by implicit constructor" codepath is already
handled by `B(int)`; we don't need to test `A(const A&)` a second time
via `DA` (nor the isomorphic case with `DB`).
We don't need `&` anywhere in this test.
Generally, `operator()` should be const; this test needn't be special.
(No functional change in test coverage.)
2021-04-06 15:31:55 -04:00
Martin Storsjö a9a7498b3f [libcxx] [test] Allow C:\System Volume Information to be missing
If running in a Windows Container, there is no such directory at all.

If running from within bash on Windows Server, the directory seems to
be fully accessible. (The mechanics of this isn't fully understood, and
it doesn't seem to happen on desktop versions.)

If the directory isn't available with the expected behaviour, mark those
individual tests as unsupported. (The test as a whole is considered to
pass, but the unsupported test is mentioned in a test summary printed on
stdout.)

Differential Revision: https://reviews.llvm.org/D98960
2021-04-06 20:55:18 +03:00
Martin Storsjö 948dd664c3 [libcxx] Fix the type attribute for a couple templates
Use `_LIBCPP_TEMPLATE_VIS` instead of `_LIBCPP_TYPE_VIS` for a template
class.

This fixes the nodiscard_extensions.pass.cpp and a couple
func.search.default test cases when built in MSVC/DLL configurations.

Differential Revision: https://reviews.llvm.org/D99932
2021-04-06 19:54:34 +03:00
Martin Storsjö 91d6debbb9 [libcxx] [test] Use dedicated types for the invocable concept tests for multiple overloads
This should be clearer, instead of relying on rules for implicit
conversions regarding built in float/integer types.

Differential Revision: https://reviews.llvm.org/D99928
2021-04-06 19:54:34 +03:00
Christopher Di Bella 96dbdd753a [libcxx] adds remaining callable concepts
* `std::predicate`
* `std::relation`
* `std::equivalence_relation`
* `std::strict_weak_order`

Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Differential Revision: https://reviews.llvm.org/D96477
2021-04-06 16:35:57 +00:00
Zbigniew Sarbinowski 916093f49f [SystemZ][z/OS] correct rc and errno within nanosleep()
This patch fixes rc and errno within nanosleep(). It also updates __rem parameter as well it introduces cast to handle conversions from long into unsigned int to avoid warnings.

Reviewed By: Mordante

Differential Revision: https://reviews.llvm.org/D99373
2021-04-06 15:36:58 +00:00
Christopher Di Bella c25c22d5f9 [libcxx] moves `std::invoke` into `__functional_base`
Including `<concepts>` in other standard library headers (such as
`<iterator>`) creates circular dependencies due to `<functional>`.
Since `<concepts>` only needs `std::invoke` from `<functional>`, the
easiest, fastest, and cleanest way to eliminate the circular dep is to
move `std::invoke` into `__functional_base`.

This has the added advantage of `<concepts>` not transitively importing
`<functional>`.

Differential Revision: https://reviews.llvm.org/D99041
2021-04-06 01:25:15 +00:00
Martin Storsjö 740e349762 [libcxx] [ci] Add a Windows CI buildkite configuration
Differential Revision: https://reviews.llvm.org/D99093
2021-04-06 00:09:16 +03:00
Arthur O'Dwyer 9abff04e50 [libc++] Fix test_macros.h in the same way as commit 49e5a896 fixed __config.
Since D99515, this header triggers -Wundef on Mac OSX older than 10.15.
This is now fixed.
2021-04-04 18:08:19 -04:00
Arthur O'Dwyer 27e5bffbf6 [libc++] Fix the header guard from _LIBCPP_STEAMBUF to _LIBCPP_STREAMBUF. 2021-04-04 17:39:50 -04:00
Mark de Wever c2c68a5940 [libc++] Improve generate_feature_test_macro_components.py.
This improves the naming of the fields `depends`/`internal_depends`. It
also adds the documentation for this script. The changes are based on
D99290 and its review comments.

Differential Revision: https://reviews.llvm.org/D99615
2021-04-04 20:08:32 +02:00
Martin Storsjö f619783882 [libcxx] [test] Link against msvcprt as C++ ABI library in tests
This matches what we link the library itself against (set in
CMakeLists.txt). When testing a static library version of libc++,
this is needed for essentially every test due to libc++ object files
requiring it.

Also with libc++ built as a DLL, some tests directly call functions that
are provided by msvcprt (such as std::set_new_handler), thus this fixes
a number of tests in that configuration too.

Differential Revision: https://reviews.llvm.org/D99263
2021-04-04 19:18:32 +03:00
Nico Weber d3b74dc1e4 Restore 8954fd436c after c06a8f9caa
Else, just-built clang can't build programs that include libc++ headers
on macOS if you build via the 'all' target.
2021-04-02 09:19:36 -04:00
Marek Kurdej 49e5a896d1 [libc++] Fix build on macOS older than 10.15.
* This was introduced in D99515 that added -Wundef flag. CI run on macOS 10.15 and this problem wasn't caught before.
2021-04-02 10:32:54 +02:00
Martin Storsjö 28ea218417 [libcxx] [test] Fix invocable tests on Windows
MSVC had a bug regarding preferring intergral conversions over
floating conversions. This is fixed in MSVC 19.28 and newer. Clang in
MSVC mode so far only mimics the old, buggy behaviour, but will
hopefully soon be fixed to comply with the new behaviour too
(see https://reviews.llvm.org/D99663).

Make the negative test to use a distinctly different type,
leaving checks for compiler specific bugs out of the libcxx test.

Differential Revision: https://reviews.llvm.org/D99641
2021-04-02 10:49:27 +03:00
Martin Storsjö f8013a35b6 [libcxx] [test] Make the condvar wait_for tests a bit more understandable. NFC.
This was requested in the review of D99175; rename the "runs"
variable to clarify what it means wrt the test, and move updating of
it to the main function to clarify its behaviour wrt the two runs
further.

Differential Revision: https://reviews.llvm.org/D99768
2021-04-02 10:46:15 +03:00
Christopher Di Bella 7959d59028 [libcxx] adds concepts `std::totally_ordered` and `std::totally_ordered_with`
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Reviewed By: Mordante

Differential Revision: https://reviews.llvm.org/D98983
2021-04-02 06:00:21 +00:00
Louis Dionne 17095dc861 [libc++][NFC] Increase readability of typeinfo comparison of ARM64
We wasted a good deal of time trying to figure out whether our implementation
was correct. In the end, it was, but it wasn't so easy to determine. This
patch dumbs down the implementation and improves the documentation to make
it easier to validate.

See https://lists.llvm.org/pipermail/libcxx-dev/2020-December/001060.html.

Differential Revision: https://reviews.llvm.org/D97802
2021-04-01 16:38:34 -04:00
Martin Storsjö 01aa9e1f6e [libcxx] [test] Make the condvar wait_for tests less brittle
These seem to fail occasionally (they are marked as possibly requiring
a retry).

When doing a condvar wait_for(), it can wake up before the timeout
as a spurious wakeup. In these cases, the wait_for() method returns that
the timeout wasn't hit, and the test reruns another wait_for().

On Windows, it seems like the wait_for() operation often can end up
returning slightly before the intended deadline - when intending to
wait for 250 milliseconds, it can return after e.g. 235 milliseconds.
In these cases, the wait_for() doesn't indicate a timeout.

Previously, the test then reran a new wait_for() for a full 250
milliseconds each time. So for N consecutive wakeups slightly too early,
we'd wait for (N+1)*250 milliseconds. Now it only reruns wait_for() for
the remaining intended wait duration.

Differential Revision: https://reviews.llvm.org/D99175
2021-04-01 21:42:11 +03:00
Martin Storsjö 46e992f905 [libcxx] [test] Remove XFAIL LIBCXX-WINDOWS-FIXME from time.clock.file/now.pass.cpp
This doesn't fail when _LIBCPP_HAS_NO_INT128 is defined consistently
in both CMAKE_CXX_FLAGS and LIBCXX_TEST_COMPILER_FLAGS; the XFAIL was
added based on early CI testruns where that flag was missing in
LIBCXX_TEST_COMPILER_FLAGS.

Differential Revision: https://reviews.llvm.org/D99705
2021-04-01 21:25:41 +03:00
Louis Dionne 8f7c1b2272 [libc++] NFC: Add a simple test to make sure we destroy elements in std::list
Differential Revision: https://reviews.llvm.org/D99672
2021-04-01 13:46:33 -04:00
Louis Dionne e93c95dea1 [libc++] Print the CMake version before generating CMake 2021-04-01 13:42:22 -04:00
Louis Dionne 232d3a3e47 [libc++] Fix codesigning in run.py
Without this patch, we'd always try to codesign the first argument in
the command line, which in some cases is not something we can codesign
(e.g. `bash` for some .sh.cpp tests).

Note that this "hack" is the same thing we do in `ssh.py` - we might need
to admit that it's not a hack after all in the future, but I'm not ready
for that yet.

Differential Revision: https://reviews.llvm.org/D99726
2021-04-01 13:39:49 -04:00
Petr Hosek 96d8c6b571 [CMake] Remove {LIBCXX,LIBCXXABI,LIBUNWIND}_INSTALL_PREFIX
These variables were introduced during early work on the runtimes build
but were obsoleted by {LIBCXX,LIBCXXABI,LIBUNWIND}_INSTALL_LIBRARY_DIR.

Differential Revision: https://reviews.llvm.org/D99697
2021-04-01 10:13:07 -07:00
Marek Kurdej 5c703f0fd8 [libc++] Build and test with -Wundef warning. NFC.
This will avoid typos like `_LIBCPP_STD_VERS` (<future>) or using `#if TEST_STD_VER > 17` without including "test_macros.h".

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D99515
2021-04-01 08:32:56 +02:00
Arthur O'Dwyer 3bdd674fbf [libc++] Mark convert_copy.pass.cpp as UNSUPPORTED on clang-13 (i.e. trunk).
Because the constexpr-time codepath triggers a Clang bug. It seems
that Clang compiles it okay in release mode, but when Clang itself
is compiled in debug mode (with assertions turned on), this input
triggers an assertion failure in Clang itself. See comments on D96385
and Clang bug report https://bugs.llvm.org/show_bug.cgi?id=45879

This commit should get the debug-mode buildbots back to green.
2021-03-31 10:22:11 -04:00
Joerg Sonnenberger 9f4022ffeb [libc++] Avoid <climits> dependency in <thread>
The standard guarantees sleep durations of 2^63-1 nanoseconds to work.
Instead of depending on INT64_MAX or ULONGLONG_MAX to exist via the
header pollution, fold the constant directly. That has the additional
positive side effect that it avoids long double arithmetic bugs in GCC.

Differential Revision: https://reviews.llvm.org/D99516
2021-03-31 15:28:16 +02:00
Martin Storsjö 7acfd85756 [libcxx] [test] Don't add dirs from the LIB env var to PATH
The directories in LIB normally only contain import libraries or
static libraries, no runtime DLLs that would need to be found
while running tests.

This code stems from 1cd196e7b4,
which (among other things) tried to do this:

> * [Test] Fix handling of library runtime search paths by correctly adding them
>   to the PATH variable when running the tests.

It's unclear to me exactly what this fixed (or tried to) at the time,
as the LIB var doesn't normally point to runtime libs.

Differential Revision: https://reviews.llvm.org/D99241
2021-03-31 09:05:47 +03:00
Martin Storsjö 4a0a85becc [libcxx] [test] Fix tests of <cuchar> that unexpectedly succeed on windows
The tests expect that the <cuchar> include should fail. When libc++
is built on top of the MSVC runtime, the header does exist provided
by MSVC. Therefore, just mark the test as unsupported on windows,
to avoid tests that unexpectedly succeed.

Differential Revision: https://reviews.llvm.org/D99096
2021-03-31 09:05:47 +03:00
Louis Dionne c06a8f9caa [libc++] Include <__config_site> from <__config>
Prior to this patch, we would generate a fancy <__config> header by
concatenating <__config_site> and <__config>. This complexifies the
build system and also increases the difference between what's tested
and what's actually installed.

This patch removes that complexity and instead simply installs <__config_site>
alongside the libc++ headers. <__config_site> is then included by <__config>,
which is much simpler. Doing this also opens the door to having different
<__config_site> headers depending on the target, which was impossible before.

It does change the workflow for testing header-only changes to libc++.
Previously, we would run `lit` against the headers in libcxx/include.
After this patch, we run it against a fake installation root of the
headers (containing a proper <__config_site> header). This makes use
closer to testing what we actually install, which is good, however it
does mean that we have to update that root before testing header changes.
Thus, we now need to run `ninja check-cxx-deps` before running `lit` by
hand.

Differential Revision: https://reviews.llvm.org/D97572
2021-03-30 14:06:11 -07:00