Commit Graph

6975 Commits

Author SHA1 Message Date
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
Louis Dionne 717b0da7a6 [libc++] Run back-deployment CI on macOS 10.15 instead of 10.14
The goal was to add coverage for back-deployment over the filesystem
library, but it was added in macOS 10.15, not 10.14.

Differential Revision: https://reviews.llvm.org/D92937
2020-12-09 11:35:15 -05:00
Arthur O'Dwyer 2130699ba4 [libc++] Mark my new <algorithm> test unsupported on clang-8.
Because in C++20 mode, it tests that `copy_n` is constexpr;
so it depends on the compiler supporting `is_constant_evaluated`.
2020-12-08 17:25:23 -05:00
Arthur O'Dwyer 1968804ac7 [libc++] Add _VSTD:: qualifications to ADL-proof <algorithm>.
Relevant blog post: https://quuxplusone.github.io/blog/2019/09/26/uglification-doesnt-stop-adl/

Differential Revision: https://reviews.llvm.org/D92776
2020-12-08 17:05:38 -05:00
Arthur O'Dwyer 35c3b53943 [libc++] ADL-proof __libcpp_is_nothrow_constructible.
The GCC C++20 buildbot hit this ADL call; Clang doesn't,
presumably because it uses a compiler builtin instead of
this codepath in <type_traits>.
https://buildkite.com/llvm-project/libcxx-ci/builds/674
2020-12-08 17:05:38 -05:00
Louis Dionne a65dc08d10 [libc++] Implement missing feature-test macro __cpp_lib_shared_ptr_arrays
This was forgotten when we implemented support for arrays in std::shared_ptr
in https://reviews.llvm.org/D62259.
2020-12-08 15:46:45 -05:00
Louis Dionne 3e46b3a188 [libc++] NFC: Indent feature-test macro script consistently 2020-12-08 15:42:57 -05:00
Yuriy Chernyshov b526d87618 [libc++] Add std::hash<char8_t> specialization if char8_t is enabled
Differential Revision: https://reviews.llvm.org/D92325
2020-12-08 13:46:18 -05:00
Marek Kurdej 877170f3eb [libc++] [LWG3221] Add tests for wrapping operator+(year_month, months).
The behaviour didn't change since commit 5b08c1742a (Recommit <chrono> changes with a couple xtra tests marked to fail on apple's clang.)

* http://wg21.link/lwg3221

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92730
2020-12-08 18:08:04 +01:00
Arthur O'Dwyer c0428b3c0c [libc++] ADL-proof <iterator>. `__convert_to_integral` is not a customization point.
The interesting change here is that we no longer consider `__convert_to_integral`
an ADL customization point for the user's types. I think the new behavior
is defensible. The old behavior had come from D7449, where Marshall explicitly
said "people can't define their own [`__convert_to_integral` overloads]."

Differential Revision: https://reviews.llvm.org/D92814
2020-12-08 11:19:16 -05:00
Louis Dionne 8726f94cc7 [libc++] Add a CI job to backdeploy to macOS 10.14
It adds coverage for back-deploying to a system that contains the
filesystem library, which 10.9 (currently our only back-deployment
target in the CI) does not have.

Differential Revision: https://reviews.llvm.org/D92794
2020-12-08 11:07:56 -05:00
Richard Smith a1344779ab Revert "Add new 'preferred_name' attribute."
This change exposed a pre-existing issue with deserialization cycles
caused by a combination of attributes and template instantiations
violating the deserialization ordering restrictions; see PR48434 for
details.

A previous commit attempted to work around PR48434, but appears to have
only been a partial fix, and fixing this properly seems non-trivial.
Backing out for now to unblock things.

This reverts commit 98f76adf4e and
commit a64c26a47a.
2020-12-08 00:42:48 -08:00
Marek Kurdej ba3adfad6e [libc++] Mark LWG3200 as Nothing To Do. NFC.
This is only a wording change, because it is currently impossible to constrain the overload set on whether the type is complete or not.
2020-12-08 09:00:45 +01:00
Richard Smith 98f76adf4e 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.

Differential Revision: https://reviews.llvm.org/D91311
2020-12-07 12:53:07 -08:00
Marek Kurdej bf8683adfa [libc++] [docs] Mark LWG3055 as complete. Use string_view instead of string in path::operator+=(ECharT).
The issue didn't change the behaviour which is tested in libcxx/test/std/input.output/filesystems/class.path/path.member/path.concat.pass.cpp.

The change to use string_view instead of string is not strictly necessary.

