Commit Graph

7413 Commits

Author SHA1 Message Date
Martin Storsjö 15fdd536f9 [libcxx] [test] Fix path.itr/iterator.pass.cpp for windows
Differential Revision: https://reviews.llvm.org/D98107
2021-03-06 19:27:14 +02:00
David Zarzycki f4059cc352 Partially revert "[runtimes] Use add_lit_testsuite to register lit testsuites"
This partially reverts commit e1173c8794
until we find out why libcxx tests are failing under runtimes build.
2021-03-06 06:06:55 -05:00
Martin Storsjö 714644a36c [libcxx] [test] Move the is_<platform> functions down to subclasses
If cross testing (and manually specifying a LIBCXX_TARGET_INFO in the
cmake configuration, as the default is to match the build platform),
we want the accessors for querying the target platform, is_windows,
is_darwin, to return the right value depending on which target info
class is used, not based on what platform is running the build and
driving the tests.

When LIBCXX_TARGET_INFO isn't defined, the right target info class
is chosen automatically based on the platform one is running on, so
this shouldn't make any practical difference for such setups.

Differential Revision: https://reviews.llvm.org/D98045
2021-03-06 08:52:34 +02:00
Christopher Di Bella c744332793 [libcxx] adds std::ranges::swap, std::swappable, and std::swappable_with
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96742

Differential Revision: https://reviews.llvm.org/D97162
2021-03-05 19:03:57 -08:00
Jessica Clarke 5d6e0e474e [benchmark] Replace references to M680x0 with M68k
The former was the old unusual name of the out-of-tree backend but it
was renamed to M68k during the code review process to conform with how
almost everything refers to the Motorola 68000 family of processors.
Thus, update the comments to avoid confusion when the backend lands.
2021-03-06 01:04:36 +00:00
Martin Storsjö 9e29852f5c [libcxx] [test] Fix detection of clang-cl when cross compiling
When cross compiling, the compiler tool doesn't have a .exe suffix.

Differential Revision: https://reviews.llvm.org/D98026
2021-03-06 00:49:26 +02:00
Martin Storsjö 1540646dbd [libcxx] Don't add -Wall when building in MSVC mode
The MSVC -Wall (or /Wall) option maps (in clang-cl) to the GCC style
option -Weverything, which we don't really want. Instead use -W4 which
is the corresponding MSVC option.

This silences the build with clang-cl, which previously used to
output 100 warnings per translation unit.

Differential Revision: https://reviews.llvm.org/D98035
2021-03-05 23:48:02 +02:00
Martin Storsjö 24a176b107 [libcxx] Apply pragma for silencing warning when building with clang-cl too
This silences warnings about unused functions (in an anonymous
namespace).

Differential Revision: https://reviews.llvm.org/D98036
2021-03-05 21:36:54 +02:00
Petr Hosek e1173c8794 [runtimes] Use add_lit_testsuite to register lit testsuites
The runtimes build uses variables set by add_lit_testsuite to collect
testsuites from all the runtimes.

Differential Revision: https://reviews.llvm.org/D97913
2021-03-05 10:37:21 -08:00
Martin Storsjö 232fec941d [libcxx] [test] Add an option to ssh.py for using a different temp path
If cross testing on Windows via WSL (at least with WSL 1), the Windows
executables can't be executed if they are in WSL specific directories
(like /tmp).

Differential Revision: https://reviews.llvm.org/D98028
2021-03-05 19:37:31 +02:00
Martin Storsjö 1adaf48d23 [libcxx] [test] Fix path.decompose for windows
Add ifdefs to the test reference tables for cases where paths are
interpreted differently (paths that contain a root name).

Fix test assumptions regarding has_root_name() and is_absolute() and
add logic to verify the results of is_absolute() for the test cases in
the table.

Also add a testcase for the path "//net/", which seemed like an
omission.

Differential Revision: https://reviews.llvm.org/D89943
2021-03-05 19:37:31 +02:00
Marek Kurdej 43e4214173 [libc++] [C++2b] [P1682] Add to_underlying.
* https://wg21.link/P1682

Reviewed By: ldionne, Mordante, #libc

Differential Revision: https://reviews.llvm.org/D97365
2021-03-05 10:31:21 +01:00
Martin Storsjö 29012ce986 [libcxx] Map ERROR_BAD_PATHNAME to errc::no_such_file_or_directory on windows
Opening a path like \\server (without a trailing share name and
path) produces this error, while opening e.g. \\server\share
(for a nonexistent server/share) produces ERROR_BAD_NETPATH (which
already is mapped).

This happens in some testcases (in fs.op.proximate); as proximate()
calls weakly_canonical() on the inputs, weakly_canonical() checks
whether the path exists or not. When the error code wasn't recognized
(it mapped to errc::invalid_argument), the stat operation wasn't
conclusive and weakly_canonical() errored out. With the proper error
code mapping, this isn't considered an error, just a nonexistent
path, and weakly_canonical() can proceed.

This roughly matches what MS STL does - it doesn't have
ERROR_BAD_PATHNAME in its error code mapping table, but it
checks for this error code specifically in the return of their
correspondence of the stat function.

Differential Revision: https://reviews.llvm.org/D97619
2021-03-05 10:49:03 +02:00
Martin Storsjö 99c7b53294 [libcxx] Avoid infinite recursion in create_directories, if the root directory doesn't exist
Differential Revision: https://reviews.llvm.org/D97618
2021-03-05 10:49:01 +02:00
Martin Storsjö 1773eec692 [libcxx] Implement semaphores for windows
Also add WIN32_LEAN_AND_MEAN before including windows.h, for consistency
with other sources.

Differential Revision: https://reviews.llvm.org/D97539
2021-03-05 10:48:59 +02:00
Christopher Di Bella 6eb5d55c55 [libcxx] fixes up some [concepts]-related code
* moves `std::copy_constructible` so it comes before
  `std::equality_comparable_with`
* replaces a few uses of `auto`
2021-03-04 22:09:43 -08:00
Christopher Di Bella e63ddcccf8 [libcxx] adds concepts std::equality_comparable[_with]
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96660

Reviewed By: ldionne, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D97176
2021-03-04 18:24:04 -08:00
Martin Storsjö 53d7c63657 [libcxx] [test] Use separate references for windows in the path.append test
Differential Revision: https://reviews.llvm.org/D89945
2021-03-04 23:21:02 +02:00
Louis Dionne c7f244b897 [libc++] Properly pick up the Ninja from Xcode in the CI script 2021-03-04 16:03:39 -05:00
Muiez Ahmed 53c8587dcd [SystemZ][z/OS] Missing non-posix functions libc++
The aim is to add missing non-posix functions for z/OS libc++ (strtod_l and strtof_l).

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D97051
2021-03-04 15:23:21 +00:00
David Spickett 6e5342a6b0 [libcxx] Move Linaro AArch64 buildbots to buildkite
Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D96267
2021-03-04 10:22:17 +00:00
Martin Storsjö c793f68d9b [libcxx] Don't use dllimport for a static member in a template
This fixes clang warnings (that are treated as errors when running
the test suite):

libcxx/include/string:4409:59: error: definition of dllimport static field [-Werror,-Wdllimport-static-field-def]
               basic_string<_CharT, _Traits, _Allocator>::npos;

The warning is normally not visible as long as the libc++ headers
are treated as system headers.

The same construct is always an error in MSVC.

