Commit Graph

10863 Commits

Author SHA1 Message Date
Mark de Wever
394eeb6e45 [libc++][test] Fixes a typo in UNSUPPORTED. 2023-08-19 08:57:58 +02:00
Kazu Hirata
11e2975810 Fx typos in documentation 2023-08-18 23:36:04 -07:00
Nikolas Klauser
4da76ea70a [libc++][NFC] Refactor enable_ifs in defaulted arguments to defaulted template arguments
This brings most of the enable_ifs in libc++ to the same style. It also has the nice side-effect of reducing the size of names of these symbols, since the arguments don't get mangled anymore.

Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D157748
2023-08-18 13:08:18 -07:00
Louis Dionne
5a6c1ce189 [libc++] Change _LIBCPP_CONSTEXPR_SINCE_XXX to constexpr in the dylib
Since we build the dylib with C++20, there's no need to use conditional
macros anymore.

Differential Revision: https://reviews.llvm.org/D157995
2023-08-18 13:44:26 -04:00
Ian Anderson
a9167c2e47 [libc++][Modules] Simplify the __std_clang_module header generation
Post review feedback on D157364. Don't section the __std_clang_module header by macro, put the headers in alphabetical order and repeat the macro guards. Restore header_information.header_restrictions.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D158133
2023-08-17 22:34:54 -07:00
Mark de Wever
2c629eb508 [libc++][CI] Fixes error messages.
Fixes 2 error messages from the module test clang-tidy plugin.
- an issue where an empty filename can't be used in an AST matcher
- an issue where no filename is valid when testing the std module cppm
This reduces the output of the test, making it easier to find the real
error when the test fails.

Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D157741
2023-08-17 18:08:47 +02:00
Mark de Wever
8f01029b17 [libc++][chrono] Fixes FreeBSD tests.
This adjusts the output of the tests to match reality.

Reviewed By: emaste, #libc, dim, philnik

Differential Revision: https://reviews.llvm.org/D157778
2023-08-17 18:00:25 +02:00
Mark de Wever
ab148445e8 [NFC][libc++][test] Fixes a copy-paste error. 2023-08-17 17:57:33 +02:00
Louis Dionne
760261a3da [libc++] Fix a few incorrect CMake configuration options
This patch fixes a few CMake options that were set using incorrect
mechanisms.

CMake's man page for the -D <var>=<value> option states: If a command in
the project sets the type to PATH or FILEPATH, then the <value> will be
converted to an absolute path. That's not what we want for most of the
paths we have as configuration options. Otherwise, using -D to set the
configuration option results in an absolute path being used, which
breaks things.

option() denotes a boolean variable, but what was desired was a
string/list variable. Fix this to prevent cmake from changing any
non-empty user provided values to 'ON'.

Differential Revision: https://reviews.llvm.org/D157926
2023-08-17 09:43:09 -04:00
Nikolas Klauser
68b1035965 [libc++][PSTL] Add a __parallel_sort implementation to libdispatch
Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155136
2023-08-15 12:20:40 -07:00
Nikolas Klauser
475bd19ee8 [libc++][NFC] Refactor return type enable_ifs to defaulted template arguments
This brings most of the enable_ifs in libc++ to the same style. It also has the nice side-effect of reducing the size of names of these symbols, since the depedent return type is shorter.

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D157736
2023-08-15 12:19:21 -07:00
Nikolas Klauser
925a11a5f2 [libc++] Simplify is_convertible
GCC 13 has added __is_convertible(), so we don't need to keep the fallback implementation around.

Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D157939
2023-08-15 12:18:36 -07:00
Kim Gräsman
3920c1c5b1 [docs] Fix reST formatting in UsingLibcxx IWYU section
The link syntax was missing a trailing underscore, and there was an
extraneous backtick on the reference to IWYU's libcxx.imp.

Reviewed By: #libc, philnik

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D157784
2023-08-15 12:16:15 -07:00
Mark de Wever
b22253b771 [libc++][CI] Removes an ASAN work-around.
With the underlying bug fixed the work-around should no longer be
needed.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D157779
2023-08-15 19:14:27 +02:00
Louis Dionne
3946535091 [libc++][NFC] Update comment in transitive_includes.gen.py to make it easier to re-run 2023-08-15 12:55:39 -04:00
Louis Dionne
014830193b [libc++] Comment out the AIX jobs that are failing
Marking them as soft_fail still causes the CI to show up as failed
on Phabricator patches.
2023-08-15 12:43:15 -04:00
Nikolas Klauser
f29c54998d [libc++] Fix problems with GCC 13 and switch to it in the CI
Reviewed By: #libc, #libc_abi, Mordante

