1435 Commits

Author SHA1 Message Date
Louis Dionne
99dcc9ff0e [libc++][NFC] Remove leftover entry for <experimental/span> in header_information.py 2023-07-05 17:48:04 -04:00
Ian Anderson
6f05da6cf8 [libc++][Modules] Add missing submodules
Several headers that are included by the modular headers are missing from the module map, add those in.
The either/or implementation headers `<__algorithm/pstl_backends/cpu_backends/serial.h>`/`<__algorithm/pstl_backends/cpu_backends/thread.h>` need to be textual, as does `<__undef_macros>`.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D153213
2023-07-05 09:51:11 -07:00
Mark de Wever
a9e5773f52 [libc++][format] Implements formatting pointer.
The feature is applied as DR instead of a normal paper. MSVC STL and
libstdc++ will do the same.

Implements
- P2510R3 Formatting pointers

Depends on D153192

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D153195
2023-07-05 18:23:31 +02:00
Louis Dionne
2d7eb9c9ea [libc++][NFC] clang-format <shared_mutex>
I am about to touch several lines in that file for a patch anyway, so
I might as well clang-format it upfront to avoid mixing styles after
my patch.
2023-07-04 11:20:21 -04:00
Louis Dionne
8dcb8ea75c [libc++] Remove support for .fail.cpp tests
We want to move away from those tests and towards explicit .verify.cpp
tests, since those have a simpler model.

Differential Revision: https://reviews.llvm.org/D153982
2023-07-03 15:38:37 -04:00
varconst
b5270ba20d [libc++] Remove the legacy debug mode.
See https://discourse.llvm.org/t/rfc-removing-the-legacy-debug-mode-from-libc/71026

Reviewed By: #libc, Mordante, ldionne

Differential Revision: https://reviews.llvm.org/D153672
2023-06-29 14:49:51 -07:00
Louis Dionne
5b55eb1e88 [lit] Add a method to lit.TestFormat to get the list of tests associated to a path
Lit TestFormat classes already needed to implement the getTestsInDirectory
method. However, some test formats may want to expand a single test path
to multiple Lit tests, for example in the case of a test that actually
generates other Lit tests.

To accommodate that, this commit adds the getTestsForPath method to
TestFormat. This method can be used to turn a single path in a Lit
test suite into a list of tests associated to that path.

Differential Revision: https://reviews.llvm.org/D151664
2023-06-27 16:27:08 -04:00
Louis Dionne
c352fa7407 [libc++] Expand the contents of LIBCXX_ENABLE_FILESYSTEM
Since LIBCXX_ENABLE_FILESYSTEM now truly represents whether the
platform supports a filesystem (as opposed to whether the <filesystem>
library is provided), we can provide a few additional classes from
the <filesystem> library even when the platform does not have support
for a filesystem. For example, this allows performing path manipulations
using std::filesystem::path even on platforms where there is no actual
filesystem.

rdar://107061236

Differential Revision: https://reviews.llvm.org/D152382
2023-06-27 09:18:40 -04:00
Nikolas Klauser
f6d557ee34 [clang][NFC] Remove trailing whitespaces and enforce it in lib, include and docs
A lot of editors remove trailing whitespaces. This patch removes any trailing whitespaces and makes sure that no new ones are added.

Reviewed By: erichkeane, paulkirth, #libc, philnik

Spies: wangpc, aheejin, MaskRay, pcwang-thead, cfe-commits, libcxx-commits, dschuff, nemanjai, arichardson, kbarton, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, Jim, s.egerton, sameer.abuasal, apazos, luismarques, martong, frasercrmck, steakhal, luke

Differential Revision: https://reviews.llvm.org/D151963
2023-06-26 09:34:36 -07:00
yronglin
9f6439f1c5 [libc++][ranges] Implement P2494R2 (Relaxing range adaptors to allow for move only types)
Implement P2494R2 `Relaxing range adaptors to allow for move only types`

https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2494r2.html#wording-ftm