<filesystem> was added in commit 998a5c8831 (Implement <filesystem>).

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D92731
2020-12-07 20:18:09 +01:00
Marek Kurdej e2279c2350 [libc++] [docs] Mark P1865 as complete since 11.0 as it was implemented together with P1135. Fix synopses in <barrier> and <latch>.
It was implemented in commit 54fa9ecd30 ([libc++] Implementation of C++20's P1135R6 for libcxx).
2020-12-06 15:36:52 +01:00
Marek Kurdej f6326736ba [libc++] [LWG3374] Mark `to_address(const Ptr& p)` overload `constexpr`.
Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92659
2020-12-06 15:26:26 +01:00
Zbigniew Sarbinowski e6c89a499d [SystemZ][ZOS] Fix the usage of pthread_t within libc++
This is the the minimal change introduced in [[ https://reviews.llvm.org/D88599 | D88599 ]]  to unblock the controversial change and discussion of proper separation between thread from thread id which will continue in D88599.

This patch will address the differences of definition of pthread_t on z/OS vs. Linux and other OS. Main trick to make the code work on z/OS relies on redefining libcpp_thread_id type and _LIBCPP_NULL_THREAD macro. This is necessary to separate initialization of libcxx_thread_id from the one of __libcxx_thread_t;

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D91875
2020-12-05 17:46:30 +00:00
Mark de Wever ce6269f9ba [NFC][libc++] Update C++20 issues status.
Properly mark LWG1203 as completed and move the version number to the
version column.
2020-12-05 16:36:19 +01:00
Arthur O'Dwyer b8bc4e153f [libc++] Update the commented "synopsis" in <algorithm> to match current reality.
The synopsis now reflects what's implemented. It does NOT reflect
all of what's specified in C++20. The "constexpr in C++20" markings
are still missing from these 12 algorithms, because they are still
unimplemented by libc++:

    reverse partition sort nth_element next_permutation prev_permutation
    push_heap pop_heap make_heap sort_heap partial_sort partial_sort_copy

All of the above algorithms were excluded from [P0202].

All of the above algorithms were made constexpr in [P0879] (along with
swap_ranges, iter_swap, and rotate — we've already implemented those three).

Differential Revision: https://reviews.llvm.org/D92255
2020-12-04 17:53:54 -05:00
Arthur O'Dwyer 14098cf6c0 [libc++] [P0202] constexpr set_union, set_difference, set_symmetric_difference, merge
These had been waiting on the ability to use `std::copy` from
constexpr code (which in turn had been waiting on the ability to
use `is_constant_evaluated()` to switch between `memmove` and non-`memmove`
implementations of `std::copy`). That work landed a while ago,
so these algorithms can all be constexpr in C++20 now.

Simultaneously, update the tests for the set algorithms.

- Use an element type with "equivalent but not identical" values.
- The custom-comparator tests now pass something different from `operator<`.
- Make the constexpr coverage match the non-constexpr coverage.

Differential Revision: https://reviews.llvm.org/D92255
2020-12-04 17:53:54 -05:00
Arthur O'Dwyer c75c6549ba [libc++] Slightly improve constexpr test coverage for std::includes.
Differential Revision: https://reviews.llvm.org/D92255
2020-12-04 17:53:53 -05:00
Brett Gutstein 297c839e2d [libc++] fix std::sort(T**, T**)
previously, invocations of std::sort(T**, T**) casted the arguments to
(size_t *). this breaks sorting on systems for which pointers don't fit
in a size_t. change the cast to (uintptr_t *) and add a test.

Differential Revision: https://reviews.llvm.org/D92190
2020-12-04 16:05:21 -05:00
Marek Kurdej 5ad6ed5298 [libc++] [test] Disable parts of path.factory.pass.cpp as requiring localization enabled.
It was added in commit 6be11e35d5, "[libcxx] Implement c++2a char8_t input/output of std::filesystem::path".
2020-12-04 20:04:35 +01:00
Marek Kurdej b04a5e752f [libc++] [test] Mark path.charconv.pass.cpp as requiring localization enabled.
It was added in commit 0b71bf7939, "[libcxx] [test] Add a test for conversions between wchar_t, utf8, char16_t, char32_t and windows native narrow code pages"
2020-12-04 19:58:48 +01:00
Marek Kurdej c36801ecd5 [libc++] [docs] Add Version column to issues tables on status pages. 2020-12-04 18:44:35 +01:00
Martin Storsjö 0b71bf7939 [libcxx] [test] Add a test for conversions between wchar_t, utf8, char16_t, char32_t and windows native narrow code pages
Differential Revision: https://reviews.llvm.org/D91133
2020-12-04 11:37:05 +02:00
Martin Storsjö 6be11e35d5 [libcxx] Implement c++2a char8_t input/output of std::filesystem::path
This implements the std::filesystem parts of P0482 (which is already
marked as in progress), and applies the actions that are suggested
in P1423.

Differential Revision: https://reviews.llvm.org/D90222
2020-12-04 11:37:05 +02:00
Arthur O'Dwyer d430330788 [libc++] Update and normalize the "all the headers" tests.
Some C++20 headers weren't added properly to all three of these
test files. Add them, and take the time to normalize the formatting
so that

    diff <(grep '#include' foo.cpp) <(grep '#include' bar.cpp)

shows no diffs (except that `no_assert_include` deliberately
excludes `<cassert>`).

- Add macro guards to <{barrier,latch,semaphore}>.
- Add macro guards to <experimental/simd>.
- Remove an include of <cassert> from <semaphore>.
- Instead, include <cassert> in the semaphore tests.

Differential Revision: https://reviews.llvm.org/D92525
2020-12-03 15:01:38 -05:00
Marek Kurdej 590bbfe0d8 [libc++] [docs] Add C++2b (to be C++23) status page.
Also:
* Fix header line in all status tables.
* Use C++20 instead of C++2a.

Reviewed By: ldionne, #libc, miscco

Differential Revision: https://reviews.llvm.org/D92306
2020-12-03 09:22:06 +01:00
Louis Dionne 4277adda1d [libc++] Install missing packages to cross-compile to 32 bits during CI 2020-12-02 16:45:53 -05:00
zoecarver 644f68ed4d [libc++] Add slice_array operator= valarray overload.
Add the slice_array::operator=(const std::valarray<T>& val_arr) overload.

Fixes https://llvm.org/PR40792.

Differential Revision: https://reviews.llvm.org/D58735
2020-12-02 10:49:20 -08:00
Marek Kurdej 28797e9952 [libc++] [docs] Mark LWG2296 as complete not only on clang.
std::addressof was made constexpr in gcc 7.
libc++ fixed it in ac473034fc (Provide a constexpr addressof with GCC 7.)
2020-12-02 11:39:43 +01:00
Marek Kurdej d82fb6022b [libc++] [docs] Mark P1424 as superseded by P1902. 2020-12-02 11:19:37 +01:00
Marek Kurdej a984dcaf7c [libc++] [P0482] [C++20] Implement missing bits for codecvt and codecvt_byname.
Add codecvt*<char16_t, char8_t> and codecvt*<char32_t, char8_t>.
Deprecate codecvt<char(16|32)_t, char>.
Enable disabled tests.
Update _LIBCPP_STD_VER to use 20 for C++20. Add _LIBCPP_DEPRECATED_IN_CXX20 macro.

Reviewed By: ldionne, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D91517
2020-12-02 09:01:58 +01:00
Martin Storsjö 0d7bd72f5a [libcxx] Apply msvcrt specific exception for lgamma() to mingw configurations, too
This fixes linking code that uses some bits of the <random> header
on mingw targets.

Differential Revision: https://reviews.llvm.org/D92379
2020-12-02 09:55:16 +02:00
Marek Kurdej 1c656e9b64 [libc++] [docs] Update and move NOTES.txt to docs/Contributing.rst.
Also, add notes about exporting ABI symbols.
Later, we can add notes about using git-clang-format before sending a patch for review.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92300
2020-12-02 08:54:11 +01:00
Arthur O'Dwyer e181a6aedd s/instantate/instantiate/ throughout. NFCI.
The static_assert in "libcxx/include/memory" was the main offender here,
but then I figured I might as well `git grep -i instantat` and fix all
the instances I found. One was in user-facing HTML documentation;
the rest were in comments or tests.
2020-12-01 22:13:40 -05:00
Arthur O'Dwyer d586f92c94 [libc++] Consistently replace `std::` qualification with `_VSTD::` or nothing. NFCI.
I used a lot of `git grep` to find places where `std::` was being used
outside of comments and assert-messages. There were three outcomes:

- Qualified function calls, e.g. `std::move` becomes `_VSTD::move`.
    This is the most common case.

- Typenames that don't need qualification, e.g. `std::allocator` becomes `allocator`.
    Leaving these as `_VSTD::allocator` would also be fine, but I decided
    that removing the qualification is more consistent with existing practice.

- Names that specifically need un-versioned `std::` qualification,
    or that I wasn't sure about. For example, I didn't touch any code in
    <atomic>, <math.h>, <new>, or any ext/ or experimental/ headers;
    and I didn't touch any instances of `std::type_info`.

In some deduction guides, we were accidentally using `class Alloc = typename std::allocator<T>`,
despite `std::allocator<T>`'s type-ness not being template-dependent.
Because `std::allocator` is a qualified name, this did parse as we intended;
but what we meant was simply `class Alloc = allocator<T>`.

Differential Revision: https://reviews.llvm.org/D92250
2020-12-01 22:13:39 -05:00