Spies: arphaman, Mordante, libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D157060
2023-08-14 16:54:50 -07:00
Nikolas Klauser
051c863012 [libc++][PSTL] Simplify the partitioning algorithm until we have better data to know how to chunk better
The current chunking strategy is very bad for sorting, and we don't really know how to chunk in general. This fixes the performance problem for sorting.

Reviewed By: ldionne, #libc

Spies: libcxx-commits, krytarowski

Differential Revision: https://reviews.llvm.org/D155531
2023-08-14 16:44:30 -07:00
Ian Anderson
f0c5ce0800 [libc++][Modules] Generate the __std_clang_module header
Use header_information to generate the __std_clang_module header. Instead of using lit_header_restrictions like the manually written header did, make a new header_include_requirements to codify what can be included rather than what can be fully tested.

Reviewed By: Mordante, #libc

Differential Revision: https://reviews.llvm.org/D157364
2023-08-14 12:08:00 -07:00
Ian Anderson
72a006b338 [libc++][Modules] Remove unnecessary requires from the module map
Top level modules don't need `requires` because they're only built when their headers are included.

Reviewed By: ldionne, Mordante, #libc

Differential Revision: https://reviews.llvm.org/D157363
2023-08-14 12:07:02 -07:00
Chris Cotter
32870da3ba Fix typos in documentation 2023-08-13 23:46:44 -07:00
Daniil Kalinin
45500fa08a [libc++] Fix the signature of std::rotl and std::rotr
- Changed parameters type in `std::rotr` and `std::rorl` functions from `unsigned int` to `int`.
- Implemented behaviour for negative parameter values.

Fixes #64544

Reviewed By: #libc, philnik

Spies: arichardson, philnik, libcxx-commits

Differential Revision: https://reviews.llvm.org/D157569
2023-08-12 08:46:11 -07:00
Edoardo Sanguineti
66bb6b4fda [libc++] Optimize internal function in <system_error>
In the event the internal function __init is called with an empty string the code will take unnecessary extra steps, in addition, the code generated might be overall greater because, to my understanding, when initializing a string with an empty `const char*` "" (like in this case), the compiler might be unable to deduce the string is indeed empty at compile time and more code is generated.

The goal of this patch is to make a new internal function that will accept just an error code skipping the empty string argument. It should skip the unnecessary steps and in the event `if (ec)` is `false`, it will return an empty string using the correct ctor, avoiding any extra code generation issues.

After the conversation about this patch matured in the libcxx channel on the LLVM Discord server, the patch was analyzed quickly with "Compiler Explorer" and other tools and it was discovered that it does indeed reduce the amount of code generated when using the latest stable clang version (16) which in turn produces faster code.

This patch targets LLVM 18 as it will break the ABI by addressing https://github.com/llvm/llvm-project/issues/63985

Benchmark tests run on other machines as well show in the best case, that the new version without the extra string as an argument performs 10 times faster.
On the buildkite CI run it shows the new code takes less CPU time as well.
In conclusion, the new code should also just appear cleaner because there are fewer checks to do when there is no message.

Reviewed By: #libc, philnik

Spies: emaste, nemanjai, philnik, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155820
2023-08-11 13:08:45 -07:00
Ian Anderson
1aee2434ce [libc++] Move header_information.py up from tests
I need to use header_information.py in a generator script that isn't for tests in an upcoming change. Move it up a level so that it's in utils/libcxx instead of utils/libcxx/tests.

Differential Revision: https://reviews.llvm.org/D157639
2023-08-11 12:45:04 -07:00
Ian Anderson
ee5e8e6dcb [libc++] Remove non-existent headers from header_information.py
experimental/algorithm and experimental/functional no longer exist, but header_information.py still has references.

Differential Revision: https://reviews.llvm.org/D157639
2023-08-11 12:45:04 -07:00
Louis Dionne
4e1a23e3fc [runtimes][NFC] Remove stray whitespace on extern C comments 2023-08-11 13:25:01 -04:00
Nikolas Klauser
bec51c907a [libc++][NFC] Remove the old PSTL headers
We don't actually use these headers, so we might as well remove them.

Reviewed By: ldionne, #libc

Spies: arichardson, EricWF, sstefan1, jplehr, wangpc, mgrang, libcxx-commits, miyuki