According to the words in P2494R2, I haven't add new test for `drop_while_view`, `take_while_view` and `filter_view`, because these views has the requirement that the predicate is an `indirect_unary_predicate`, which requires that the predicate is `copy_constructible`, so they still can't accept move only types as predicate.

```
[P2483R0] also suggests future work to relax the requirements on the predicate types stored by standard views. This paper does not perform this relaxation, as the copy constructibility requirement is enshrined in the indirect callable concepts ([indirectcallable.indirectinvocable]). Thus, while this paper modifies the views that currently use copyable-box for user provided predicates, it only does so to apply the rename of the exposition-only type to movable-box; it does not change any of the constraints on those views. It does, however, relax the requirements on invocables accepted by the transform family of views, because those are not constrained using the indirect callable concepts.
```

Reviewed By: #libc, var-const

Differential Revision: https://reviews.llvm.org/D151629
2023-06-25 08:15:52 +08:00
Louis Dionne
b356928058 [libc++] Fix the check-format job
Previously, it wouldn't take into account files in ignore_format.txt
(at least not on OSX) because the `find` command would return file names
like `libcxx/src//new_handler.cpp`, which never matched the file names
in `ignore_format.txt`.

Differential Revision: https://reviews.llvm.org/D153416
2023-06-21 17:59:32 -04:00
Louis Dionne
333384c5bc [libc++][NFC] clang-format filesystem_error.h
It's giving me trouble in an upcoming patch so I figured I'd do it as
a NFC before landing that other patch.
2023-06-20 16:27:26 -04:00
Louis Dionne
5a6e6adb91 [libc++] Make sure our .clang-format is used for all languages
In particular, this ensures that it is used for Objective-C and
Objective-C++, since we have a few files that get detected as that.

Differential Revision: https://reviews.llvm.org/D153289
2023-06-20 15:00:53 -04:00
Mark de Wever
202054559c [libc++][test] Removes old fallbacks.
All supported compilers support the -std=year except Clang < 17 which
doesn't support C++23. This fallback is marked for removal once we no
longer support Clang 16.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D152106
2023-06-20 19:29:49 +02:00
Mark de Wever
f5b82022ff [libc++][CI] Install newer CMake version.
This version allowed testing the std module in C++26 mode.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D153227
2023-06-20 19:20:08 +02:00
Louis Dionne
2da049a141 [libc++] Add incomplete availability markup for std::pmr
This fixes rdar://110330781, which asked for the feature-test macro
for std::pmr to take into account the deployment target. It doesn't
fix https://llvm.org/PR62212, though, because the availability markup
itself must be disabled until some Clang bugs have been fixed.

This is pretty vexing, however at least everything should work once
those Clang bugs have been fixed. In the meantime, this patch at least
adds the required markup (as disabled) and ensures that the feature-test
macro for std::pmr is aware of the deployment target requirement.

Differential Revision: https://reviews.llvm.org/D135813
2023-06-20 10:59:05 -04:00
Louis Dionne
1288e72d10 [libc++][NFC] Sort header list in header_information.py 2023-06-19 11:54:04 -04:00
Louis Dionne
5aa03b648b [libc++][NFC] Apply clang-format on large parts of the code base
This commit does a pass of clang-format over files in libc++ that
don't require major changes to conform to our style guide, or for
which we're not overly concerned about conflicting with in-flight
patches or hindering the git blame.

This roughly covers:
- benchmarks
- range algorithms
- concepts
- type traits

I did a manual verification of all the changes, and in particular I
applied clang-format on/off annotations in a few places where the
result was less readable after than before. This was not necessary
in a lot of places, however I did find that clang-format had pretty
bad taste when it comes to formatting concepts.

Differential Revision: https://reviews.llvm.org/D153140
2023-06-19 11:19:51 -04:00
Mark de Wever
f805c799bf [libc++] "Implements" new SI prefixis.
Like yocto, zepto, zetta, and yotta. The new prefixes quecto, ronto,
ronna, and quetta can't be implemented in a intmax_t. So their
implementation does nothing.