(One _LIBCPP_FUNC_VIS was added in
2d8f23f571, which broke DLL builds.
59919c4d6b fixed this by adding another
_LIBCPP_FUNC_VIS on the declaration for consistency, but the underlying
issue remained, that one can't use dllimport here.)

Differential Revision: https://reviews.llvm.org/D97168
2021-03-04 08:55:27 +02:00
Christopher Di Bella 647af31e74 [libcxx] adds concept `std::assignable_from`
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96660

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96742
2021-03-03 22:41:55 -08:00
Christopher Di Bella f893312c1a [libcxx] adds concept `std::common_with`
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96660

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96683
2021-03-03 20:01:11 -08:00
Arthur O'Dwyer 09fa1d0e50 [libc++] Introduce __identity_t<T>. NFCI.
This is just a shorter synonym for `__identity<T>::type`.
Use it consistently throughout, where possible.

There is still some metaprogramming in <memory> and <variant>
where `__identity` is being used _without_ immediately calling
`::type` on it; but this is the unusual case, and it will become
even less usual as we start deliberately protecting certain types
against deduction (e.g. D97742).

Differential Revision: https://reviews.llvm.org/D97862
2021-03-03 22:23:14 -05:00
Christopher Di Bella 3f5438c46c [libcxx] adds concept `std::common_reference_with`
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96657

Reviewed By: ldionne, Mordante, #libc

Differential Revision: https://reviews.llvm.org/D96660
2021-03-03 17:52:41 -08:00
Louis Dionne 460953ad9a [libc++] Temporary hack: disable Apple back-deployment testing
Apple back-deployment testing is currently failing because Green Dragon
is down. To avoid stalling the whole CI pipeline because of that, I am
temporarily disabling those jobs until Green Dragon is back, or even
better we have found a different way to store those small artifacts.
2021-03-03 17:02:48 -05:00
Louis Dionne 3c62198c61 [libc++] NFC: Normalize links to bug reports 2021-03-03 13:45:29 -05:00
Louis Dionne 5034d7115d [libc++] Use generator expression to simplify the CMake code
A comment was left for when we would require CMake >= 3, which we do now.
I expect this should be a NFC.

Differential Revision: https://reviews.llvm.org/D97341
2021-03-03 12:59:51 -05:00
Louis Dionne 5601305fb3 [libc++/abi] Replace uses of _NOEXCEPT in src/ by noexcept
We always build the libraries in a Standard mode that supports noexcept,
so there's no need to use the _NOEXCEPT macro.

Differential Revision: https://reviews.llvm.org/D97700
2021-03-03 12:57:31 -05:00
zoecarver 84a50f5911 [libc++] Add bind_front function (P0356R5).
Implementes [[ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0356r5.html | P0356R5 ]]. Adds `bind_front` to `functional`.

Reviewed By: ldionne, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D60368
2021-03-02 16:18:06 -08:00
Christopher Di Bella eadece333f [libcxx] adds common_reference to <type_traits>
Implements part of P0898R3 Standard Library Concepts

Reworks D74351 to use requires-clauses over SFINAE and so that it more
closely follows the wording.

Co-authored by: Michael Schellenberger Costa <mschellenbergercosta@googlemail.com>

(Michael did all the heavy lifting and I came in to polish it for
 submission, since Michael is focussing on `std::format` now.)

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96657
2021-03-02 22:33:37 +00:00
Martin Storsjö 34ee3d91a8 [libcxx] [test] Pass some windows environment variables through to test processes
Normally, the run.py wrapper script runs the child processes in
a clean environment, with only the environment variables available
that are passed via the --env parameter.

However, the COMSPEC and TEMP variables are kind of necessary when
running some tests; COMSPEC is necessary for finding the interpreter
when executing commands via std::system().

Before f1a96de1bc, tests were executed
via an intermediate shell which implicitly readded the COMSPEC variable.

The TEMP variable allows temp files to be placed in a sensible
location; if unset, they're placed in the default temp fallback of
C:\Windows instead.

Differential Revision: https://reviews.llvm.org/D97452
2021-03-02 22:39:14 +02:00
Martin Storsjö c5e8f024dc [libcxx] Explicitly return the expected error code in create_directories if the parent isn't a directory
On windows, going ahead and actually trying to create the directory
doesn't return an error code that maps to
std::errc::not_a_directory in this case.

This fixes two cases of
    TEST_CHECK(ErrorIs(ec, std::errc::not_a_directory))
in filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
for windows (in testcases added in 59c72a7012).

Differential Revision: https://reviews.llvm.org/D97090
2021-03-02 22:21:29 +02:00
Martin Storsjö 4adb4bca05 [libcxx] [test] Fix a test error with condvars with trivial destruction
If the destructor is trivial (_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION,
the constructor always is), the compiler warns about the
std::condition_variable being unused.

Add a cast to void to silence the warning about the object being unused.

Differential Revision: https://reviews.llvm.org/D97540
2021-03-02 20:34:22 +02:00
Louis Dionne c5659dd4cc [libc++] Add a utility script to run the Docker image used by builders
Several contributors have been asking me how to reproduce the CI
environment locally. This is the last step towards making that work
out-of-the-box. Basically, just run `libcxx/utils/ci/run-buildbot-container`
and you're good to go.

Differential Revision: https://reviews.llvm.org/D97782
2021-03-02 13:06:14 -05:00
Martin Storsjö 74c883f7e5 [libcxx] [test] Use the native path types in path.compare
This makes sure that it actually tests the right compare() overloads
in windows configurations.

This also fixes the allocation guards that enforce no allocations
while running the compare() functions.

Differential Revision: https://reviews.llvm.org/D97551
2021-03-01 21:01:46 +02:00
Louis Dionne 60ba1fefab [libc++/abi] Allow running back-deployment testing against libc++abi
Before this patch, we could only link against the back-deployment libc++abi
dylib. This patch allows linking against the just-built libc++abi, but
running against the back-deployment one -- just like we do for libc++.

Also, add XFAIL markup to flag expected errors.

Differential Revision: https://reviews.llvm.org/D91069
2021-03-01 12:13:03 -05:00
Marek Kurdej 11ef785cdd [libc++] [docs] [C++2b] Update status page with issues (and forgotten papers) adopted in November 2020 and February 2021 virtual meetings.
Sources:
* https://github.com/cplusplus/draft/pull/4380 (November 2020)
* https://github.com/cplusplus/draft/pull/4523 (February 2021)
* https://github.com/cplusplus/draft/issues?q=is%3Aissue+LWG+Motion
2021-03-01 11:19:18 +01:00
Vitaly Buka 3744ba24dc [NFC][libc++] Suppress "warning: ignoring return value"
According to the comment on the next line
it's expected behaviour.
2021-02-26 14:32:54 -08:00
Casey Carter 30cd3dd0fb [libcxx][test] Don't require Container<cv T> extension on non-libc++
... when testing `default_initializable`. Also, include `<memory>` for `unique_ptr`.
2021-02-26 13:40:22 -08:00
Christopher Di Bella e4dd614ae8 [libcxx] cleans up __cpp_concepts mess
libc++ was previously a bit confused by what the value of __cpp_concepts
should be. Also replaces `__floating_point` with `floating_point` now
that it exists.

Differential Revision: https://reviews.llvm.org/D97015
2021-02-26 18:43:40 +00:00
Louis Dionne 27f9ed7850 [libc++] Make the from-scratch config work on macOS out-of-the-box 2021-02-26 13:11:49 -05:00
Louis Dionne f8e810c359 [libc++] Allow running CI on macOS when Ninja isn't installed outside of Xcode
Xcode does bundle Ninja, so we can use that Ninja if there's no system-wide
Ninja installed. This is useful on some CI bots we have that don't come
with Ninja pre-installed.
2021-02-26 12:15:12 -05:00
Louis Dionne cb3de09503 [libc++] Remove the now unused macos-trunk and macos-backdeployment CI scripts
We use the run-buildbot script everywhere now.
2021-02-26 10:29:02 -05:00
Martin Storsjö c7d46f221e [libcxx] Use the allocating form of getcwd() on Glibc and Apple platforms
This avoids having to query pathconf for a max size for
preallocating a buffer for the return value.

This is an extension to the POSIX getcwd() spec.

Differential Revision: https://reviews.llvm.org/D97460
2021-02-26 00:14:12 +02:00
Martin Storsjö fb2e4f5401 [libcxx] [test] Add a MinGW target
This can't easily be autodetected (unless LIBCXX_TARGET_TRIPLE is
specified, or unless we query what the compiler's default target is,
which only is supported by clang), but can be chosen manually via
LIBCXX_TARGET_INFO.

This chooses mingw style lib naming, and uses -nostdlibc++ instead
of -nodefaultlib -nostdlib (as the latter requires specifying a lot of
details manually - this is done in the cmake config though).

Differential Revision: https://reviews.llvm.org/D97294
2021-02-26 00:10:48 +02:00
Martin Storsjö 72fe14d40a [libcxx] [cmake] Add asm to the runtimes build languages
This fixes building libunwind with a new enough version of cmake.

(libunwind treats its asm sources as C depending on the cmake version
on some platforms; this fixes builds when such workarounds aren't used,
when cmake treats asm correctly on its own.)

Differential Revision: https://reviews.llvm.org/D97399
2021-02-26 00:10:48 +02:00
Martin Storsjö 3be7968c36 [libcxx] [test] Ifdef out uses of create_fifo on windows
Restructure code in directory_entry.obs/file_type_obs.pass.cpp
and directory_entry.obs/hard_link_count.pass.cpp to reduce the
amount of ifdeffery needed.

In file_type_obs.pass.cpp, we can't inline the calls to
env.create_* into the lambda calls (e.g. "test_path(env.create_*())"),
because the lambda removes the referenced file, and the hardlink
must be created while the earlier test file exists.

In hard_link_count.pass.cpp, move restoration of the original
directory permissions to the end of the lambda, so that new
directory entries can be created after the lambda has run once.

Differential Revision: https://reviews.llvm.org/D89948
2021-02-26 00:10:47 +02:00
Martin Storsjö f15377084c [libcxx] [test] Use string().c_str() to convert a std::filesystem::path to a const char*
On Windows, path::value_type is wchar_t, so one can't pass the return
value of path::c_str() directly to std::remove().

This matches what was done for tests under std/input.output/filesystems
in 81db3c31aa and
3784bdf217.

Differential Revision: https://reviews.llvm.org/D97458
2021-02-26 00:10:47 +02:00
Louis Dionne 618862e89a [libc++] Fix incorrect forwarding in tuple's assignment operator
Also, add a bunch of tests for tuple and pair's assignment operators
involving reference types.

Differential Revision: https://reviews.llvm.org/D97419
2021-02-25 14:56:16 -05:00
Martin Storsjö c218c80c73 [libcxx] [test] Quote the path to the python interpreter
This should allow running tests with the interpreter in some of the
default paths where Python for Windows might be installed.

Differential Revision: https://reviews.llvm.org/D97369
2021-02-24 22:24:41 +02:00
Louis Dionne 5f5416e1c4 [libc++] NFC: Fix a few tests in tuple that would succeed trivially 2021-02-24 11:33:41 -05:00
Louis Dionne 4814985dec [libc++] NFC: Fix a few tests in pair that would succeed trivially 2021-02-24 11:25:45 -05:00
Martin Storsjö 90232b2ecd [libcxx] [test] Don't pass INCLUDE to clang via -isystem
Passing the MSVC include dirs via -isystem makes them included before
clang's own include resource dir (<prefix>/lib/clang/<version>/include).
This causes includes of stddef.h to bypass clang's stddef.h which
defines max_align_t, which libc++ needs defined.

This was added in 4372f06d0f when the
initial windows testing support was added, and has been brought along
since. It's unclear if this was needed back then - now it no longer is
needed at least, and since libc++ started depending on max_align_t, this
became an issue.

Differential Revision: https://reviews.llvm.org/D97167
2021-02-24 11:16:49 +02:00
Marek Kurdej 77bd454da3 [libc++] [docs] [C++2b] Update status page with papers adopted in February 2021 virtual meeting. 2021-02-24 09:40:33 +01:00
Martin Storsjö f97ea0d5b3 [libcxx] [test] Define _CRT_STDIO_ISO_WIDE_SPECIFIERS while building tests
This matches how libc++ itself is built. This avoids errors due to
mismatch if linking libc++ statically.

Differential Revision: https://reviews.llvm.org/D97169
2021-02-23 15:57:30 +02:00
Mark de Wever c61e511f38 [NFC][libc++] Fix _LIBCPP_HAS_BITSCAN64 usage.
Seems line was accidentally left in
llvm-svn: 290924 86eebc5b65

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D97211
2021-02-23 08:13:49 +01:00
Louis Dionne a0839b14df [libc++] Fix tuple assignment from types derived from a tuple-like
The implementation of tuple's constructors and assignment operators
currently diverges from the way the Standard specifies them, which leads
to subtle cases where the behavior is not as specified. In particular, a
class derived from a tuple-like type (e.g. pair) can't be assigned to a
tuple with corresponding members, when it should. This commit re-implements
the assignment operators (BUT NOT THE CONSTRUCTORS) in a way much closer
to the specification to get rid of this bug. Most of the tests have been
stolen from Eric's patch https://reviews.llvm.org/D27606.

As a fly-by improvement, tests for noexcept correctness have been added
to all overloads of operator=. We should tackle the same issue for the
tuple constructors in a future patch - I'm just trying to make progress
on fixing this long-standing bug.

PR17550
rdar://15837420

Differential Revision: https://reviews.llvm.org/D50106
2021-02-22 14:52:18 -05:00
Martin Storsjö 3d6ca4b8dc [libcxx] [test] Call create_directory_symlink when linking directories
This makes the symlinks work properly on windows.

A similar round of cleanup was done in
c41bda7f5f, but these tests were
added after that.

Differential Revision: https://reviews.llvm.org/D97089
2021-02-21 00:25:54 +02:00
Martin Storsjö 26005c788b [libcxx] Make path::format a non-class enum
The spec doesn't declare it as an enum class, and being declared
as an enum class breaks referring to the values as e.g.
path::auto_format.

Differential Revision: https://reviews.llvm.org/D97084
2021-02-21 00:25:54 +02:00
Mark de Wever 84dbcdd5ff [libc++] Fix the build for AppleClang.
Forgot to add some parts of D93593, this should disable the tests on
Apple. Seems Louis was right ;-)
2021-02-20 13:54:46 +01:00
Martin Storsjö 7b5f0050a9 [libcxx] [test] Remove two unnecesary files/variables in a test
These don't seem to have any function in the test.

The non_regular_file one seems to have been added in
0f8c8f59df, without any apparent
purpose there.