Differential Revision: https://reviews.llvm.org/D157558
2023-08-11 08:29:15 -07:00
Michael Platings
d13f1cb569 [libc++][test] Fix max_size test for Arm big endian
With ABI version 2 and big endian Arm, the full_size test matches the
current behaviour. It's possible that this would also be the case for
other big endian architectures but I don't have data on that.

Differential Revision: https://reviews.llvm.org/D157699
2023-08-11 16:23:32 +01:00
Piotr Fusik
1406f099de [libc++][tests] Fix a test exercising incorrect overload
Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D154489
2023-08-11 06:12:11 +02:00
Kazu Hirata
14292d9f1e [libcxx] Fix typos in documentation 2023-08-10 18:44:19 -07:00
Nikolas Klauser
9e94f7dcb5 [libc++] Remove P2554R0 from the status paper, since it's also part of P0009R18 2023-08-10 14:29:36 -07:00
Nikolas Klauser
f8a1913e46 [libc++] Remove P2553R1 from the status page, since it's been part of P0009R18 2023-08-10 14:13:06 -07:00
Piotr Fusik
090996f4a1 [libc++] Work around dynamic linking of stringstream::str() on Windows
Also `istringstream::str()` and `ostringstrem::str()`.

https://github.com/llvm/llvm-project/issues/40363 causes `str()`
to be dllimport'ed despite _LIBCPP_HIDE_FROM_ABI.
This is a temporary solution until #40363 is fixed.

Reviewed By: #libc, thakis, philnik

Differential Revision: https://reviews.llvm.org/D157602
2023-08-10 20:47:11 +02:00
Mark de Wever
5bf8de882a [libc++][CI] Upgrades to LLVM 18 as HEAD version.
Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D156922
2023-08-10 17:02:56 +02:00
Louis Dionne
2583946e1f [libc++] Use _LIBCPP_VERBOSE_ABORT from __throw_bad_alloc
It seems like this one was forgotten and we were still using a raw
std::abort().

Differential Revision: https://reviews.llvm.org/D157446
2023-08-10 08:32:01 -04:00
Louis Dionne
280d68e7f8 [libc++] Clean up mess around __throw_runtime_error
We were defining the function in locale.cpp, and we actually had two
overloads for it. This is pretty confusing given that one was static
and not exported from the dylib, and the other one was. Instead, use
the vanilla __throw_runtime_error function everywhere even though that
adds a tiny bit of code duplication.

