10392 Commits

Author SHA1 Message Date
Mark de Wever
5db033e204 [libc++][format] Improves fill character.
The main change is to allow a UCS scalar value as fill character.
Especially for char based formatting this increase the number of valid
characters. Originally this was to be expected ABI breaking, however the
current change does not seem to break the ABI.

Implements
- P2572 std::format() fill character allowances

Depends on D144499

Reviewed By: ldionne, tahonermann, #libc

Differential Revision: https://reviews.llvm.org/D144742
2023-05-19 17:20:50 +02:00
Hristo Hristov
cde9d41d87 [libc++][ranges][NFC] Added P2711R1 to release notes
This adds release notes for P2711R.
`join_with_view` is missing an implementation yet.

Implemented in: https://reviews.llvm.org/D144822

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D150845
2023-05-19 10:02:31 +03:00
Nikolas Klauser
80643d9366 [libc++][NFC] Rename iterator category checks to make it obvious that they check //only// the iterator category
We plan to add concepts for checking that iterators actually provide what they claim to. This is to avoid people thinking that these type traits actually check the iterator requirements in more detail.

Reviewed By: ldionne, #libc

Spies: Mordante, libcxx-commits, wenlei

Differential Revision: https://reviews.llvm.org/D150801
2023-05-18 15:37:28 -07:00
Louis Dionne
35f9fd6435 [libc++] Avoid dereferencing a const iterator in std::sort
This is a workaround to provide a grace period for folks that were
broken by D147089. As a fly-by, also apply comments by Mark I had
somehow missed in the review.

Differential Revision: https://reviews.llvm.org/D150779
2023-05-18 08:24:17 -07:00
yronglin
acce2a3159 [libc++] Implement P2505R5(Monadic operations for std::expected).
Implement P2505R5(https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2505r5.html)

Reviewed By: #libc, philnik, ldionne

Differential Revision: https://reviews.llvm.org/D140911
2023-05-18 01:05:25 +08:00
yronglin
5ae9098e5c Revert "[libc++] Implement P2505R5(Monadic operations for std::expected)."
This reverts commit ebc111b08bddca55d5f7e560a20bdb2c913d80cb.

Sorry, I forgot to append Phabricator reversion when land D140911, I try to revert this change and reland.

Reviewed By: #libc, ldionne, EricWF

Differential Revision: https://reviews.llvm.org/D150793
2023-05-18 00:55:47 +08:00
Louis Dionne
afbd36f153 [libc++][NFC] Rename the 'noexceptions' CI config to 'no-exceptions' for consistency
Differential Revision: https://reviews.llvm.org/D150672
2023-05-17 09:55:03 -07:00
Azat Khuzhin
53aed4759b [libcxx] Fix crash in std::stringstream with payload >= INT_MAX
stringstream does works for payload > INT_MAX, however
stringstream::gcount() can break the internal field (__nout_) and this
breaks the stringstream itself, and so the program will crash.

Fix this, by using __pbump(streamsize) over pbump(int)

Note, libstdc++ does not have this bug.

Reviewed By: #libc, ldionne, Mordante

Spies: arichardson, Mordante, philnik, ldionne, libcxx-commits, mikhail.ramalho

Differential Revision: https://reviews.llvm.org/D146294
2023-05-17 09:21:04 -07:00
zijunzhao
f9f1f9c2a5 [libc++] Improve ranges::starts_with
Fix some nits in ranges::starts_with
2023-05-17 16:14:15 +00:00
yronglin
ebc111b08b [libc++] Implement P2505R5(Monadic operations for std::expected).
Signed-off-by: yronglin <yronglin777@gmail.com>
2023-05-17 23:42:01 +08:00
Nico Weber
d763c6e5e2 Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""
This reverts commit 65429b9af6a2c99d340ab2dcddd41dab201f399c.

Broke several projects, see https://reviews.llvm.org/D144509#4347562 onwards.