Differential Revision: https://reviews.llvm.org/D97083
2021-02-20 10:20:12 +02:00
Martin Storsjö 8c305a5d82 [libcxx] Rename a method in PathParser for clarity. NFC.
Differential Revision: https://reviews.llvm.org/D97081
2021-02-20 10:20:11 +02:00
Mark de Wever 1a5c92f680 [libc++] Fixes _LIBCPP_HAS_NO_CONCEPTS
Before the define was in a GCC specific part. Now it's available for all
compilers. The patch had its CI run in D93593.
2021-02-20 09:13:16 +01:00
zoecarver 6c75a84ce7 [libc++][nfc] Only test if pair is_assignable after C++03.
In C++03 libc++ uses a different set of constructors which aren't
constrained, so these tests won't work. This should fix the bots.

Refs: 82c4701.
2021-02-19 15:14:44 -08:00
Martin Storsjö 99fc4a6584 [libcxx] Enable filesystem by default for mingw targets
This feature can be built successfully for windows now. However,
the helper functions for __int128_t aren't available in MSVC
configurations, so don't enable it by default there yet. (See
https://reviews.llvm.org/D91139 for discussion on how to proceed
with things in MSVC environments.)

Differential Revision: https://reviews.llvm.org/D97075
2021-02-20 01:09:10 +02:00
zoecarver 82c4701d4e [libc++][nfc] SFINAE on pair/tuple assignment operators: LWG 2729.
This patch ensures that SFINAE is used to delete assignment operators in pair and tuple based on issue 2729.

Differential Review: https://reviews.llvm.org/D62454
2021-02-19 13:25:34 -08:00
Martin Storsjö f4f5fb9151 [libcxx] Make generic_*string return paths with forward slashes on windows
This matches what MS STL returns; in std::filesystem, forward slashes
are considered generic dir separators that are valid on all platforms.

Differential Revision: https://reviews.llvm.org/D91181
2021-02-19 21:49:51 +02:00
zoecarver dbc89028d7 [libcxx] Fix LWG 2875: shared_ptr::shared_ptr(Y*, D, […]) constructors should be constrained.
Fixes LWG issue 2875.

Differential Revision: https://reviews.llvm.org/D81414
2021-02-19 11:11:39 -08:00
Martin Storsjö 513463fd26 [libcxx] Have lexically_normal return the path with preferred separators
Differential Revision: https://reviews.llvm.org/D91179
2021-02-19 21:06:54 +02:00
Marek Kurdej bcb5a124ae [libc++] Turn off clang-format for auto-generated version header. NFC. 2021-02-19 17:26:16 +01:00
zoecarver 6a328c66d3 [libc++] shared_ptr deleter requirements (LWG 2802).
This patch implements 2802. Requires _Deleter to have call operator and be move constructible. Based on D62233.

Refs PR37637.

Differential Revision: https://reviews.llvm.org/D62274
2021-02-18 21:31:07 -08:00
zoecarver 82b82b9430 Mark 2534 as Complete.
c90dee1 fixed LWG 1203 which supresses LWG 2534 as well.