Differential Revision: https://reviews.llvm.org/D155008
2023-08-10 08:31:10 -04:00
Nikolas Klauser
e30a148b09 [libc++] Remove generic char_traits implementation
This has been deprecated and should be removed now.

Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D157058
2023-08-09 15:55:28 -07:00
zijunzhao
996559602b Update RangesAlgorithm status
Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D157539
2023-08-09 19:28:00 +00:00
Mark de Wever
4d4c70c91c [libc++][modules] Removes the module partitions.
This patch is based on the suggestion by @ChuanqiXu on discourse
(https://discourse.llvm.org/t/alternatives-to-the-implementation-of-std-modules/71958)

Instead of making a module partition per header every header gets an inc
file which contains the exports per header. The std module then includes
all public headers and these inc files. The one file per header is
useful for testing purposes. The CI tests whether the exports of a
header's module partition matches the "public" named declarations in the
header. With one file per header this can still be done.

The patch improves compilation time of files using "import std;" and the
size of the std module.

A comparision of the compilation speed using a libc++ test
  build/bin/llvm-lit -a -Dstd=c++23 -Denable_modules=std libcxx/test/std/modules/std.pass.cpp

Which boils down to
  import std;

  int main(int, char**) {
    std::println("Hello modular world");
    return 0;
  }
and has -ftime-report enabled

Before
===-------------------------------------------------------------------------===
                          Clang front-end time report
===-------------------------------------------------------------------------===
  Total Execution Time: 8.6585 seconds (8.6619 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   4.5041 ( 57.2%)   0.4264 ( 54.4%)   4.9305 ( 56.9%)   4.9331 ( 57.0%)  Clang front-end timer
   3.2037 ( 40.7%)   0.2408 ( 30.7%)   3.4445 ( 39.8%)   3.4452 ( 39.8%)  Reading modules
   0.1665 (  2.1%)   0.1170 ( 14.9%)   0.2835 (  3.3%)   0.2837 (  3.3%)  Loading .../build/test/__config_module__/CMakeFiles/std.dir/std.pcm
   7.8744 (100.0%)   0.7842 (100.0%)   8.6585 (100.0%)   8.6619 (100.0%)  Total

After
===-------------------------------------------------------------------------===
                          Clang front-end time report
===-------------------------------------------------------------------------===
  Total Execution Time: 1.2420 seconds (1.2423 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   0.8892 ( 84.6%)   0.1698 ( 88.8%)   1.0590 ( 85.3%)   1.0590 ( 85.2%)  Clang front-end timer
   0.1533 ( 14.6%)   0.0168 (  8.8%)   0.1701 ( 13.7%)   0.1704 ( 13.7%)  Reading modules
   0.0082 (  0.8%)   0.0047 (  2.5%)   0.0129 (  1.0%)   0.0129 (  1.0%)  Loading .../build/test/__config_module__/CMakeFiles/std.dir/std.pcm
   1.0507 (100.0%)   0.1913 (100.0%)   1.2420 (100.0%)   1.2423 (100.0%)  Total

Using "include <print>" instead of "import module;"
===-------------------------------------------------------------------------===
                          Clang front-end time report
===-------------------------------------------------------------------------===
  Total Execution Time: 2.1507 seconds (2.1517 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   1.9714 (100.0%)   0.1793 (100.0%)   2.1507 (100.0%)   2.1517 (100.0%)  Clang front-end timer
   1.9714 (100.0%)   0.1793 (100.0%)   2.1507 (100.0%)   2.1517 (100.0%)  Total

It's possible to use the std module in external projects
(https://libcxx.llvm.org/Modules.html#using-in-external-projects)

Tested this with a private project to validate the size of the generated files:

Before
$ du -sch std-*
448M	std-build
508K	std-src
120K	std-subbuild
449M	total

After
$ du -sch std-*
29M	std-build
1004K	std-src
132K	std-subbuild
30M	total

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D156907
2023-08-09 19:39:08 +02:00
Mark de Wever
cf83cfb3a5 [libc++][doc] Updates format related release notes.
As suggested by @ldionne.

Reviewed By: ldionne, #libc, avogelsgesang

Differential Revision: https://reviews.llvm.org/D156030
2023-08-09 19:04:29 +02:00
Louis Dionne
e5ec498fc5 [libc++] Assume that coroutines are available in C++20
All supported compilers have support for coroutines in C++20 now.

Differential Revision: https://reviews.llvm.org/D145086
2023-08-08 14:05:18 -04:00
Louis Dionne
ce12d6563e [libc++] Temporarily allow AIX builders to fail
The builders are in a broken state, which causes all the CI builds
to appear as red. Make them soft fail until we've managed to reach
the build bot owners.

Differential Revision: https://reviews.llvm.org/D157421
2023-08-08 14:04:17 -04:00
Louis Dionne
51af4fddf4 [libc++][NFC] Add missing license to test file 2023-08-08 13:32:56 -04:00
Louis Dionne
5e67348158 [libc++] Remove variables that are not necessary anymore inside header_information.py
Those are not relevant anymore since we don't have tests for private
headers anymore.

Differential Revision: https://reviews.llvm.org/D155880
2023-08-08 08:47:14 -04:00
Louis Dionne
d2a61db072 [libc++] Deflake the Clang Modules CI job
This re-introduces the workaround that had been introduced in d7ca140c01
and then removed in 0c0628c92c, since it seems like it is needed after all.

Differential Revision: https://reviews.llvm.org/D157319
2023-08-08 08:42:50 -04:00
Eymen Ünay
f1fc29b65c [libcxx] Fix typo in comments
Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D157213
2023-08-07 18:15:28 +02:00
Gonzalo Brito Gadeschi
0e2de665f3 [libc++][PSTL] Parallelize random_access_iterator
P2408 requires this for C++23, but implementing it in C++20 is safe
because the only code impacted would be code that violated a
precondition of the parallel algorithm. It was P2408 intent to
enable implementations to backport this to C++20.

Closes #63447 .

Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D154305
2023-08-07 17:58:27 +02:00
Konstantin Varlamov
1d340250a8 [libc++][PSTL] Disable -Wpass-failed.
PSTL contains many pragmas that request loop vectorization, which would
produce a warning when the compiler is unable to fulfill the request (if
`-Wpass-failed` is enabled). This is normal and expected in some cases,
and we don't want `-Werror` to turn that into a compilation failure.

Differential Revision: https://reviews.llvm.org/D157145
2023-08-04 15:11:36 -07:00
Konstantin Varlamov
e6b2e1b882 [libc++][print] Mark some more <print> tests as requiring a file system.
A follow-up to https://reviews.llvm.org/D156585.
2023-08-04 13:53:43 -07:00
Christian Trott
0f4d7d81c9 [libc++][mdspan] Fix layout_left::stride(r)
It was using the stride calculation of layout_right.

Reviewed By: philnik

Differential Revision: https://reviews.llvm.org/D157065
2023-08-04 09:40:27 -06:00
Martin Storsjö
9b02e8d4a0 [libcxx] Respect CMAKE_MSVC_RUNTIME_LIBRARY wrt whether to use the debug CRT
If CMAKE_MSVC_RUNTIME_LIBRARY isn't set, then CMake defaults to
the debug CRT, if CMAKE_BUILD_TYPE is set to Debug. If
CMAKE_MSVC_RUNTIME_LIBRARY is set though, that overrides any
implicit defaults.

Match this in libcxx's own manual linking logic. This allows
decoupling the debug CRT from the CMAKE_BUILD_TYPE and allows users
to configure their builds exactly how they want.

Differential Revision: https://reviews.llvm.org/D155561
2023-08-04 15:53:45 +03:00
Martin Storsjö
9853e9b859 [libcxx] [test] Deduplicate setting parameters for clangcl test configs. NFC.
Differential Revision: https://reviews.llvm.org/D156573
2023-08-04 15:53:18 +03:00
Nikolas Klauser
3537338d1a [libc++][libunwind] Fixes to allow GCC 13 to compile libunwind/libc++abi/libc++
These are changes to allow GCC 13 to successfully compile the runtimes stack.

Reviewed By: ldionne, #libc, #libunwind, MaskRay

Spies: MaskRay, zibi, SeanP, power-llvm-team, mstorsjo, arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D151387
2023-08-04 00:51:43 -07:00
Konstantin Varlamov
1cf970db4e [libc++][print] Make <print> tests require file system support.
`print` functions require `FILE` and `stdout` to be available and cause
compilation errors on platforms that don't support the file system.

Differential Revision: https://reviews.llvm.org/D156585
2023-08-04 00:23:49 -07:00
Konstantin Varlamov
000d2b8582 [libc++][hardening][NFC] Rework the Lit feature for detecting the hardening mode.
Make it a multichoice string to closer mirror the CMake variable. This
allows writing `UNSUPPORTED: libcpp-hardening-mode=unchecked` rather
than `UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode`.

Differential Revision: https://reviews.llvm.org/D155906
2023-08-04 00:21:55 -07:00
Nikolas Klauser
b63ac56ac4 [libc++] Update clang-tidy configuration for the tests
This is to avoid clang-tidy complaining all over the tests that the naming is wrong.
2023-08-03 09:40:48 -07:00
Nikolas Klauser
ae381cf9f2 [libc++] Fix PSTL status 2023-08-03 09:32:54 -07:00
Nikolas Klauser
dcdcc7c804 [libc++][NFC] Replace typedefs with using in the math headers
Reviewed By: #libc, Mordante, ldionne

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155382
2023-08-03 08:51:50 -07:00
Nikolas Klauser
f3589d25fe [libc++][NFC] Refactor the enable_ifs in the math headers
Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155261
2023-08-02 10:03:32 -07:00
Mark de Wever
f0e9cd2b1c [libc++][PSTL] Adds a missing include.
This should fix an error in the Apple CI.
2023-08-02 18:10:58 +02:00
Mark de Wever
7b580d8b40 [NFC][libc++][format] Switches to from_range constructor.
Some places in the format library were identified to benefit from
basic_string's from_range constructor. At that time that constructor was
not implemented. It's implemented now so adjust the code to use this new
constructor.

Reviewed By: #libc, var-const

Differential Revision: https://reviews.llvm.org/D156022
2023-08-02 18:01:48 +02:00
Piotr Fusik
f418cb1a93 [libc++] Fix std::out_of_range thrown from basic_stringbuf::str() &&
Reviewed By: #libc, Mordante, philnik

Differential Revision: https://reviews.llvm.org/D156783
2023-08-02 16:26:51 +02:00
Nikolas Klauser
8670b53e11 [libc++] Optimize ranges::find for vector<bool>
Benchmark results:
```
----------------------------------------------------------------
Benchmark                                    old             new
----------------------------------------------------------------
bm_vector_bool_ranges_find/1             5.64 ns         6.08 ns
bm_vector_bool_ranges_find/2             16.5 ns         6.03 ns
bm_vector_bool_ranges_find/3             20.3 ns         6.07 ns
bm_vector_bool_ranges_find/4             22.2 ns         6.08 ns
bm_vector_bool_ranges_find/5             23.5 ns         6.05 ns
bm_vector_bool_ranges_find/6             24.4 ns         6.10 ns
bm_vector_bool_ranges_find/7             26.7 ns         6.10 ns
bm_vector_bool_ranges_find/8             25.0 ns         6.08 ns
bm_vector_bool_ranges_find/16            27.9 ns         6.07 ns
bm_vector_bool_ranges_find/64            44.5 ns         5.35 ns
bm_vector_bool_ranges_find/512            243 ns         25.7 ns
bm_vector_bool_ranges_find/4096          1858 ns         35.6 ns
bm_vector_bool_ranges_find/32768        15461 ns         93.5 ns
bm_vector_bool_ranges_find/262144      126462 ns          571 ns
bm_vector_bool_ranges_find/1048576     497736 ns         2272 ns
```

Reviewed By: #libc, Mordante

Spies: var-const, Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D156039
2023-08-01 10:28:25 -07:00
Mark de Wever
7ef87931dd [libc++][PSTL] Silence clang-tidy errors.
This is a quick-fix to get the CI green again, not a proper solution.
2023-08-01 17:43:46 +02:00
Martin Storsjö
9abc6d9105 [libcxx] Add release notes for Windows wide stdio stream handling
This adds notes for the change from https://reviews.llvm.org/D146398 /
fcbbd9649a.

Differential Revision: https://reviews.llvm.org/D156627
2023-08-01 09:40:03 +03:00
Nikolas Klauser
15941dd629 [libc++][PSTL] Add vectorization annotations when clang is used
Reviewed By: #libc, ldionne

Spies: wangpc, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155512
2023-07-31 18:52:03 -07:00
Nikolas Klauser
9391330293 [libc++][PSTL] Fix std::copy frontend dispatching
Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155325
2023-07-31 18:39:02 -07:00
Nikolas Klauser
0e4d812f3e [libc++][NFC] Format math headers
Reviewed By: #libc, Mordante

Spies: arichardson, Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155260
2023-07-31 17:19:49 -07:00
Nikolas Klauser
404d31196f [libc++][NFC] Remove std:: qualifications from math headers
Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155259
2023-07-31 17:19:44 -07:00
Nikolas Klauser
6553608aca [libc++] Granulaize math.h and move the functions to std::__math
Reviewed By: #libc, Mordante

Spies: Mordante, arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155258
2023-07-31 17:19:39 -07:00
Mark de Wever
bae14bcd1d [libc++][modules] Improves export validation.
Adds tests to guard against the issue solved in D156592.

Depends on D156592

Reviewed By: ChuanqiXu, #libc, philnik

Differential Revision: https://reviews.llvm.org/D156594
2023-07-31 18:38:52 +02:00
Mark de Wever
e57f6f709e [libc++][modules] Fixes exporting named declarations.
@ChuanqiXu noticed std::atomic was not properly exported in the std module.
Investigation showed other named declarations were not exported either. This
fixes the issue.

Depends on D156550

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D156592
2023-07-31 18:37:45 +02:00
Mark de Wever
d7915c8aa9 [libc++][test] Fixes using modules in the test suite.
Importing modules in the test suite failed due to linker errors. This
fixes the issue and adds a minimal test to validate importing the std
module works.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D156550
2023-07-31 18:36:45 +02:00
Mark de Wever
ec39506cfc [libc++][CI] Update tools in Docker.
Switch to LLVM-18 as ToT version.
Use the latest official CMake 3.27 release.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D156593
2023-07-31 18:32:08 +02:00
Ian Anderson
165841b681 [libc++][Modules] Fix a few module related warnings
I'm getting a few -Wundefined-inline warnings, and a -Wnon-modular-include-in-module too. Fix all of those.

Reviewed By: Mordante, #libc

Differential Revision: https://reviews.llvm.org/D156508
2023-07-29 07:33:35 -07:00
Martin Storsjö
e777e44546 [libcxx] Allow linking against the MSVC static CRT
This respects the CMAKE_MSVC_RUNTIME_LIBRARY option for selecting
the right CRT to use.

Add a CI configuration that tests building this way.

Based on a patch by Andrew Ng.

The test config files end up accumulating and duplicating a fair
bit of cmake-specific logic here; if preferred, we could also add
that in `libcxx/test/CMakeLists.txt` and export a few more variables
to `cmake-bridge.cfg.in` instead.

Differential Revision: https://reviews.llvm.org/D155560
2023-07-28 23:51:28 +03:00
Andrew Ng
cd1b8be8de [libcxx] [test] Make set_windows_crt_report_mode.h more explicit
This header is included when building with a debug CRT in
MSVC/Clang-cl environments. By default, failed asserts with the
debug CRT pops up a blocking dialog box alerting the user about
the failed assert. When running more than one test in an automated
fashion, this isn't ideal.

This header tries to run initializers to set the behaviour of the
failed asserts to print a message to the console, just like the
default is in release mode.

This is previously done by setting the reporting mode to
_CRTDBG_MODE_DEBUG, which means outputting to the debugger's
output window. In some setups, this is enough for making it work,
but in others it instead can pop up a dialog asking for which
debugger to use.

Instead set the mode explicitly to _CRTDBG_MODE_FILE and set the
destination to be explicitly to stderr.

For setups where the previous code worked correctly, it doesn't make
any difference other than that a failed assert prints an additional
"abort() has been called" message that wasn't printed before.

Differential Revision: https://reviews.llvm.org/D155823
2023-07-28 23:51:27 +03:00
Martin Storsjö
e346fd8a60 [libcxx] [test] Fix running tests with Clang-cl in Debug mode
When building in debug mode, the debug version of the MSVC CRT
gets linked in. (This is the default in CMake in general. In the case
of libcxx, we manually link the CRT though - and in debug mode,
we pick the debug version of the CRT.) When building the tests,
we need to use the same version of the CRT as was used for building
the library.

Additionally; the debug CRT defaults to pop up a dialog box when
asserts fail, which blocks running tests. By including the
set_windows_crt_report_mode.h helper header, we change the assert
behaviour back to that of release mode - printing a message and
exiting immediately.

This was supported by the old libcxx test system, where support for
it was added in 7e3ee09ad2. When porting
over to the newer test setup, this mechanism wasn't brought over (and the
old test infrastructure was removed in
a48f018bb7).

Thus: In debug mode, link against the debug versions of msvcrt and
msvcprt, define _DEBUG (enabling CRT debug mode code patterns),
and include the set_windows_crt_report_mode.h header.

Based on a patch by Andrew Ng.

Linking of the debug version of the CRT can also be done by using
the new -fms-runtime-lib= Clang option. However that option was
added in Clang 16, and libcxx only requires Clang 15 for now;
therefore doing the CRT linking entirely manually for now (just as
before).

Additionally, adjust set_windows_crt_report_mode.h to avoid including
the body of the file when building in C mode or in C++03 mode.
This fixes the following two tests:
  libcxx/include_as_c.sh.cpp
  libcxx/selftest/dsl/dsl.sh.py

The former test is built in C mode. The latter tries compiling things
as C++03. Some of the vcruntime headers that we include break in
C++03 mode when MS CRT debug mode is enabled.

Differential Revision: https://reviews.llvm.org/D155554
2023-07-28 23:51:27 +03:00
Nikolas Klauser
bb65caf90a [libc++][NFC] Format __bit_reference
Reviewed By: #libc, Mordante

Spies: arichardson, Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D156038
2023-07-28 10:43:49 -07:00
Nikolas Klauser
5d976edd3f [libc++][NFC] Move libc++-specific unique_ptr test to test/libcxx 2023-07-28 10:32:33 -07:00
Nikolas Klauser
6d43651b36 [libc++][NFC] Replace _VSTD with std in __bit_reference
Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D156037
2023-07-28 08:33:51 -07:00
Nikolas Klauser
50a1f74355 [libc++][NFC] Replace typedefs with using in __bit_reference
Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D156036
2023-07-28 08:33:49 -07:00
Konstantin Varlamov
8b9a98661b [libc++][ranges] Fix ranges::to test.
- Make a test for an internal concept libc++-only;
- Make sure that `size` and `capacity` in a test container return the
  same type on all platforms.
2023-07-27 15:30:11 -07:00
Konstantin Varlamov
91876eab93 [libc++] Increase the constexpr steps limit on some bitset tests.
Prevent these tests from failing on some platforms (the number of
constexpr steps increased by https://reviews.llvm.org/D154860).
2023-07-27 15:29:37 -07:00
Nikolas Klauser
a55f93f5c1 [libc++] Replace _LIBCPP_INLINE_VISIBILITY with _LIBCPP_HIDE_FROM_ABI in __bit_reference
Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D156035
2023-07-27 14:59:34 -07:00
Nikolas Klauser
4d20cfcf4e [libc++] Simplify single-iterator __bit_iterator algorithm specializations
The single-iterator algorithms have an implementation for `false` and `true`, which are almost identical. Instead of writing two functions, this refactors the code to take the value searched for as a template parameter. This avoids a lot of code duplication and makes it easier to reason about the algorithm and their difference.

Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D156033
2023-07-27 14:57:45 -07:00
Ian Anderson
a800485a2d [libc++][Modules] Recreate the top level std clang module
lldb needs the `std` clang module to make all of libc++ available in the debugger. Make a new header to include the rest of the public headers and use to build a `std` module that just re-exports the rest of libc++.

Reviewed By: Mordante, JDevlieghere, #libc

Differential Revision: https://reviews.llvm.org/D156177
2023-07-27 14:50:18 -07:00
Mark de Wever
97d60af0d3 [libc++] Renames nasty_macro test.
The name is not really descriptive, renamed the file and improved the
diagnostics.

As a drive-by fixes one macro to generate a diagnostic.

Reviewed By: #libc, jloser, philnik

Differential Revision: https://reviews.llvm.org/D156051
2023-07-26 23:18:09 +02:00
Christian Trott
488c3db245 [libc++][mdspan] Fix uglification, categorize asserts and move tests
Fixes uglification in mdspan deduction guides, which CI
did not test for until recently. The CI modification
and mdspan testing overlapped, so mdspan landed with green
CI, and the CI modification landed too.

Make most assertions in mdspan and its helper classes
trigger during a hardened build in order to catch
out of bounds access errors.

Also moves all mdspan assertions tests from libcxx/test/std
to libcxx/test/libcxx.

Differential Revision: https://reviews.llvm.org/156181
2023-07-25 12:39:35 -06:00
Mark de Wever
e2e93f0a94 [libc++][doc] Adds LLVM 18.0.0 release nostes.
As mentioned in D155024 libc++ now has release notes for LLVM 17 and 18
to make cherry-picking easier.
2023-07-25 19:49:08 +02:00
Mark de Wever
2dafbdfd00 [libc++] Disables a test in clang-18.
This test fails on clang-18.
2023-07-25 17:12:01 +02:00
Christian Trott
fc48765781 [libc++][mdspan] Implement std::mdspan class
This implements P0009 std::mdspan ((https://wg21.link/p0009)),
a multidimensional span with customization points for
layouts and data access.

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

Differential Revision: https://reviews.llvm.org/154367
2023-07-25 06:12:56 -06:00
Tobias Hieta
ab720289ca
Bump trunk version to 18.0.0git 2023-07-25 13:58:49 +02:00
Nikolas Klauser
1e24b4d3fd [libc++] Fix template parameter naming and enforce it through readability-identifier-naming
Reviewed By: #libc, Mordante

Spies: Mordante, aheejin, libcxx-commits

Differential Revision: https://reviews.llvm.org/D156059
2023-07-24 19:54:12 -07:00
Advenam Tacet
3326feb397 [NFC] Fix release notes about ASan
Existing notes were not fully correct and were missing a detail:
- `std::vector` was annotated long time ago,
- `std::deque` annotations are new,
- now container annotations were extended to all allocators (support in ASan API exists since LLVM16).

Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D156162
2023-07-25 04:50:09 +02:00
varconst
4a652e4a99 [libc++][hardening] Categorize more assertions.
Differential Revision: https://reviews.llvm.org/D155873
2023-07-24 14:57:01 -07:00
Advenam Tacet
705fb08be1 [NFC][libc++] Update comments to reflect changes in ASan
ASan capabilities were extended, but some comments were not updated and describe old behavior. This commit updates outdated comments, which I found.
Mentioned changes are:
- All allocators in containers (`std::vector` and `std::deque`; D146815 D136765) are supported, but it's possible to turn off annotations for a specific allocator (D145628).
- Buffers don't have to be aligned (D132522).

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D156155
2023-07-24 20:32:56 +02:00
Mark de Wever
770b020610 [libc++][doc] Uses the proper paper number.
This was brought to my attention in
88622aabf1 (r122279717)
2023-07-22 16:44:59 +02:00
Mark de Wever
e2953303f4 [libc++][print] Adds stdout functions.
Implements parts of
- P2093R14 Formatted output
- P2539R4  Should the output of std::print to a terminal be
           synchronized with the underlying stream?

Depends on D150044

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D155262
2023-07-22 11:28:17 +02:00
varconst
66bd177a77 [libc++][hardening] Don't trigger uncategorized assertions in the hardened mode.
The hardened mode is intended to only include security-critical,
relatively low-overhead checks that are intended to be usable in
production. By default, assertions are excluded from this mode.

Differential Revision: https://reviews.llvm.org/D155866
2023-07-20 22:50:52 -07:00