Implements
- P2734R0 Adding the new SI prefixes

Depends on D153192

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153200
2023-06-19 17:04:35 +02:00
Mark de Wever
a4f0764aef [libc++] Marks __cpp_lib_bitops as implemented.
This FTM was introduced in
  P0553R4 Bit operations

Which has been implemented since libc++ 9.

This was noticed while working on D153192.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153225
2023-06-19 17:01:27 +02:00
Mark de Wever
3f05d044f4 [libc++] Update status after Varna meeting.
This updates:
- The status tables
- Feature test macros
- New headers for modules
The latter avoids forgetting about modules when implementing the feature
in a new header.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153192
2023-06-19 16:55:30 +02:00
Louis Dionne
c7d3c84449 [libc++] Split sources for <filesystem>
The operations.cpp file contained the implementation of a ton of
functionality unrelated to just the filesystem operations, and
filesystem_common.h contained a lot of unrelated functionality as well.

Splitting this up into more files will make it possible in the future
to support parts of <filesystem> (e.g. path) on systems where there is
no notion of a filesystem.

Differential Revision: https://reviews.llvm.org/D152377
2023-06-19 09:07:05 -04:00
Hui
cea4285949 [libc++][NFC] Granularise <thread> header
- This was to make implementing jthread easier and requested in https://reviews.llvm.org/D151559

Differential Revision: https://reviews.llvm.org/D151792
2023-06-17 12:28:52 +01:00
Louis Dionne
f7679bcfb6 [libc++][NFC] Reformat params.py
After the Black reformatting changes, the code became pretty hard to
read and inconsistently formatted. This fixes that.

Differential Revision: https://reviews.llvm.org/D152839
2023-06-15 14:46:14 -04:00
Mark de Wever
9b08c8a225 [libc++][modules] Adds the C++23 std module.
The patch is based on D144994.

D151030 added the module definitions for the module std.
This patch wires in the module and enables the basic testing.

Some notable features are missing:
- There is no test that libc++ can be fully imported as a module.
- This lacks the parts for the std.compat module.
- The module is not shipped with libc++.

Implements parts of
- P2465R3 Standard Library Modules std and std.compat

Reviewed By: ldionne, aaronmondal, #libc

Differential Revision: https://reviews.llvm.org/D151814
2023-06-15 18:14:15 +02:00
Louis Dionne
aee3a9f5bc [libc++][NFC] clang-format new_handler.cpp 2023-06-15 11:14:26 -04:00
Louis Dionne
80e4ccab79 [libc++] Move the definition of std::new_handler out of new.cpp
This reduces the difference between libc++'s new.cpp and libc++abi's
stdlib_new_delete.cpp files, which are essentially copies of each other.

Differential Revision: https://reviews.llvm.org/D152956
2023-06-15 11:14:14 -04:00
Louis Dionne
52310ce9c1 [libc++][NFC] Reformat features.py
This file was reformatted using the Black tool, which led to entirely
unreadable code due to how lines are broken. Formatting tools are fine,
but not when they lead to code that humans have trouble reading. In the
case of features.py, a lot of it was meant to be aligned in a repetitive
but consistent way to make the structure of the code stand out.
Reformatting with the tool lost that property.

Differential Revision: https://reviews.llvm.org/D152737
2023-06-13 10:24:46 -07:00
Louis Dionne
520c7fbbd0 [libc++] Mark slow tests as unsupported on GCC
Some tests in our test suite are unbelievably slow on GCC due to the
use of the always_inline attribute. See [1] for more details.

This patch introduces the GCC-ALWAYS_INLINE-FIXME lit feature to
disable tests that are plagued by that issue. At the same time, it
moves several existing tests from ad-hoc `UNSUPPORTED: gcc-12` markup
to the new GCC-ALWAYS_INLINE-FIXME feature, and marks the slowest tests
reported by the CI as `UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME`.

[1]: https://discourse.llvm.org/t/rfc-stop-supporting-extern-instantiations-with-gcc/71277/1