Also reverts follow-up commit "[OpenMP] Compile assembly files as ASM, not C"

This reverts commit 4072c8aee4c89c4457f4f30d01dc9bb4dfa52559.

Also reverts fix attempt  "[cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump"

This reverts commit 7d47dac5f828efd1d378ba44a97559114f00fb64.
2023-05-17 10:53:33 -04:00
varconst
43377cc4a6 [libc++][ranges] Implement the changes to deque from P1206 (ranges::to):
- add the `from_range_t` constructors and the related deduction guides;
- add the `insert_range`/`assign_range`/etc. member functions.

(Note: this patch is split from https://reviews.llvm.org/D142335)

Differential Revision: https://reviews.llvm.org/D149827
2023-05-17 00:48:33 -07:00
Hui
544e38ca43 [libc++] Utilities for implementing stop_token
This change contains three util classes that were out from D145183 to make incremental progress
- automic_unique_lock
- intrusive_list
- intrusive_shared_ptr

Differential Revision: https://reviews.llvm.org/D150205
2023-05-17 07:21:40 +01:00
Christian Trott
fcaccf817d [libcxx] Add mdspan/extents
This patch adds std::extents. extents is one of the core classes used by std::mdspan. It describes a multi-dimensional index space with a mix of compile time and runtime sizes. Furthermore, it is templated on the index type used to describe the multi-dimensional index space.

The class is designed to be highly optimizable in performance critical code sections, and is fully useable in constant expressions contexts.

Testing of this class tends to be somewhat combinatorical, due to the large number of possible corner cases involved in situations where we have both runtime and compile time extents. To add to this, the class is designed to be interoperable (in particular constructible) from arguments which only need to be convertible to the index_type, but are otherwise arbitrary user types. For a larger discussion on the design of this class refer to: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p0009r18.html

Co-authored-by: Damien L-G <dalg24@gmail.com>

Reviewed By: ldionne, #libc

Spies: libcxx-commits, H-G-Hristov, tschuett, philnik, arichardson, Mordante, crtrott

Differential Revision: https://reviews.llvm.org/D148067
2023-05-16 14:30:36 -07:00
Piotr Fusik
49007a020c [libc++] Add C++20 stringstream::view()
Reviewed By: #libc, philnik, Mordante

Spies: Mordante, philnik, libcxx-commits

Differential Revision: https://reviews.llvm.org/D148641
2023-05-16 12:02:35 -07:00
Mark de Wever
dc95245e69 [libc++][format] Removes format sources.
The source file is used to anchor the destructor of format_error. When
format is moved from experimental to stable this code would move to the
dylib. One issue with code in the dylib is that it can't be used in
constexpr context. There is a proposal to make format work during
constant evaluation

  P2758 Emitting messages at compile time

This paper has initially been received favourable by EWG. Therefore move
the code to the header. This also avoids possible availability issues on
Mac back deployment targets.

Note it is expected that format will no longer be experimental with the
next LLVM release.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D150073
2023-05-16 20:31:44 +02:00
Martin Storsjö
391b51b18f [libcxx] [test] Improve error reporting around invoked commands
This was requested in the review of D145807, but I had missed to
apply it before landing the patch.

Differential Revision: https://reviews.llvm.org/D150444
2023-05-16 21:27:54 +03:00
Nikolas Klauser
7ace54e64b [libc++][PSTL] Implement std::copy{,_n}
Reviewed By: ldionne, #libc

Spies: jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D149706
2023-05-15 14:46:59 -07:00
Louis Dionne
fc748408c6 [libc++] Revert moving the pre-release checklist
I had not seen https://reviews.llvm.org/D150585 which supersedes
this, and I want to avoid merge conflicts for D150585.
2023-05-15 12:35:15 -07:00
Louis Dionne
5b28e4d791 [libc++][NFC] Reformat test
I didn't notice in the review that clang-format made a poor job at
formatting the test so I went back and did it manually.
2023-05-15 11:35:30 -07:00
Louis Dionne
79f852cc18 [libc++][NFC] Use angle brackets to include ranges_mismatch.h 2023-05-15 11:35:30 -07:00
Mark de Wever
91d7b96b77 [libc++] Removes _LIBCPP_ABI_OLD_LOGNORMAL_DISTRIBUTION
This was planned for LLVM 15 but was never done.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D150580
2023-05-15 20:27:45 +02:00
zijunzhao
205175578e [libc++] Implement ranges::starts_with 2023-05-15 18:15:38 +00:00
Nikolas Klauser
61d5671c16 Revert "[libc++][PSTL] Implement std::copy{,_n}"
This reverts commit b049fc0481bc387f57fd61da7239f85ef91096c1.

The wrong patch was landed.
2023-05-15 11:06:57 -07:00
Louis Dionne
eed718a3e2 [libc++][docs] Move the pre-release check-list
It was confusing to some contributors because it appeared in a
prominent place on the Contibuting page.
2023-05-15 10:34:55 -07:00
Nikolas Klauser
b049fc0481 [libc++][PSTL] Implement std::copy{,_n}
Reviewed By: ldionne, #libc

Spies: jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D149706
2023-05-15 10:31:57 -07:00
Nikolas Klauser
6851d078c5 [libc++][PSTL] Implement std::transform
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D149615
2023-05-15 09:57:20 -07:00
Nikolas Klauser
627e6efa5b Revert "[libc++][PSTL] Implement std::transform"
This reverts commit cbd9e5454741ebe6b39521fe1a8ed4eed5c2c801.

The wrong patch was landed.
2023-05-15 06:56:40 -07:00
Nikolas Klauser
cbd9e54547 [libc++][PSTL] Implement std::transform
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D149615
2023-05-15 06:48:43 -07:00
Mark de Wever
b7932803de [libc++] Moves unwrap_reference to type_traits.
This was discovered while working on modules.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D149351
2023-05-14 20:03:55 +02:00
Ian Anderson
f0917e9269 [libc++][PSTL] Make the PSTL submodules only have one header
Module map generation for the private detail headers is easier done if each private header is by itself in a submodule. Move the __algorithm/pstl_backends into their own submodules.

Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D150503
2023-05-13 23:02:40 -07:00
Nikolas Klauser
c04bcadf30 [libc++][NFC] Use _LIBCPP_STD_VER instead of __cpp_lib_atomic_is_always_lock_free
Reviewed By: #libc, ldionne, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D150421
2023-05-13 16:27:03 -07:00
Mark de Wever
65429b9af6 Reland "[CMake] Bumps minimum version to 3.20.0."
The owner of the last two failing buildbots updated CMake.

This reverts commit e8e8707b4aa6e4cc04c0cffb2de01d2de71165fc.
2023-05-13 11:42:25 +02:00
Mark de Wever
62858636f5 [NFC][libc++][format] Tests formatter requirements.
Like done D149543 this validates the other formatter specializations.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D150041
2023-05-13 11:21:15 +02:00
Nikolas Klauser
b97859b674 [libc++][PSTL] Move the already implemented functions to the new dispatching scheme
Reviewed By: ldionne, #libc

Spies: arichardson, pcwang-thead, libcxx-commits, miyuki

Differential Revision: https://reviews.llvm.org/D150277
2023-05-12 13:11:16 -07:00
Hui
868591501c [libc++][ranges] Fix iota_view's constructor's incorrect constraint
One of the overload of the constructors should check Bound is not unreachable_sentinel_t, instead of the Start

Differential Revision: https://reviews.llvm.org/D150206
2023-05-12 19:22:13 +01:00
Mark de Wever
b51e8acd82 [NFC][libc++][format] Uses uniform member signatures.
The newer formatters for (tuple, vector<bool>::reference) specify the
formatter's parse and format member function. This signature is slightly
different from the signature for existing formatters. Adapt the existing
formatters to the new style.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D150034
2023-05-12 17:48:23 +02:00
Mark de Wever
f271df0e79 [clang][ci] Improves buildkite artifacts.
The financial cost of the network I/O for the Clang install artifacts is
quite significant. afd3478f37c8 improved this by creating tarballs. This
commit improves the tarball by using xz compression instead of gzip. This
option is the slowest, but gives the smallest size.

      size  time           time
            (compression)  (decompression)
gzip  51 M  7  s           1.2 s
bz2   44 M  17 s           5.8 s
xz    33 M  76 s           3.1 s

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D150062
2023-05-12 17:44:26 +02:00
Louis Dionne
8e2d09c339 [libc++][PSTL] Add more specialized backend customization points
This allows backends to customize arbitrary parallel algorithms, which was requested pretty often.

Reviewed By: #libc, ldionne

Spies: arichardson, miyuki, crtrott, dalg24, __simt__, philnik, libcxx-commits

Differential Revision: https://reviews.llvm.org/D149686
2023-05-11 13:54:28 -07:00
John Brawn
4d9c936a3e [libc++] Adjust tests using ext/* headers that undefine __DEPRECATED
Several tests undefined __DEPRECATED to avoid warnings as they're
testing the deprecated ext/hash_map. A better way to do this is to use
-Wno-deprecated so it isn't defined in the first place. This prevents
these tests from failing when we give a warning when undefining the
__DEPRECATED macro, as D144654 will do.

For the generated tests however just remove the testing of these
header files, so we don't disable the warning when testing the other
header files.

Differential Revision: https://reviews.llvm.org/D145691
2023-05-11 11:47:11 +01:00
Ian Anderson
5ac0c1af82 [libc++][PSTL] Add missing includes to PSTL headers
Several PSTL headers included by <algorithm> are missing includes for things they use.
Switch some quoted includes to angle includes.

(Issues found from running `check-cxx` with https://reviews.llvm.org/D144322)

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D150085
2023-05-10 15:45:12 -07:00
Jordan Rupprecht
0ec57bf7b1 [libc++] Consistently enable __CORRECT_ISO_CPP_WCHAR_H_PROTO in mbstate.
In libc++'s `wchar.h`, before we forward to the system `wchar.h`, we set `__CORRECT_ISO_CPP_WCHAR_H_PROTO` to ensure it defines the correct signature (e.g. `extern "C++" const wchar_t *wmemchr` and not `extern wchar_t *wmemchr`). After D148542, there are cases where we include the system `wchar.h` from within `__mbstate_t.h` without setting that, and so we get a function type mismatch if we transitively include `wchar.h` through multiple headers in a modules-enabled build. Consistently setting it here resolves those build errors.

Alternative 1: we could put this in `__config` instead. I chose to put it here for a more limited scope.

Alternative 2: we could patch `wchar.h` itself to work correctly and remove references `__CORRECT_ISO_CPP_WCHAR_H_PROTO` from libc++ entirely. It does already set it, but with an additional condition that it is being built by GCC >= 4.4. Clang does pretend to be GCC via `__GNUC__` etc. which can be controlled via `-fgnuc-version` command line flags, but that might have other consequences.

Reviewed By: ldionne, #libc, MaskRay

Differential Revision: https://reviews.llvm.org/D150015
2023-05-10 15:43:38 -07:00
Louis Dionne
15a138acff [libc++][NFC] Remove duplicate declaration of __iter_value_type
The exact same declaration exists a few lines above.
2023-05-10 17:28:15 -04:00
Louis Dionne
845e72eb78 [libc++][NFC] Fix slightly incorrect instructions for testing with Ninja 2023-05-10 15:50:40 -04:00
Aaron Siddhartha Mondal
059986328c
[libcxx] Fix pstl __init_ identifier after 9c4717a
Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D150201
2023-05-10 19:20:55 +02:00
Nikolas Klauser
f041b3472a [libc++][PSTL] Move the remaining configuration into __config
Reviewed By: ldionne, #libc

Spies: sstefan1, jplehr, arichardson, libcxx-commits, miyuki

Differential Revision: https://reviews.llvm.org/D150217
2023-05-10 09:23:13 -07:00
Louis Dionne
36d8b449cf [libc++] Add assertions for potential OOB reads in std::sort
We introduced an optimization to std::sort in 4eddbf9f10a6. However,
that optimization led to issues where users that were passing invalid
comparators to std::sort could start seeing OOB reads. This led to
the revert of the std::sort optimization from the LLVM 16 release
(see https://llvm.org/D146421).

This patch introduces _LIBCPP_ASSERTs to the places in the algorithm
where we make an assumption that the comparator will be consistent and
hence avoid a bounds check based on that. If the comparator happens not
to be consistent with itself, these are the places where we would
incorrectly go out of bounds. This allows users that enable libc++
assertions to catch such misuse at the cost of basically a bounds
check. For users that do not enable libc++ assertions (which is 99.9%
of users since assertions are off by default), this is basically a
no-op, and in fact the assertion will turn into a __builtin_assume,
making it explicit to the compiler that it can rely on the fact that
we're not going out of bounds.

I think this patch strikes the right balance. Folks that want absolute
performance will get what they want, since it is a precondition for the
comparator to be consistent, so the bounds checks are technically not
mandatory. Folks who want more safety *already* need to be enabling
libc++ assertions to catch other types of bugs (like operator[] OOB),
so this solution should also work for them.

I do think we have a lot of work towards popularizing the use of libc++
assertions and integrating it better so that users don't have to know
about the obscure _LIBCPP_ENABLE_ASSERTIONS macro to enable them, but
that's a separate concern.

rdar://106897934

Differential Revision: https://reviews.llvm.org/D147089
2023-05-09 09:05:29 -04:00
Louis Dionne
0acafcd804 [libc++] Provide an assignment operator from pair<U, V> in C++03
This adds an extension to std::pair in C++03 mode where we provide an
assignment operator from a pair<U, V>. Previously, any code trying to
trigger such an assignment operator would have tried using the
`operator=(pair const&)` copy assignment operator, which would then
have tried creating a `pair const&` by using the unconstrained
pair<U, V> constructor.

After this patch, pair will instead go through operator= directly if
its member types are assignable. If they are not assignable, the extension
operator= is disabled with SFINAE and the pair(pair<U, V>) constructor
will be used. Since that constructor is unconstrained, that will either
work or give a hard error.

This should be pretty transparent to users, but this is technically a
behavior change in C++03. Indeed, if a type has both a valid cross-type
assignment operator *and* a valid cross-type constructor, the library
will now prefer the cross-type assignment instead of going through the
cross-type constructor and then using the copy-constructor. Since this
is the mandated behavior in C++11, however, one could argue that any user
broken by that needs to change their code.

The motivation for this change is to allow simplifying the definition
of std::map's value_type, which requires handling assignment to a pair
of references properly. This patch will allow removing complexity from
https://llvm.org/D121485 instead of adding complexity in that patch.

Differential Revision: https://reviews.llvm.org/D150119
2023-05-09 08:35:16 -04:00
varconst
17bbb224f9 [libc++][ranges] Implement the changes to vector from P1206 (ranges::to):
- add the `from_range_t` constructors and the related deduction guides;
- add the `insert_range`/`assign_range`/etc. member functions.
(Note: this patch is split from https://reviews.llvm.org/D142335)

Differential Revision: https://reviews.llvm.org/D149826
2023-05-08 23:40:55 -07:00
Jake Egan
7ad7b3275f [AIX] Adjust support of format function tests
escaped_output.unicode.pass.cpp is failing only on 32-bit AIX. The rest are passing.

Reviewed by: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D149078
2023-05-08 13:41:00 -04:00