Refs D62889.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96885
2021-02-18 21:28:49 -08:00
Christopher Di Bella 9f4f6ac94b [libcxx] adds concept `std::uniform_random_bit_generator`
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/D96577
2021-02-19 01:47:29 +00:00
Joerg Sonnenberger a77e918016 libcxx: use early returns
Differential Revision: https://reviews.llvm.org/D96955
2021-02-18 19:43:14 +01:00
Nico Weber 9d36f70ef2 libcxx: fix a documentation typo
See `grep 'option.LIBCXX_INCLUDE_TESTS' libcxx/CMakeLists.txt`.
2021-02-18 11:59:51 -05:00
Zbigniew Sarbinowski 25aa0d1244 [SystemZ][ZOS] Guard using declaration for ::fchmodat
The use of fchmodat() is beeing guarded but its using declaration is not. Let's use the same guard in both places to avoid compiler errors on platforms where `fchmodat` does not exist.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D96303
2021-02-18 15:01:04 +00:00
Martin Storsjö 78d693faec [libcxx] Implement append and operator/ properly for windows
The root_path function has to be changed to return the parsed bit
as-is; otherwise a path like "//net" gets a root path of "//net/", as
the root name, "//net", gets the root directory (an empty string) appended,
forming "//net/". (The same doesn't happen for the root dir "c:" though.)

Differential Revision: https://reviews.llvm.org/D91178
2021-02-18 09:03:53 +02:00
Martin Storsjö 8a783e6845 [libcxx] Implement is_absolute properly for windows
Differential Revision: https://reviews.llvm.org/D91177
2021-02-17 19:33:05 +02:00
Louis Dionne 642048eea0 [libc++] Allow retries in a few more flaky tests 2021-02-17 11:20:40 -05:00
Martin Storsjö 929f0bcc24 [libcxx] Implement parsing of root_name for paths on windows
Differential Revision: https://reviews.llvm.org/D91176
2021-02-17 15:45:31 +02:00
Zbigniew Sarbinowski 5f9be2c3e3 [SystemZ][ZOS] Prefer -nostdlib++ as opposed to -nodefaultlibs when building c++ libraries
Let's use -nostdlib++ rather than -nodefaultlibs when building libc++/libc++abi/libunwind libraries. The default is -nostdlib++ if supported by a build compiler like it is the case with clang, otherwise -nodefaultlibs is used as before.

This change is needed to avoid additional changes at the link step and not to increase the maintenance costs. If clang with -nodefaultlibs is used all the libraries which are removed but required would have to be manually added in. This set of libraries are unique and will send out.

The propose change will allow to make the link step simple for other platforms as well.

Reviewed By: #libc, #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D95875
2021-02-16 18:42:14 +00:00
Colin Finck 0f5020af7f [libc++] Build thread_win32.cpp only if LIBCXX_HAS_PTHREAD_API is not set
This allows building libc++ against winpthreads from mingw-w64 to support
operating systems older than Windows 7. The remaining libc++ code already
supports `WIN32` with `LIBCXX_HAS_PTHREAD_API`.

Note that there is also the older "pthreads-win32". However, that support
library implements `pthread_t` as a struct, which violates the libc++
assumption that `pthread_t` is always a scalar and can be compared,
ordered, and set to zero.

Differential Revision: https://reviews.llvm.org/D96339
2021-02-16 10:03:42 -05:00
Arthur O'Dwyer 5f58374bbe [libc++] Change `std::numeric_limits` to just `numeric_limits` in <chrono>.
The namespace is unnecessary, and libc++ style is not to include it on type names.
(As opposed to function names, where qualification affects ADL; and in certain
function signatures where `std::` and `_VSTD::` might be mangled differently.
This is none of those situations.)
2021-02-15 16:12:10 -05:00
Louis Dionne 5d0d465ad4 [libc++] Mark __cpp_lib_constexpr_memory as being implemented 2021-02-15 15:26:53 -05:00
Dimitry Andric 328261019f Define new/delete in libc++ when using libcxxrt
Always turn on LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS, if libcxxrt is used
as the C++ ABI library, since libcxxrt does not provide the full set
ofnew and delete operators. In particular, the aligned versions of these
operators are completely missing. This primarily addresses builds on
FreeBSD, as this platform uses libcxxrt by default.

Also, attempt to provide a FreeBSD.cmake cache file, with hopefully sane
settings, partially copied from the Apple.cmake cache file. This needs
more work, probably some additions to ci build scripts (although I am
not aware of any 'official' FreeBSD build bots).

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96720
2021-02-15 21:22:12 +01:00
Zbigniew Sarbinowski 48fcce1aea [SystemZ][ZOS] Fix __libcpp_thrad_isnull()
Previous pthread revision https://reviews.llvm.org/D91875 missed a small change for `__libcpp_thrad_isnull()` required for z/OS.

Reviewed By: zibi

Differential Revision: https://reviews.llvm.org/D96302
2021-02-12 20:21:11 +00:00
Zbigniew Sarbinowski cb2d2ae56a [SystemZ][ZOS] Provide CLOCK_MONOTONIC alternative
We need CLOCK_MONOTONIC equivalent implementation for z/OS within libc++. The default implementation is asserting.

On z/OS the lack of  'clock_gettime()' and 'time_point()' force us to look for alternatives.
The current proposal is to use `gettimeofday()` for CLOCK_MONOTONIC  which is also used in CLOCK_REALTIME.  This will allow us to skip the assertion with compromised CLOCK_MONOTONIC implementation which will not guarantee to never go back in time because it will use `gettimeofday()` but only when it's set.

Is this a good compromise for platforms which does not support monotonic clock?
Hopefully this will spark the discussion and agreement how to proceed in this situation.

Reviewed By: #libc, ldionne, hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D93542
2021-02-12 18:39:48 +00:00
Mark de Wever f8772da8cc [libc++][format] Enable format_error on older compilers.
It seems like modifying the header doesn't cause libc++ to be rebuild.
So the breakage of the previous commit didn't happen on my system.

This should fix the build of https://buildkite.com/mlir/mlir-core
2021-02-11 19:11:20 +01:00
Mark de Wever af83e89ae3 [libc++][format] Improve Add basic_format_parse_context.
Add an additional guard to prevent building on older clang versions.

This should fix the build of https://buildkite.com/mlir/mlir-core
2021-02-11 18:55:54 +01:00
Mark de Wever 38ddeade65 [libc++][format] Add basic_format_parse_context.
Implements parts of:
- P0645 Text Formatting

Depends on D92214

Reland with changes:
The format header will only be compiled if the compiler used has support
for concepts. This should fix the issues with the initial version.

Differential Revision: https://reviews.llvm.org/D93166
2021-02-11 17:57:54 +01:00
Ilya Tokar c81d52997a [libc++] Use builtins in more math.h functions.
Not using builtins doesn't always imply worse code,
but for e. g. isinf, this is 30%+ faster.

Before:
name        time/op
BM_isinf     2.14ns ± 2%

After:
name        time/op
BM_isinf     1.33ns ± 2%

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D88854
2021-02-10 15:17:42 -05:00
Christopher Di Bella 17db24a7a8 [libcxx] adds concepts `std::invocable` and `std::regular_invocable`
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/D96235
2021-02-10 19:35:53 +00:00
Christopher Di Bella c63de225fd [libcxx] adds concept std::derived_from
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D74292
2021-02-10 19:30:08 +00:00
Christopher Di Bella bee7b07f23 [libcxx] adds [concepts.arithmetic]
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/D88131
2021-02-10 19:04:57 +00:00
Louis Dionne 183b75f667 [libc++] Remove c++98 Lit features in the test suite
We don't populate a Lit feature named c++98 since 31cbe0f240.
2021-02-10 13:32:41 -05:00
Christopher Di Bella 2193e8be3e [libcxx] adds concept `std::copy_constructible`
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96230

Differential Revision: https://reviews.llvm.org/D96232
2021-02-10 17:56:42 +00:00
Christopher Di Bella 2b2f36a8b1 [libcxx] adds concept `std::move_constructible`
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D77961

Differential Revision: https://reviews.llvm.org/D96230
2021-02-10 17:33:35 +00:00
Colin Finck ebfadd82cb [libc++] Fix copy-paste mistake in __threading_support
Differential Revision: https://reviews.llvm.org/D96115
2021-02-10 11:00:32 -05:00
Christopher Di Bella 8caf835337 [libcxx] adds concept `std::convertible_to`
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/D77961
2021-02-10 03:27:41 +00:00
Arthur O'Dwyer eec04092d6 [libc++] [LWG2993] reference_wrapper<T> conversion from U&&
Implement the resolution of LWG2993. Replace a deleted constructor
with a constructor that SFINAEs away in appropriate circumstances.
Also, now that the constructor is templated, we must have an
explicit deduction guide to make CTAD work.

Some tests have been merged in from Agustín Bergé's D40259.

Differential Revision: https://reviews.llvm.org/D92725
2021-02-09 15:50:25 -05:00
zoecarver dea74b2820 [libc++] Add `noexcept` to `string::find` and similar members.
Adds `noexcept` to `string_view`/`string::find` and similar members
(`rfind`, etc.). See discussion in D95251. Refs D95821.

Reviewed By: curdeius, ldionne

Differential Revision: https://reviews.llvm.org/D95848
2021-02-09 11:47:40 -08:00
Mark de Wever 171956aab3 Revert "[libc++] Require C++20 to build the benchmarks."
There are build bots without C++20 support building the benchmarks.

This reverts commit 34acc91642.
2021-02-09 19:59:34 +01:00
Mark de Wever 34acc91642 [libc++] Require C++20 to build the benchmarks.
Some work-in-progress patches for the format header contain benchmarks.
The format header requires C++20 to build. This is a preparation to make
it easy to add these benchmarks.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96057
2021-02-09 18:34:07 +01:00
Mark de Wever 2544060e71 [libc++] Remove C++11 work-arounds in src.
Building libcxx requires at least C++17 so remove the old work-arounds.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96200
2021-02-09 18:31:00 +01:00
Louis Dionne 73aa09704a [libc++] Add a wait step in the BuildKite pipeline to shield macOS builders
We don't have many of those and they are rather slow, so we'd rather not run
those jobs if we know other jobs in the pipeline failed anyway.
2021-02-08 10:14:16 -05:00
Sterling Augustine a34b8b879e Various minor fixes for python 3
Switch StdTuple printer from python 2-style "next" to python 3.

Nested iteration changed enough to make the original bitset iteration
code a bit trickier than it needs to be, so unnest.

The end node of a map iterator is sometimes hard to detect in isolation,
don't fail in that case.

Differential Revision: https://reviews.llvm.org/D96167
2021-02-05 13:01:34 -08:00
Martin Storsjö d4f4e723d0 [libcxx] Implement temp_directory_path using GetTempPath on windows
This does roughly the same as the manual implementation, but checks
a slightly different set of environment variables and has a more
appropriate fallback if no environment variables are available
(/tmp isn't a very useful fallback on windows).

Differential Revision: https://reviews.llvm.org/D91175
2021-02-05 22:47:33 +02:00
Martin Storsjö 4d292d531b [libcxx] Use the posix code for directory_entry::__do_refresh
This works just fine for windows, as all the functions it calls
are implemented and wrapped for windows.

Differential Revision: https://reviews.llvm.org/D91173
2021-02-05 22:47:33 +02:00
Arthur O'Dwyer 85167fb7c2 [libc++] Further improve the contiguous-iterator story, and fix some bugs.
- Quality-of-implementation: Avoid calling __unwrap_iter in constexpr contexts.
    The user might conceivably write a contiguous iterator where normal iterator
    arithmetic is constexpr-friendly but `std::to_address(it)` isn't.

- Bugfix: When you pass contiguous iterators to `std::copy`, you should get
    back your contiguous iterator type, not a raw pointer. That means that
    libc++ can't `__unwrap_iter` unless it also does `__rewrap_iter`.
    Fortunately, this is implementable.

- Improve test coverage of the new `contiguous_iterator` test iterator.
    This catches the bug described above.

- Tests: Stop testing that we can `std::copy` //into// an `input_iterator`.
    Our test iterators may currently support that, but it seems nonsensical to me.

Differential Revision: https://reviews.llvm.org/D95983
2021-02-05 15:18:04 -05:00
zoecarver fab194898b [lic++][docs] Explain noexcept policy for narrow contracts.
Adds documentation around libc++'s policy to add noexcept to things that cannot throw but aren't marked as noexcept.

Refs LWG 3518 and D95251.

Differential Revision: https://reviews.llvm.org/D95821
2021-02-05 11:27:19 -08:00
Arthur O'Dwyer 5d9565634c Revert "Revert "[libc++] [P0879] constexpr std::nth_element, and rewrite its tests.""
This reverts commit b6ffece320.

The bug is now fixed (it was a stupid cut-and-paste kind of error),
and the regression test added. The new patch is also simpler than the old one!

Differential Revision: https://reviews.llvm.org/D96084
2021-02-05 12:02:43 -05:00
Jordan Rupprecht b6ffece320 Revert "[libc++] [P0879] constexpr std::nth_element, and rewrite its tests."
This reverts commit 207d4be4d9 due to returning incorrect results. Regression test case posted in D96074.
2021-02-04 14:03:49 -08:00
Marek Kurdej 1361c5e7d7 [libc++] Add format check to CI
Note: contrary to what I said previously, I didn't change .clang-format nor utils/generate_feature_test_macro_components.py script.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92229
2021-02-04 21:15:37 +01:00
Louis Dionne 1700ea7302 [libc++] Remove the ability to use braced-init for filesystem paths
According to my reading of http://eel.is/c++draft/filesystems#fs.class.path,
the Standard doesn't actually mention that this should work. Since other
implementations don't allow it, allowing it in libc++ is just setting a
portability trap.

Supersedes https://reviews.llvm.org/D89865.

Differential Revision: https://reviews.llvm.org/D95975
2021-02-04 11:49:00 -05:00
Louis Dionne 76fc35752d [libc++] Make feature-test macros consistent with availability macros
Before this patch, feature-test macros didn't take special availability
markup into account, which means that feature-test macros can sometimes
appear to "lie". For example, if you compile in C++20 mode and target
macOS 10.13, the __cpp_lib_filesystem feature-test macro will be provided
even though the <filesystem> declarations are marked as unavailable.
This patch fixes that.

rdar://68142369

Differential Revision: https://reviews.llvm.org/D94983
2021-02-04 11:40:22 -05:00
Louis Dionne 85b9c5ccc1 [libc++] Fix libcxx build on 32bit architectures with 64bit time_t defaults e.g. riscv32
Patch by Khem Raj.

Differential Revision: https://reviews.llvm.org/D85095
2021-02-04 11:38:54 -05:00
Mark de Wever e275e62983 [libc++] Adds a make_string test helper function.
These function makes it easier to write generic unit tests for the
format header. It solves the issue where it's not possible to use
  `templated_prefix"foo"`
where `templated_prefix` resolves to: nothing, `L`, `u8`, `u`,
or `U`. The templated_prefix would be more faster during execution.

Reviewed By: ldionne, #libc, curdeius

Differential Revision: https://reviews.llvm.org/D93414
2021-02-04 17:16:44 +01:00
Louis Dionne b51756819a [libc++] Rename include/support to include/__support
We do ship those headers, so the directory name should not be something
that can potentially conflict with user-defined directories.

Differential Revision: https://reviews.llvm.org/D95956
2021-02-04 10:16:33 -05:00
Arthur O'Dwyer 493f140792 [libc++] [P0879] constexpr std::sort
This completes libc++'s implementation of
P0879 "Constexpr for swap and swap related functions."
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0879r0.html

For the feature-macro adjustment, see
https://cplusplus.github.io/LWG/issue3256

Differential Revision: https://reviews.llvm.org/D93661
2021-02-03 18:57:05 -05:00
Arthur O'Dwyer d41c6d51cb [libc++] Rationalize our treatment of contiguous iterators and __unwrap_iter().
- Implement C++20's changes to `reverse_iterator`, so that it won't be
    accidentally counted as a contiguous iterator in C++20 mode.
- Implement C++20's changes to `move_iterator` as well.
- `move_iterator` should not be contiguous. This fixes a bug where
    we optimized `std::copy`-of-move-iterators in an observable way.
    Add a regression test for that bugfix.
- Add libcxx tests for `__is_cpp17_contiguous_iterator` of all relevant
    standard iterator types. Particularly check that vector::iterator
    is still considered contiguous in all C++ modes, even C++03.

After this patch, there continues to be no supported way to write your
own iterator type in C++17-and-earlier such that libc++ will consider it
"contiguous"; however, we now fully support the C++20 approach (in C++20
mode only). If you want user-defined contiguous iterators in C++17-and-earlier,
libc++'s position is "please upgrade to C++20."

Differential Revision: https://reviews.llvm.org/D94807
2021-02-03 16:28:38 -05:00
Martin Storsjö cdc60a3b9a [libcxx] Implement the read_symlink function for windows
Differential Revision: https://reviews.llvm.org/D91172
2021-02-03 09:23:58 +02:00
Martin Storsjö 40117b700f [libcxx] Implement the permissions function for windows
Differential Revision: https://reviews.llvm.org/D91171
2021-02-03 09:23:24 +02:00
Martin Storsjö 83d705adb2 [libcxx] Implement the canonical function for windows
Differential Revision: https://reviews.llvm.org/D91170
2021-02-02 23:03:19 +02:00
Martin Storsjö 0c71c914fa [libcxx] Implement the current_path function for windows
Differential Revision: https://reviews.llvm.org/D91169
2021-02-02 23:03:19 +02:00
Louis Dionne 3fb8385379 [libc++] Add new queues for specific macOS system versions
This will allow running back-deployment testing on macOS only on systems
running the right version of macOS. For the time being, we're cheating
because we don't have actual machines running older than 10.15.
2021-02-02 15:56:44 -05:00
Reid Kleckner bab7486416 Disable CFI in __get_elem to allow casting a pointer to uninitialized memory
Fixes usage of shared_ptr with CFI enabled, which is llvm.org/pr48993.

Differential Revision: https://reviews.llvm.org/D95827
2021-02-02 12:39:24 -08:00
Martin Storsjö a3cc99658d [libcxx] Implement the space function for windows
Differential Revision: https://reviews.llvm.org/D91168
2021-02-02 19:48:24 +02:00
Mehdi Amini 68f66f37d7 Revert "[libc++][format] Add basic_format_parse_context."
This reverts commit 35a57f39b5.

A build is broken during clang bootstrap with:

In file included from ../libcxx/src/format.cpp:9:
/tmp/ci-nGNyLRM9V3/include/c++/v1/format:153:16: error: no member named 'is_constant_evaluated' in namespace 'std::__1'
    if (_VSTD::is_constant_evaluated() && __id >= __num_args_)
        ~~~~~~~^
1 error generated.
2021-02-01 21:18:11 +00:00
Mark de Wever 35a57f39b5 [libc++][format] Add basic_format_parse_context.
Implements parts of:
- P0645 Text Formatting

Depends on D92214

Reviewed By: ldionne, curdeius, #libc

Differential Revision: https://reviews.llvm.org/D93166
2021-02-01 20:19:20 +01:00
Mark de Wever 3ffc53ba16 [libc++] Implements concept default_initializable.
Implements:
- LWG3149 DefaultConstructible should require default initialization

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

Depends on D91986

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93461
2021-02-01 19:13:24 +01:00
Ruslan Arutyunyan c448ea948c [libc++] Fix for the Bug 41784
Add deleted volatile copy-assignment operator in the most derived atomic
to fix the Bug 41784. The root cause: there is an `operator=(T) volatile`
that has better match than the deleted copy-assignment operator of the base
class when `this` is `volatile`. The compiler sees that right operand of
the assignment operator can be converted to `T` and chooses that path
without taking into account the deleted copy-assignment operator of the
base class.

The current behavior on libstdc++ is different from what we have in libc++.
On the same test compilation fails with libstdc++. Proof: https://godbolt.org/z/nebPYd
(everything is the same except the -stdlib option).

I choose the way with explicit definition of copy-assignment for atomic
in the most derived class. But probably we can fix that by moving
`operator=(T)` overloads to the base class from both specializations.
At first glance, it shouldn't break anything.

Differential Revision: https://reviews.llvm.org/D90968
2021-02-01 10:14:22 -05:00
xgupta 94fac81fcc [Branch-Rename] Fix some links
According to the [[ https://foundation.llvm.org/docs/branch-rename/ | status of branch rename ]], the master branch of the LLVM repository is removed on 28 Jan 2021.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D95766
2021-02-01 16:43:21 +05:30
Mark de Wever 8869e2f969 [libc++] Allow building with C++17.
After committing D92214 it was noticed libc++ no longer builds with
C++17. For now reenable building with C++17. This is intended to be a
temporary measure in the future a C++20 capable compiler will be
required.
2021-01-31 14:25:01 +01:00
Casey Carter 6057517904 [libcxx][test] Silence MSVC narrowing warning 2021-01-29 11:05:52 -08:00
Casey Carter 5565092faa [libcxx][test] Silence false positive MSVC /analyze warning 2021-01-29 10:05:14 -08:00
Casey Carter 9f8ca86a87 [libcxx][test] explicitly discard bitset::test's return
... just in case some implementation annotates it `[[nodiscard]]`.
2021-01-29 10:01:51 -08:00
Martin Storsjö f65ba25cf3 [libcxx] Sanitize paths before creating symlinks on windows
The MS STL does even more cleanup (corresponding to lexically_normal
I think), but this seems to be the very minimum needed for making the
symlinks work when the target path contains non-native paths.

Differential Revision: https://reviews.llvm.org/D91145
2021-01-29 13:39:30 +02:00
Martin Storsjö efec3cc652 [libcxx] Hook up a number of operation functions to their windows counterparts
Use the corresponding wchar functions, named "_wfunc" instead of "func",
where feasible, or reimplement functions with native windows APIs.

Differential Revision: https://reviews.llvm.org/D91143
2021-01-29 13:38:45 +02:00
Martin Storsjö 592d623529 [libcxx] Implement _FilesystemClock::now() and __last_write_time for windows
Differential Revision: https://reviews.llvm.org/D91142
2021-01-29 13:38:27 +02:00
Martin Storsjö 2ff8662b5d [libcxx] Implement the stat function family on top of native windows APIs
While the windows CRTs (the modern UCRT, and the legacy msvcrt.dll
that mingw still often defaults to) do provide stat functions, they're
a bit lacking - they only provide second precision on the modification
time, lack support for symlinks and a few other details.

Instead reimplement them using a couple windows native functions,
getting exactly the info we need. (Technically, the implementation
within the CRT calls these functions anyway.)

If we only need a few fields, we could also do with fewer calls, as a
later optimization.

Differential Revision: https://reviews.llvm.org/D91141
2021-01-29 13:37:54 +02:00
Casey Carter edecee3826 [libcxx][test] move libc++-specific tests into the libcxx tree
...and rename from `version.pass.cpp` to `version.compile.pass.cpp` to follow the new convention.
2021-01-28 18:01:56 -08:00
Casey Carter ad4a6ce10c [libcxx][test] MoveOnly's comparisons are non-member
... so that comparisons with an `int` LHS and `MoveOnly` RHS are valid, as is necessary for the `partial_sort_copy` test to pass with an implementation that doesn't force a conversion to the type of the RHS as libc++ does.
2021-01-28 17:07:03 -08:00
Casey Carter 2dd0c4d846 [libcxx][test] Update directory_entry test for C++20
P1614R2 removes most of `directory_entry`'s member comparison operators, leaving only `operator==` and `operator<=>`. This test should require the comparison expressions to be valid rather than require the member functions to be present so it is correct in both C++17 and C++20 modes.
2021-01-28 09:40:54 -08:00
Mark de Wever 18fe3fe0e7 [libc++] Implements concept constructible_from
Implements parts of:
- P0898R3 Standard Library Concepts
- P1754 Rename concepts to standard_case for C++20, while we still can

Depends on: D91004

Reviewed By: ldionne, cjdb, #libc

Differential Revision: https://reviews.llvm.org/D91986
2021-01-28 18:32:47 +01:00
Mark de Wever 081c1db02d [libc++] Implement format_error.
This is the first step at implementing <format>. It adds the <format> header
and implements the `format_error`. class.

Implemnts parts of:
-P0645 Text Formatting

Reviewed By: ldionne, #libc, miscco, curdeius

Differential Revision: https://reviews.llvm.org/D92214
2021-01-28 18:02:53 +01:00
Arthur O'Dwyer 207d4be4d9 [libc++] [P0879] constexpr std::nth_element, and rewrite its tests.
This patch is more than just adding the `constexpr` keyword, because
the old code relied on `goto`, and `goto` is not constexpr-friendly.
Refactor to eliminate `goto`, and then mark it as constexpr in C++20.

I freely admit that the name `__nth_element_partloop` is bad;
I couldn't find any better name because I don't really know
what this loop is doing, conceptually. Vice versa, I think
`__nth_element_find_guard` has a decent name.

Now the only one we're still missing from P0879 is `sort`.

Differential Revision: https://reviews.llvm.org/D93557
2021-01-28 11:59:00 -05:00
Louis Dionne bf5941afcd [libc++] Fix extern-templates.sh.cpp test on Linux 2021-01-28 10:46:22 -05:00
Louis Dionne 90407b16b1 [libc++] Fix extern template test failing on Windows
See https://reviews.llvm.org/D94718#2521489 for details.
2021-01-27 13:08:52 -05:00
Arthur O'Dwyer 5386aa2627 [libc++] [P0879] constexpr heap and partial_sort algorithms
Now the only ones we're still missing from P0879
are `sort` and `nth_element`.

Differential Revision: https://reviews.llvm.org/D93512
2021-01-27 10:26:06 -05:00
Simon Tatham 7b3ba8dd02 [libcxx] Update include/__libcpp_version to match include/__config
https://reviews.llvm.org/rG5369517d20dd362a178a1b2d6c398d8898ee4620
bumped the version number in __config to 13000, causing a test failure
in libcxx/test/libcxx/libcpp_version.pass.cpp because now the two
don't match.

This is the only part of the post-release TODO in
libcxx/docs/Contributing.rst that wasn't done by that commit.
2021-01-27 15:16:55 +00:00
Tom Stellard 5369517d20 Bump the trunk major version to 13
and clear the release notes.
2021-01-26 19:37:55 -08:00
Arthur O'Dwyer fc3192026b [libc++] Give `MoveOnly` all six comparison operators, not just == and <.
Split out of D93512.
2021-01-26 19:42:00 -05:00
Louis Dionne 4210b87020 [libc++] Fix oss-fuzz build 2021-01-26 15:30:50 -05:00
Brad Smith 4b6d7fdd20 [libcxx] random_device, for OpenBSD specify optimal entropy properties
Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D94571
2021-01-25 20:55:09 -05:00
Arthur O'Dwyer f9b6fd269b [libc++] Support immovable return types in std::function.
LWG reflector consensus is that this was a bug in libc++.
(In particular, MSVC also will fix it in their STL, soon.)
Bug originally discovered by Logan Smith.

Also fix `std::function<const void()>`, which should work
the same way as `std::function<void()>` in terms of allowing
"conversions" from non-void types.

Differential Revision: https://reviews.llvm.org/D94452
2021-01-25 19:34:41 -05:00
Nico Weber a206d991f9 libcxx: Try to fix build after D92044 2021-01-25 15:10:41 -05:00
Ruslan Arutyunyan 9d50958757 [libc++] Fix build after 51faba35fd
Differential Revision: https://reviews.llvm.org/D95372
2021-01-25 13:40:47 -05:00
Arthur O'Dwyer f851db3dae [libc++] [P0879] constexpr std::reverse, partition, *_permutation.
After this patch, the only parts of P0879 that remain missing will be
std::nth_element, std::sort, and the heap/partial_sort algorithms.

Differential Revision: https://reviews.llvm.org/D93443
2021-01-25 13:09:30 -05:00
Arthur O'Dwyer 3fbd3eaf28 [libc++] Implement [P0769] "Add shift to algorithm" (shift_left, shift_right)
I believe this is a complete implementation of std::shift_left and std::shift_right from
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0769r2.pdf

Some test cases copied-with-modification from D60027.

Differential Revision: https://reviews.llvm.org/D93819
2021-01-25 12:57:04 -05:00
Mark de Wever 193cda105d [libc++][doc] Update the release notes.
Updates the libc++ release notes with the changes since the last
release.

Differential Revision: https://reviews.llvm.org/D95248
2021-01-25 18:32:13 +01:00
Ruslan Arutyunyan 51faba35fd [libc++] Implement P0655R1 visit<R>: Explicit Return Type for visit
Differential Revision: https://reviews.llvm.org/D92044
2021-01-25 11:14:45 -05:00
Marek Kurdej 5e7a93a954 [libc++] Set CMAKE_FOLDER. NFC.
* This variable populates the default value of FOLDER target property. It is used in some IDE's (e.g. MSVC) to group different targets together.
2021-01-25 09:51:16 +01:00
Zbigniew Sarbinowski 92bb81aac1 [SystemZ][ZOS] Provide PATH_MAX macro for libcxx
Defining PATH_MAX to _XOPEN_PATH_MAX which is the closest macro available on z/OS.
Note that this value is 1024 which is 4 times smaller from same macro on Linux.

Reviewed By: #libc, ldionne, hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D92110
2021-01-24 00:29:39 +00:00
Mark de Wever 99d5fad7a5 [libc++] Remove invalid C++20 code from a test.
During the review of D91986 it has been discovered the in C++11
deprecated `throw()` exception specification has been removed in
C++20. Removed the part of the test code using this feature.
2021-01-23 20:10:17 +01:00
Mark de Wever a8e06361dd [libc++] Implements concept destructible
Implements parts of:
- P0898R3 Standard Library Concepts
- P1754 Rename concepts to standard_case for C++20, while we still can

Reviewed By: ldionne, miscco, #libc

Differential Revision: https://reviews.llvm.org/D91004
2021-01-23 18:17:25 +01:00
Thorsten Schütt b973e2e2f2 [libc++] Introduce __bits
It has the low-level bit fiddling operations from bit. It eliminates a cyclic dependency between __bit_reference, bits, and vector. I want to exploit this in later patches.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D94908
2021-01-22 21:20:23 +01:00
Louis Dionne faa440786c [libc++] Bring back mach_absolute_time implementation of steady_clock
This is meant to unblock Chrome, as discussed in https://llvm.org/D74489.

Differential Revision: https://reviews.llvm.org/D95177
2021-01-22 14:54:16 -05:00
Mark de Wever 3317b38ef8 [NFC][libc++] Update the implementation status.
During the review of https://reviews.llvm.org/D93912 we failed to notice
the implementation status wasn't updated. This rectifies the issue.
2021-01-22 20:24:33 +01:00
Louis Dionne 03b6dc3005 [libc++] Fix broken build when merging libc++abi into libc++ on Apple 2021-01-22 12:39:40 -05:00
Brad Smith 1be2524b7d [libcxx] Check return value for asprintf()
local __libcpp_asprintf_l() -> libc asprintf() was inspecting the pointer (with
indeterminate value) for failure, rather than the return value of -1.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D94564
2021-01-21 19:43:11 -05:00
Marek Kurdej f3b979b65e [libc++] Use ioctl when available to get random_device entropy.
Implemented the idea from D94571 to improve entropy on Linux.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D94953
2021-01-21 18:01:02 +01:00
Alex Richardson 537d90db82 [libc++] Split re.alg tests into locale-dependent and independent tests
Currently all these tests are XFAILED on Linux even though the problem
only seems to be with the few checks that look at collation. To retain
test coverage this splits the locale-dependent tests into a separate
.pass.cpp that is XFAILed as before.
This commit also XFAILs the locale-dependent tests on FreeBSD since the
[=M=] and [.ch.] behaviour for cs_CZ also doesn't seem to match the
behaviour that is expected by these tests.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D94969
2021-01-20 15:48:50 +00:00
Wim Leflere 6ac9cb2a7c [libc++][P1679] add string contains
C++23 string contains implementation and tests

Paper: https://wg21.link/P1679R3
Standard (string): https://eel.is/c++draft/string.contains
Standard (string_view): https://eel.is/c++draft/string.view.ops#lib:contains,basic_string_view

Differential Revision: https://reviews.llvm.org/D93912
2021-01-19 14:35:07 -05:00
Louis Dionne 933518fff8 [libc++] Make LIBCXX_ENABLE_FILESYSTEM fully consistent
Previously, LIBCXX_ENABLE_FILESYSTEM controlled only whether the filesystem
support was compiled into libc++'s library. This commit promotes the
setting to a first-class option like LIBCXX_ENABLE_LOCALIZATION, where
the whole library is aware of the setting and features that depend on
<filesystem> won't be provided at all. The test suite is also properly
annotated such that tests that depend on <filesystem> are disabled when
the library doesn't support it.

This is an alternative to https://llvm.org/D94824, but also an improvement
along the lines of LIBCXX_ENABLE_LOCALIZATION that I had been wanting to
make for a while.

Differential Revision: https://reviews.llvm.org/D94921
2021-01-19 14:15:48 -05:00
Louis Dionne 68dba7eae1 [libc++] Unbreak the debug mode
When the Debug mode is enabled, we disable extern declarations because we
don't want to use the functions compiled in the library, which might not
have had the debug mode enabled when built. However, some extern declarations
need to be kept, because code correctness depends on it.

31e820378b removed those declarations, which had the unintended
consequence of breaking the debug build. This commit fixes that by
re-introducing a separate macro for the required extern declarations,
and adds a comment so that we don't fall into that trap in the future.

Differential Revision: https://reviews.llvm.org/D94718
2021-01-19 14:15:31 -05:00
Raul Tambre 480643a95c [CMake] Remove dead code setting policies to NEW
cmake_minimum_required(VERSION) calls cmake_policy(VERSION),
which sets all policies up to VERSION to NEW.
LLVM started requiring CMake 3.13 last year, so we can remove
a bunch of code setting policies prior to 3.13 to NEW as it
no longer has any effect.

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

Differential Revision: https://reviews.llvm.org/D94374
2021-01-19 17:19:36 +02:00
Alex Richardson 077a84f911 [libc++] Sync TEST_HAS_TIMESPEC_GET and _LIBCPP_HAS_TIMESPEC_GET on FreeBSD
Commit 5e416ba943 (D71522) updated the
__config header but didn't change test_macros.h.
This fixes libcxx/language.support/has_timespec_get.compile.pass.cpp on
FreeBSD12/13.

Reviewed By: #libc, dim, ldionne

Differential Revision: https://reviews.llvm.org/D94292
2021-01-19 15:02:57 +00:00
Marek Kurdej a11f8b1ad6 [libc++] [P0935] [C++20] Eradicating unnecessarily explicit default constructors from the standard library.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0935r0.html

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D91292
2021-01-19 08:22:06 +01:00
Arthur O'Dwyer 14573d44ae Regenerate the feature test macro unit-tests. NFCI.
Somehow commit 1f1250151f added the
right code but with the wrong whitespace.
2021-01-18 19:06:28 -05:00
Louis Dionne 2cb4a96a99 [libc++] NFCI: Refactor allocator_traits
The implementation had a lot of boilerplate and was more complicated than
necessary. This NFC refactoring introduces a few macros to reduce code
duplication, and uses a consistent style and formatting for the whole file.

Differential Revision: https://reviews.llvm.org/D94544
2021-01-18 17:37:25 -05:00
Wim Leflere 2776be43f0 [libc++] improve feature test macro script
I've been playing a bit with the `generate_feature_test_macro_components.py` script and replaced some hardcoded values with extra code generation (generate ALL the things).
The output is the same and it makes updating the script less work for the coming 25 C++ standards (until 2 digit number overflow).

Feel free to 'veto' if you think it's overkill.

Differential Revision: https://reviews.llvm.org/D94530
2021-01-18 15:19:21 -05:00
Louis Dionne 01a13f127a [libc++] Rename check-cxx-deps to cxx-test-depends for consistency
Several subprojects have targets that do the same thing, and they all
follow the same naming convention: llvm-test-depends, clang-test-depends,
lld-test-depends, etc.

This makes libc++ consistent with other LLVM projects.
Thanks to Duncan Exon Smith for noticing and suggesting the change.

Differential Revision: https://reviews.llvm.org/D94499
2021-01-18 14:41:53 -05:00
Reid Kleckner 4f24d0dd53 Fix libc++ clang-cl build, swap attribute order
Clang insists that __attribute__ attributes precede __declspec
attributes. This is a longstanding known issue:
https://llvm.org/pr24559. Re-order the visibility and deprecation macros
to fix the build.

Differential Revision: https://reviews.llvm.org/D94788
2021-01-15 11:44:13 -08:00
Igor Kudrin 7803636057 [libcxx testing] Fix UB in tests for std::lock_guard
If mutex::try_lock() is called in a thread that already owns the mutex,
the behavior is undefined. The patch fixes the issue by creating another
thread, where the call is allowed.

Differential Revision: https://reviews.llvm.org/D94656
2021-01-15 16:11:45 +07:00
Shoaib Meenai 0066a09579 [libc++] Give extern templates default visibility on gcc
Contrary to the current visibility macro documentation, it appears that
gcc does handle visibility attribute on extern templates correctly, e.g.
https://godbolt.org/g/EejuV7. We need this so that extern template
instantiations of classes not marked _LIBCPP_TEMPLATE_VIS (e.g.
__vector_base_common) are correctly exported with gcc when building with
hidden visibility.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D35388
2021-01-12 18:30:56 -08:00
Martin Storsjö 02f1d28ed6 [libcxx] Avoid overflows in the windows __libcpp_steady_clock_now()
As freq.QuadValue can be in the range of 10000000 to 19200000,
the multiplication before division makes the calculation overflow
and wrap to negative values every 16-30 minutes.

Instead count the whole seconds separately before adding the
scaled fractional seconds.

Add a testcase for steady_clock to check that the values returned for
now() compare as bigger than the zero time origin; this
corresponds to a testcase in Qt [1] [2] (that failed spuriously
due to this).

[1] https://bugreports.qt.io/browse/QTBUG-89539
[2] https://code.qt.io/cgit/qt/qtbase.git/tree/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp?id=f8de5e54022b8b7471131b7ad55c83b69b2684c0#n569

Differential Revision: https://reviews.llvm.org/D93456
2021-01-12 23:56:03 +02:00
Brad Smith 79f99ba65d [libcxx] Port to OpenBSD
Add initial OpenBSD support.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D94205
2021-01-12 14:21:11 -05:00
Arthur O'Dwyer eef4bdbb34 [libc++] Add a missing `<_Compare>` template argument.
Sometimes `_Compare` is an lvalue reference type, so letting it be
deduced is pretty much always wrong. (Well, less efficient than
it could be, anyway.)

Differential Revision: https://reviews.llvm.org/D93562
2021-01-12 14:18:24 -05:00
Marek Kurdej 1f1250151f [libc++] [C++2b] [P1048] Add is_scoped_enum and is_scoped_enum_v.
* https://wg21.link/p1048

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D94409
2021-01-12 17:08:20 +01:00
Marek Kurdej 30a7d430e8 [libc++] Turn off auto-formatting of generated files. NFC.
This adds `// clang-format off` in the auto-generated file to avoid lint warnings.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D94410
2021-01-11 20:49:26 +01:00
Louis Dionne d86e16e4bd [libc++] NFC: Document the Differential queries to avoid duplicating work
Differential Revision: https://reviews.llvm.org/D94343
2021-01-08 17:47:39 -05:00
Arthur O'Dwyer cdd7cbf7b5 [libc++] Mark [P0809] "LWG2831: Comparing Unordered Containers" as Nothing To Do.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0809r0.pdf

This issue/paper simply removed some library UB because vendors were
already doing the right thing. libc++ has always done the right thing
(in this respect).

Differential Revision: https://reviews.llvm.org/D93816
2021-01-08 17:33:22 -05:00
Arthur O'Dwyer 963b771e24 [libc++] Mark [P0475] "LWG2511: guaranteed copy elision for piecewise construction" as Complete.
The point of LWG2511 is basically just to make sure that we use
`tuple<Args&&...>` instead of `tuple<Args...>` in a couple of places
inside `scoped_allocator_adaptor` and inside `pair`.
As far as I can tell, this has been true for libc++
since EricWF's D27612 (and maybe even earlier than that).
2021-01-08 17:33:13 -05:00
Arthur O'Dwyer ca1694b9d0 Re-enable __cpp_lib_constexpr_functional.
I accidentally disabled this feature-test macro in my D93830,
due to a rebasing conflict. It had been enabled by my D93815,
and should have remained enabled.
2021-01-08 17:30:04 -05:00
Louis Dionne bc556e5685 [libc++/abi] Re-remove unnecessary null pointer checks from operator delete
In 7cd67904f7, we removed the unnecessary nullptr checks from the libc++abi
definition of operator delete, but we forgot to update the definition in
libc++ (damn code duplication!). Then, in d4a1e03c5f, I synced the
definitions across libc++ and libc++abi, but I did it the wrong way around.
I re-added the if() checks to libc++abi instead of removing them from libc++.

In ef74f0fdc3, we re-removed the if() check from operator delete, but
only in libc++abi. This patch corrects this mess and removes it
consistently in libc++ and libc++abi.

Differential Revision: https://reviews.llvm.org/D93473
2021-01-08 17:03:50 -05:00
Louis Dionne 955dd7b7f3 [libc++] LWG2070: Use Allocator construction for objects created with allocate_shared
This patch updates `allocate_shared` to call `allocator_traits::construct`
when creating the object held inside the shared_pointer, and
`allocator_traits::destroy` when destroying it. This resolves
the part of P0674R1 that was originally filed as LWG2070.

This change is landed separately from the rest of P0674R1 because it is
incredibly tricky from an ABI perspective.

This is the reason why this change is so tricky is that we previously
used EBO in a compressed pair to store both the allocator and the object
type stored in the `shared_ptr`. However, starting in C++20, P0674
requires us to use Allocator construction for initializing the object type.
That requirement rules out the use of the EBO for the object type, since
using the EBO implies that the base will be initialized when the control
block is initialized (and hence we can't do it through Allocator construction).
Hence, supporting P0674 requires changing how we store the object type
inside the control block, which we do while being ABI compatible by using
some trickery with a properly aligned char buffer.

Fixes https://llvm.org/PR41900
Supersedes https://llvm.org/D62760

Differential Revision: https://reviews.llvm.org/D91201
2021-01-08 13:04:03 -05:00
Marek Kurdej 95729f95d8 [libc++] Add basic support for -std=c++2b.
* Add feature test macros.
* Add buildbot configuration generic-cxx2b that uses clang-tot.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D94227
2021-01-08 19:02:41 +01:00
Arthur O'Dwyer 466df1718e [libc++] Update generate_feature_test_macro_components.py to match SD-6.
It's still a little confusing because in many cases C++17 and C++20
have different values, and libc++ implements the C++17 behavior but
not the C++20 behavior; 'unimplemented' can't represent that scenario.
Ultimately we probably ought to completely redesign the script to be
in terms of paper numbers, rather than language revisions, and make
it generate the CSV files like "Cxx2aStatusPaperStatus.csv" as well.

Most newly added macros are unimplemented. I've marked a few as implemented,
though, based on my reading of the code; for example I was pretty sure
`__cpp_lib_latch` is implemented since we have `<latch>`.

Differential Revision: https://reviews.llvm.org/D93830
2021-01-08 11:44:39 -05:00
Alex Richardson 32733c347d [libc++] Add missing XFAIL to tests that need __atomic_* libcalls
FreeBSD did not provide the __atomic_* functions as part of the base
system until recently. They were added to libgcc_s in SVN revision r364753
(August 2020), so check for availability of 'non-lockfree-atomics' so that
these tests do not fail unexpectedly on older versions of FreeBSD.

This also removes the #ifndef __APPLE__ from atomic_helpers.h that was used
to work around lack of atomic runtime functions on older Apple platforms
and replaces it with XFAIL: !non-lockfree-atomics.

Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D88818
2021-01-08 12:48:22 +00:00
Arthur O'Dwyer ff1b6f9ff2 [libc++] Alphabetize generate_feature_test_macro_components.py. NFCI.
For ease of comparing our list with the official SD-6 list, which is alphabetized.
https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#library-feature-test-macros
This also alphabetizes the lists of headers in which the macros are
defined, which harmlessly alters many comments in <version>.
Also drive-by-fix some trivial flake8 warnings.
2021-01-07 18:11:46 -05:00
Louis Dionne c01202a7ef [libc++] Fix typo in run-buildbot
The installation directory was never meant to contain a brace.
2021-01-07 17:37:09 -05:00
Marek Kurdej 044b892c79 [libc++] Use c++20 instead of c++2a consistently.
* The only exception is that the flag -std=c++2a is still used not to break compatibility with older compilers (clang <= 9, gcc <= 9).
* Bump _LIBCPP_STD_VER for C++20 to 20 and use 21 for the future standard (C++2b).

That's a preparation step to add c++2b support to libc++.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93383
2021-01-07 13:11:33 +01:00
Mikhail Maltsev 7da3e3a898 [libcxx] Mark a test as unsupported for C++03
The nullptr_t_integral_cast.pass.cpp test is currently xfailed for
C++03, but actually, it only fails with the first version of libc++
ABI.

This patch changes XFAIL to UNSUPPORTED to avoid unexpected passes
with ABI v2 or later.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93941
2021-01-07 12:06:08 +00:00
Marek Kurdej b6fb0209b6 [libc++] [CI] Install Tip-of-Trunk clang.
* Check created symlinks.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93520
2021-01-07 12:04:09 +01:00
Martin Storsjö f4485240a2 [libcxx] Handle backslash as path separator on windows
Differential Revision: https://reviews.llvm.org/D91138
2021-01-07 10:02:47 +02:00
Arthur O'Dwyer 781c476ce0 [libc++] ADL-proof vector<bool> by adding _VSTD:: qualification on calls.
This affects only vectors with weird/malicious allocators,
the same corner case covered in D91708, but for `vector<bool>` this time.

Also ADL-proof <__tree>, which affects only sets and maps with weird/malicious
allocators where the ADL trap is in the *fancy pointer type*.

Also drive-by _VSTD:: qualification in the guts of std::bind,
std::packaged_task, std::condition_variable.

Differential Revision: https://reviews.llvm.org/D93424
2021-01-06 18:23:50 -05:00
Marek Kurdej 3f0b637d6b [libc++] [docs] Mark contract-related papers as removed from C++20. 2020-12-30 14:24:26 +01:00
Arthur O'Dwyer c0a2d3b90b [libc++] Fix a test failure in 7b00e9fae3 (D93815).
"LLVM Buildbot on libcxx-libcxxabi-libunwind-armv7-linux" is not happy
with comparing `unsigned` and `int` [-Werror,-Wsign-compare].
2020-12-28 18:46:07 -05:00
Arthur O'Dwyer dd756e3e84 [libc++] Fix a test failure in 7b00e9fae3 (D93815).
"LLVM Buildbot on libcxx-libcxxabi-x86_64-linux-debian" is not happy
with default-initializing the `double` member of `A` in a constexpr
function. At least I'm pretty sure that's what it's complaining about.
2020-12-28 13:55:40 -05:00
Arthur O'Dwyer 7b00e9fae3 [libc++] [P1065] Constexpr invoke, reference_wrapper, mem_fn, not_fn, default_searcher.
This completes the implementation of P1065 "constexpr INVOKE":
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1065r2.html

This doesn't yet complete the implementation of P1032 "Misc constexpr bits,"
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1032r1.html
but it does complete all of the <functional> bits, which means
that we can now set `__cpp_lib_constexpr_functional` for C++20.

This could use more constexpr tests for `std::reference_wrapper<T>`,
but the existing tests are extremely non-constexpr-friendly and
so I don't want to get into that rabbit-hole today.

Differential Revision: https://reviews.llvm.org/D93815
2020-12-28 13:24:07 -05:00
Arthur O'Dwyer 30f589c912 [libc++] Constexpr-proof some machinery in not_fn.pass.cpp. NFCI.
We don't need to use global variables here; we can store the "State"
of this machinery on the stack, so that it's constexpr-friendly.
2020-12-28 13:24:07 -05:00
Alex Richardson 0f81598cc1 [libc++] Add a 'is-lockfree-runtime-function' lit feature
On macOS 10.14 /usr/lib/system/libcompiler_rt.dylib contains all the
`__atomic_load*`, etc. functions but does not include the `__atomic_is_lock_free`
function. The lack of this function causes the non-lockfree-atomics feature
to be set to false even though large atomic operations are actually
supported, it's just the is_lock_free() function that is missing.

This is required so that the !non-lockfree-atomics feature can be used
to XFAIL tests that require runtime library support (D88818).

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D91911
2020-12-22 11:56:20 +00:00
Mark de Wever 5740f96d8e [NFC][libc++] Fixes swapped comments. 2020-12-19 16:16:54 +01:00
Martin Storsjö 156180727d [libcxx] Fix the preexisting directory_iterator code for windows
The directory_iterator.cpp file did contain an incomplete,
non-working implementation for windows.

Change it to use the wchar version of the APIs.

Don't set the windows specific errors from GetLastError() as code
in the generic category; remap the errors to the std::errc values.

Error out cleanly on empty paths.

Invoke FindFirstFile on <directoryname>/* to actually list the
entries of the directory.

If the first entry retured by FindFirstFile is to be skipped (e.g.
being "." or ".."), call advance() (which calls FindNextFile and loops)
which doesn't return until a valid entry is found (or the end is
reached).

Differential Revision: https://reviews.llvm.org/D91140
2020-12-18 11:24:53 +02:00
Martin Storsjö de698ae734 [libcxx] Convert paths to/from the right narrow code page for narrow strings on windows
On windows, the narrow, char based paths normally don't use utf8, but
can use many different native code pages, and this is what system
functions that operate on files, taking such paths/file names, interpret
them as.

Differential Revision: https://reviews.llvm.org/D91137
2020-12-18 11:24:52 +02:00
Martin Storsjö 48c6500b5b [libcxx] Reorder the two u8path functions, to make the following diff more readable. NFC.
Differential Revision: https://reviews.llvm.org/D91136
2020-12-18 11:24:52 +02:00
Martin Storsjö e83e0cac04 [libcxx] Make filesystem::path::value_type wchar_t on windows
Also set the preferred separator to backslash.

libc++ doesn't compile successfully for windows prior to this change,
and this change on its own isn't enough to make it compile successfully
either, but is the first stepping stone towards making it work correctly.

Most of operations.cpp will need to be touched, both for calling
functions that take wchar paths, but also for using other windows
specific functions instead of the posix functions used so far; that is
handled in later commits.

Changing parts of operations.cpp to generalize the string type handling
in code that doesn't touch system functions.

Differential Revision: https://reviews.llvm.org/D91135
2020-12-18 11:24:52 +02:00
Azat Khuzhin 6340f890bb [libc++] Fix extern C for __sanitizer_annotate_contiguous_container() (for gcc)
gcc supports it only at the beginning:

    $ g++ -o /dev/null -c /tmp/test_extern.cpp
    $ cat /tmp/test_extern.cpp
    extern "C" __attribute__ ((__visibility__("default"))) int foo();

Otherwise:

    $ g++ -o /dev/null -c /tmp/test_extern.cpp
    /tmp/test_extern.cpp:1:52: error: expected unqualified-id before string constant
        1 | __attribute__ ((__visibility__("default"))) extern "C" int foo();
          |                                                    ^~~
    $ cat /tmp/test_extern.cpp
    __attribute__ ((__visibility__("default"))) extern "C" int foo();

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D93316
2020-12-17 16:20:24 -05:00
Martin Storsjö 08a00c6f43 [libcxx] Remove ifdefs in the message to static_assert. NFC.
Differential Revision: https://reviews.llvm.org/D93283
2020-12-17 13:37:52 +02:00
Louis Dionne 46ae360452 [libc++] Fix CI Dockerfile
Installing clang-format-11 doesn't seem to work if it's done before
we've installed LLVM. I must admit I didn't try to get to the bottom
of the issue, since installing it after seems to work.
2020-12-16 17:01:21 -05:00
Marek Kurdej d69fc6629d [libc++] Install git-clang-format on CI nodes.
Two problems fixed:
* an old version of clang-format get installed by default (6.0).
* git-clang-format is not present, only git-clang-format-<version> (e.g. git-clang-format-6.0).

Solution:
* install clang-format-11 with explicit version
* make symlink git-clang-format to the latest version of git-clang-format-<version>

Differential Revision: https://reviews.llvm.org/D93201
2020-12-16 16:36:34 -05:00
Louis Dionne f2966d17a2 [libc++] Use consistent declaration for main() in test 2020-12-15 17:34:06 -05:00
Marek Kurdej d1da346296 [libc++] Fix synopsis in string::ends_with test. NFC. 2020-12-15 19:03:11 +01:00
Louis Dionne a00290ed10 [libc++] Fix allocate_shared when used with an explicitly convertible allocator
When the allocator is only explicitly convertible from other specializations
of itself, the new version of std::allocate_shared would not work because
it would try to do an implicit conversion. This patch fixes the problem
and adds a test so that we don't fall into the same trap in the future.
2020-12-15 11:50:06 -05:00
Louis Dionne b3d1d1f4ff [libc++] Remove unnecessary static assertion in allocate_shared
Checking that `T` is constructible from `Args...` is technically not
required by the Standard, although any implementation will obviously
error out if that's not satisfied. However, this check is incompatible
with using Allocator construction in the control block (upcoming change
as part of implementing P0674), so I'm removing it now to reduce the
upcoming diff as much as possible.

Differential Revision: https://reviews.llvm.org/D93246
2020-12-14 17:47:43 -05:00
Louis Dionne 3b7280f5e4 [libc++] NFCI: Return pointer instead of reference from __shared_ptr_emplace helper method
This makes __get_alloc consistent with __get_elem, and will reduce the
diff required to implement P0674R1.
2020-12-14 17:46:09 -05:00
Louis Dionne 19d57b5c42 [libc++] Refactor allocate_shared to use an allocation guard
This commit is a step towards making it easier to add support for arrays
in allocate_shared. Adding support for arrays will require writing multiple
functions, and the current complexity of writing allocate_shared is
prohibitive for understanding.

Differential Revision: https://reviews.llvm.org/D93130
2020-12-14 17:10:05 -05:00
Louis Dionne 7ad49aec12 [libc++] Split allocator_traits and pointer_traits out of <memory>
In addition to making the code a lot easier to grasp by localizing many
helper functions to the only file where they are actually needed, this
will allow creating helper functions that depend on allocator_traits
outside of <memory>.

This is done as part of implementing array support in allocate_shared,
which requires non-trivial array initialization algorithms that would be
better to keep out of <memory> for sanity. It's also a first step towards
splitting up our monolithic headers into finer grained ones, which will
make it easier to reuse functionality across the library. For example,
it's just weird that we had to define `addressof` inside <type_traits>
to avoid circular dependencies -- instead it's better to implement those
in true helper headers.

Differential Revision: https://reviews.llvm.org/D93074
2020-12-14 16:13:57 -05:00
Arthur O'Dwyer 3c8e31e17b [libc++] ADL-proof <functional> by adding _VSTD:: qualification on calls.
- std::reference_wrapper
- std::function
- std::mem_fn

While I'm here, remove _VSTD:: qualification from calls to `declval`
because it takes no arguments and thus isn't susceptible to ADL.

Differential Revision: https://reviews.llvm.org/D92884
2020-12-14 12:08:34 -05:00
Arthur O'Dwyer be4c657b01 [libc++] Consistently replace `::new(__p) T` with `::new ((void*)__p) T`. NFCI.
Everywhere, normalize the whitespace to `::new (EXPR) T`.
Everywhere, normalize the spelling of the cast to `(void*)EXPR`.

Without the cast to `(void*)`, the expression triggers ADL on GCC.
(I think this is a GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98249)
Even if it doesn't trigger ADL, it still seems incorrect to use any argument
that's not exactly `(void*)` because that opens the possibility of overload
resolution picking a user-defined overload of `operator new`, which would be
wrong.

Differential Revision: https://reviews.llvm.org/D93153
2020-12-14 12:08:34 -05:00
Marek Kurdej 59c72a7012 [libc++] [P1164] Add tests for create_directories. NFC.
That's a follow-up patch after D92769.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93026
2020-12-14 17:27:18 +01:00
Arthur O'Dwyer 2664f5d436 generate_header_tests.py: Sort the header files ASCIIbetically.
Otherwise they come out in random (inode?) order.

Also `chmod +x` the generator, and re-run it. Somehow on Marek's
machine it produced \r\n line endings?! Open all files with
`newline='\n'` so that (if the Python3 docs are correct)
that won't happen again.

Differential Revision: https://reviews.llvm.org/D93137
2020-12-14 09:56:07 -05:00
Arthur O'Dwyer b6f1917415 [libc++] Fix some one-off typos in comments. NFCI. 2020-12-14 09:54:58 -05:00
Arthur O'Dwyer ce9ac549c9 [libc++] Remove __is_construct::__nat. NFCI.
This type has been unused since commit 5b4cc84b87.
2020-12-14 09:54:58 -05:00
Arthur O'Dwyer e9eb99999f [libc++] s/insertible/insertable/g. NFCI. 2020-12-14 09:54:58 -05:00
Arthur O'Dwyer 1d7c39e14e [libc++] s/Birdirectional/Bidirectional/g. NFCI. 2020-12-14 09:54:57 -05:00
Richard Smith 7de9c61f31 Fix test expectation to cope with custom version namespaces. 2020-12-13 22:43:24 -08:00
Louis Dionne d02eac0c00 [libc++] Fix Docker image build after installing clang-format 2020-12-11 14:13:13 -05:00
Louis Dionne 202df6870e [libc++] Install clang-format on CI nodes 2020-12-11 14:06:42 -05:00
Louis Dionne f75bf712de [libc++] Use TARGET_FILE instead of TARGET_SONAME_FILE when generating ABI lists
TARGET_SONAME_FILE isn't valid on Windows, and TARGET_FILE should achieve
the same results.

Differential Revision: https://reviews.llvm.org/D92856
2020-12-11 12:12:40 -05:00
Louis Dionne ece3e5bb8b [libc++] NFCI: Implement make_shared as allocate_shared with std::allocator
This simplifies the implementation, and it appears to be equivalent since
make_shared was allocating memory with std::allocator anyway.

Differential Revision: https://reviews.llvm.org/D93071
2020-12-11 12:01:48 -05:00
Marek Kurdej da97d12cc0 [libc++] Remove invalid use of `#if _LIBCPP_STD_VER >= 11`, as `_LIBCPP_STD_VER` can never be less than 11.
The relevant part of `__config` is:
```
#ifndef _LIBCPP_STD_VER
#  if  __cplusplus <= 201103L
#    define _LIBCPP_STD_VER 11
```

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93025
2020-12-11 08:31:59 +01:00
Arthur O'Dwyer 3696227c10 [libc++] ADL-proof by adding _VSTD:: qualifications to memmove etc.
Generally these calls aren't vulnerable to ADL because they involve only
primitive types. The ones in <list> and <vector> drag in namespace std
but that's OK; the ones in <fstream> and <strstream> are vulnerable
iff `CharT` is an enum type, which seems far-fetched.
But absolutely zero of them *need* ADL to happen; so in my opinion
they should all be consistently qualified, just like calls to any
other (non-user-customizable) functions in namespace std.

Also: Include <cstring> and <cwchar> in <__string>.
We seemed to be getting lucky that <memory> included <iterator>
included <iosfwd> included <wchar.h>. That gave us the
global-namespace `wmemmove`, but not `_VSTD::wmemmove`.
This is now fixed.

I didn't touch these headers:
<ext/__hash> uses strlen, safely
<support/ibm/locale_mgmt_aix.h> uses memcpy, safely
<string.h> uses memchr and strchr, safely
<wchar.h> uses wcschr, safely
<__bsd_locale_fallbacks.h> uses wcsnrtombs, safely

Differential Revision: https://reviews.llvm.org/D93061
2020-12-10 22:03:12 -05:00
Arthur O'Dwyer b12ea06521 [libc++] Include C++ headers, not C headers, in <charconv>.
This matches how libc++ does it in all other C++ headers
(that is, headers not ending in ".h").
We need to include <cstring> if we want to use `_VSTD::memmove`
instead of unqualified ADL `memmove`. Even though ADL doesn't
physically matter in <charconv>'s specific case, I'm trying
to migrate libc++ to using `_VSTD::memmove` for all cases
(because some of them do matter, and this way it's easier to
grep for outliers).

Differential Revision: https://reviews.llvm.org/D92875
2020-12-10 22:03:12 -05:00
Louis Dionne 092e8a7ea3 [libc++] NFCI: Refactor __shared_ptr_emplace
This is the first of a series of patches leading up to the implementation
of P0674r1, i.e. array support in allocate_shared. I am splitting this
up into multiple patches because the overall change is very tricky and
I want to isolate potential breakage.
2020-12-10 16:45:58 -05:00
Marek Kurdej e4ed349c76 [libc++] [P1164] [C++20] Make fs::create_directory() error if there is already a non-directory.
Also mark LWG2935 and LWG3079 as complete.

Applied retroactively to previous standards too, as it's a DR.

* https://wg21.link/P1164
* https://wg21.link/lwg2935
* https://wg21.link/lwg3079

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92769
2020-12-10 08:40:27 +01:00
Marek Kurdej 6fd5a94eeb [libc++] Add a script to automatize updating test for a new header.
Idea from D92525.
This script globs include/ directory and updates the tests in test/libcxx.
This patch does not generate module.modulemap nor CMakeLists.txt.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92656
2020-12-10 08:37:50 +01:00
Richard Smith 2a2c228c7a Add new 'preferred_name' attribute.
This attribute permits a typedef to be associated with a class template
specialization as a preferred way of naming that class template
specialization. This permits us to specify that (for example) the
preferred way to express 'std::basic_string<char>' is as 'std::string'.

The attribute is applied to the various class templates in libc++ that have
corresponding well-known typedef names.

This is a re-commit. The previous commit was reverted because it exposed
a pre-existing bug that has since been fixed / worked around; see
PR48434.

Differential Revision: https://reviews.llvm.org/D91311
2020-12-09 12:22:35 -08:00