Differential Revision: https://reviews.llvm.org/D152736
2023-06-13 10:20:30 -07:00
Louis Dionne
dd72b81334 [libc++] Rename availability macros for <filesystem>
This makes it clearer that the availability macro only pertains to
<filesystem>, and not to whether the platform has support for a file
system.

Differential Revision: https://reviews.llvm.org/D152172
2023-06-07 11:31:29 -07:00
Louis Dionne
66a562d22e [libc++] Roll up fstream support into filesystem support
LIBCXX_ENABLE_FILESYSTEM should represent whether the platform has
support for a filesystem, not just whether we support <filesystem>.
This patch slightly generalizes the setting to also encompass whether
we provide <fstream>, since that only makes sense when a filesystem is
supported.

Differential Revision: https://reviews.llvm.org/D152168
2023-06-07 08:04:58 -07:00
Nikolas Klauser
88632e4806 [libc++] Refactor __less
This simplifies the usage of `__less` by making the class not depend on the types compared, but instead the `operator()`. We can't remove the template completely because we explicitly instantiate `std::__sort` with `__less<T>`.

Reviewed By: ldionne, #libc

Spies: arichardson, EricWF, libcxx-commits, mgrang

Differential Revision: https://reviews.llvm.org/D145285
2023-06-06 13:58:52 -07:00
Louis Dionne
1939eb3dc2 [libc++] Disable int128_t and ship filesystem on MSVC by default
Back in 2020 [1], we went very close to enabling Filesystem on MSVC
by disabling int128_t, but decided to wait because MSVC support
for int128_t was supposed to come shortly after. Since it's not
there yet, I propose turning off int128_t support by default on MSVC.
This will make <filesystem> available by default on MSVC, and most
importantly will open the possibility for changing
LIBCXX_ENABLE_FILESYSTEM to mean "the system doesn't have support
for a filesystem" instead of simply "don't build the std::filesystem
library", which is what I'm really after with this change.

In a way, this is a resurection of D91139.

[1]: https://reviews.llvm.org/D91139#2429595

Differential Revision: https://reviews.llvm.org/D134912
2023-06-06 13:31:03 -07:00
Louis Dionne
7d2b9fafab [libc++] Use Lit annotations for all .gen.py tests
Instead of guarding header tests using #ifdefs inside the tests,
use Lit markup to mark all the tests as unsupported. This is simpler
but also provides better feedback about which tests are being run
when running the test suite.

Differential Revision: https://reviews.llvm.org/D151893
2023-06-06 13:28:09 -07:00
Nikolas Klauser
d965960fcf Revert "[libc++] Optimize for_each for segmented iterators"
This reverts commit b1dc43aa3a05c2f14725e2e6428544208ccbe161.
2023-06-05 10:00:02 -07:00
Louis Dionne
81cc929d4f [libc++] Use .gen.py tests for the transitive inclusion tests
This finishes the transition of tests covered in generate_header_tests.py
to the new .gen.py format.

Differential Revision: https://reviews.llvm.org/D152008
2023-06-05 07:23:31 -07:00
Hui
b77e50e6ae [libc++] Implement stop_token
Implement stop_token
http://eel.is/c++draft/thread.stoptoken
2023-06-05 15:10:36 +01:00
Louis Dionne
c0f4b12da4 [libc++] Transition several remaining generated tests to the new .gen format
In addition to reducing the amount of boilerplate we need to generate
whenever a new header is added, this also improves the existing tests
by running them in separate Lit tests (so they can be parallelized).
This also creates separate translation units for most header tests,
which is what we really should have done from the start since it
isolates each header we're testing.

Differential Revision: https://reviews.llvm.org/D151654
2023-06-02 10:02:15 -07:00
Louis Dionne
45307f1b0d [libc++] Refactor the mandatory header inclusion tests to .gen.py
This allows removing a bunch of boilerplate from the test suite and
reducing the amount of manual stuff contributors have to do when they
add a new public header.

Differential Revision: https://reviews.llvm.org/D151830
2023-06-01 19:56:30 -07:00
Louis Dionne
6091025b85 [libc++] Make sure we use POSIX paths in header_information.py
Otherwise, the various lists of headers have different content based
on whether they are run on Windows or other platforms, which makes it
really difficult to write .gen.py tests correctly.

Differential Revision: https://reviews.llvm.org/D151913
2023-06-01 19:56:06 -07:00
Louis Dionne
460d1367c3 [libc++] Extract ccache stats after the bootstrapping build 2023-06-01 13:16:19 -07:00
Louis Dionne
86ab93828a [libc++] Use .gen.py tests to generate _LIBCPP_VERSION tests
This removes the need for contributors to do some manual steps
when adding a new public header.

Differential Revision: https://reviews.llvm.org/D151831
2023-06-01 08:18:43 -07:00
Nikolas Klauser
b1dc43aa3a [libc++] Optimize for_each for segmented iterators
```
---------------------------------------------------
Benchmark                       old             new
---------------------------------------------------
bm_for_each/1               3.00 ns         2.98 ns
bm_for_each/2               4.53 ns         4.57 ns
bm_for_each/3               5.82 ns         5.82 ns
bm_for_each/4               6.94 ns         6.91 ns
bm_for_each/5               7.55 ns         7.75 ns
bm_for_each/6               7.06 ns         7.45 ns
bm_for_each/7               6.69 ns         7.14 ns
bm_for_each/8               6.86 ns         4.06 ns
bm_for_each/16              11.5 ns         5.73 ns
bm_for_each/64              43.7 ns         4.06 ns
bm_for_each/512              356 ns         7.98 ns
bm_for_each/4096            2787 ns         53.6 ns
bm_for_each/32768          20836 ns          438 ns
bm_for_each/262144        195362 ns         4945 ns
bm_for_each/1048576       685482 ns        19822 ns
```

Reviewed By: ldionne, Mordante, #libc

Spies: arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D151274
2023-05-31 18:15:25 -07:00
Nikolas Klauser
dc124cda7c [libc++] Introduce __for_each_segment and use it in copy/move
This simplifies the code inside copy/move and makes it easier to apply the optimization to other algorithms.

Reviewed By: ldionne, Mordante, #libc

Spies: arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D151265
2023-05-31 18:15:20 -07:00
Mark de Wever
f29f1c7e23 [libc++]{CI] Bumps clang-tidy version used.
The CI can no longer run with clang-tidy 16 increment it to version 17.
Whether permanently moving to the latest development version is being
discussed on Discourse.

Depends on D149455

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D151628
2023-05-31 17:25:42 +02:00
Mark de Wever
cf64668b8c [libc++][test] Prefers the newer clang-tidy version.
Module require Clang 17, since Clang 16 requires the magic # __FILE__
line. Therefore, if available, use clang-tidy 17 too. This change should
be reverted after LLVM 17 is released.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D149455
2023-05-31 17:24:37 +02:00
Mark de Wever
4de9936fe0 [libc++][CI] Escape quoting.
This should fix the Clang CI.
2023-05-31 07:55:05 +02:00
Louis Dionne
19ef02e3f4 [libc++][ci] Use ccache in the jobs that build Clang
This is an attempt to reduce the time taken by the Bootstrapping
build job and the Clang CI job that builds the compiler from scratch.

Differential Revision: https://reviews.llvm.org/D150908
2023-05-30 13:10:03 -07:00
Mark de Wever
d951c6a533 [libc++][CI] Installs libomp.
This is needed to build clang-tidy plugins using clang-tidy 17.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D151488
2023-05-30 18:40:36 +02:00
Louis Dionne
1ee839d0ce [libc++] Use the new .gen tests to implement __verbose_abort tests
This reduces the amount of boilerplate that we need to generate
for each commit. It also resolves a problem where the modular CI
would run extremely slow on this test because we'd define a macro
before including the standard library, defeating the module cache.

Differential Revision: https://reviews.llvm.org/D151156
2023-05-29 12:28:52 -07:00