10737 Commits

Author SHA1 Message Date
Mark de Wever
4ec6595d6e [libc++][doc] Marks LLVM-17 release notes as final.
Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D158340

(cherry picked from commit 71a7192d6927b422c224f5d231300774cb02348a)
2023-08-21 10:06:54 +02:00
Louis Dionne
271731ed70 [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

(cherry picked from commit 760261a3daf98882ccbd177e3133fb4a058f47ad)
2023-08-21 10:01:22 +02:00
Piotr Fusik
db0bf3b664 [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

(cherry picked from commit 090996f4a1186b1522e1225b6779d74ce9da250c)
2023-08-21 10:00:40 +02:00
Konstantin Varlamov
d489df7cfb [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

(cherry picked from commit 1d340250a894b6ec956e2145b2fc7babbf83e61b)
2023-08-21 09:51:54 +02:00
Mark de Wever
147b83573a [libc++][doc] Updates format related release notes.
As suggested by @ldionne.

Reviewed By: ldionne, #libc, avogelsgesang

Differential Revision: https://reviews.llvm.org/D156030

(cherry picked from commit cf83cfb3a569632c0049f11d0f56b851aaf21393)
2023-08-10 09:06:28 +02:00
Nikolas Klauser
6bff1eb9b0 [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

(cherry picked from commit 3537338d1ab9b6da4b58499877953deb81c59e5e)
2023-08-09 08:58:13 +02:00
Louis Dionne
d93ba81b55 [libc++] Deflake the Clang Modules CI job
This re-introduces the workaround that had been introduced in d7ca140c0122
and then removed in 0c0628c92c0d, since it seems like it is needed after all.

Differential Revision: https://reviews.llvm.org/D157319

(cherry picked from commit d2a61db072e90ca15a8e5bc053aab878af5cb92a)
2023-08-09 08:57:05 +02:00
Mark de Wever
edc0ee3cca [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

(cherry picked from commit e57f6f709ed2ebef7852bebb47baaf202962b4ee)
2023-08-08 12:47:27 +02:00
Konstantin Varlamov
9a53f9cfb9 [libc++][print] Mark some more <print> tests as requiring a file system.
A follow-up to https://reviews.llvm.org/D156585.

(cherry picked from commit e6b2e1b88248c1f5b34fde4e51aaeb99f849b580)
2023-08-08 09:23:59 +02:00
Konstantin Varlamov
1d07708c18 [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

(cherry picked from commit 1cf970db4e5499f6b38d9c6644935a78d758802c)
2023-08-07 09:04:34 +02:00
Christian Trott
219cef0881 [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

(cherry picked from commit 0f4d7d81c9d08512a3871596fa2a14b737233c80)
2023-08-07 09:04:26 +02:00
Piotr Fusik
1f7ff62d05 [libc++] Fix std::out_of_range thrown from basic_stringbuf::str() &&
Reviewed By: #libc, Mordante, philnik

Differential Revision: https://reviews.llvm.org/D156783

(cherry picked from commit f418cb1a9367d85c7c9b1aa93dc3fa60c8ef9849)
2023-08-03 09:01:33 +02:00
Martin Storsjö
e5f9e1628d [libcxx] Add release notes for Windows wide stdio stream handling
This adds notes for the change from https://reviews.llvm.org/D146398 /
fcbbd9649ac165aaf7fc7d60b8fef3b23755179a.

Differential Revision: https://reviews.llvm.org/D156627

(cherry picked from commit 9abc6d9105ca625ee2a03c0ec96a77d9575ca34f)
2023-08-02 09:09:46 +02:00
Ian Anderson
fa79d2b364 [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

(cherry picked from commit 165841b681c146ae1e013a0aa4d69ef7c7c20fe2)
2023-07-31 09:15:42 +02:00
Ian Anderson
3fbec448b8 [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

(cherry picked from commit a800485a2deda0807cb9dc212b7d42ac916055fd)
2023-07-28 09:08:39 +02:00
Christian Trott
9957225e7d [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-26 19:30:43 +02:00
Christian Trott
ab863b3e73 [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-26 19:30:43 +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
varconst
c3648f37d0 [libc++][ranges] Implement ranges::to.
Differential Revision: https://reviews.llvm.org/D142335
2023-07-20 22:48:18 -07:00
Konstantin Varlamov
e52f0e7746 [libc++][hardening][NFC] Rename HardenedMode.rst to Hardening.rst.
This addresses a comment from https://reviews.llvm.org/D154997.
2023-07-20 17:41:37 -07:00
Nikolas Klauser
37e5baf318 [libc++][PSTL] Implement std::sort
Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits, mgrang

Differential Revision: https://reviews.llvm.org/D152860
2023-07-20 14:45:36 -07:00
Louis Dionne
503f2ee4a8 [libc++] Make sure we use the libdispatch backend on Apple platforms
The Apple.cmake cache wasn't set up properly, so we wouldn't enable
the libdispatch backend by default on Apple platforms. This patch
fixes the issue and adds a test.

We also need to make various drive-by fixes:
- Drop the usage of std::vector in libdispatch.h to avoid changing
  the transitive includes only on Apple platforms.
- Fix includes
- Use __construct at since construct_at is unavailable in C++17
- Get rid of the (unused) __get_memory_resource function since that
  adds a back-deployment requirement and we don't use it right now.
- Fix bugs in the chunking logic around boundary conditions.

Differential Revision: https://reviews.llvm.org/D155649
2023-07-20 15:53:27 -04:00
Ian Anderson
571178a21a [libc++][Modules] Make top level modules for all C++ headers with OS/clang versions
The headers that include_next compiler and OS headers need to be in different top level modules in order to avoid module cycles. e.g. libc++'s stdlib.h will #include_next stdlib.h from the compiler and then the C library. Either of those are likely to include stddef.h, which will come back up to the libc++ module map and create a module cycle. Putting stdlib.h and stddef.h (and the rest of the C standard library headers) in top level modules resolves this by letting the order go cxx_stdlib_h -> os_stdlib_h -> cxx_stddef_h -> os_stddef_h.

All of those headers' dependencies then need to be moved into top level modules themselves to avoid module cycles between the new top level level cstd modules. This starts to get complicated, as the libc++ C headers, by standard, have to include many of the C++ headers, which include the private detail headers, which are intertwined. e.g. some `__algorithm` headers include `__memory` headers and vice versa.

Make top level modules for all of the libc++ headers to easily guarantee that the modules aren't cyclic.

Add enough module exports to fix `check-cxx` and `run-buildbot generic-modules`.

`__stop_token/intrusive_shared_ptr.h` uses `__atomic/atomic.h` but has no include path to it. Add that include.
`math.h` absorbs `bits/atomic_wide_counter.h` on some platforms that don't have modules, work around that by including `math.h` in `__threading_support`.
<mutex> doesn't actually require threads, there are a few pieces like once_flag that work without threads. Remove the requirement from its module.
AIX is no longer able to support modular builds.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D144322
2023-07-20 12:49:20 -07:00
Louis Dionne
f9bd459785 [libc++][NFC] Fix synopsis comments in cout tests 2023-07-20 14:13:21 -04:00
varconst
4122db1fbd [libc++][hardening] Categorize most assertions inside the container classes.
This introduces:
- `_LIBCPP_ASSERT_VALID_INPUT_RANGE`;
- `_LIBCPP_ASSERT_VALID_CONTAINER_ACCESS`;
- `_LIBCPP_ASSERT_VALID_ITERATOR_ACCESS`;
- `_LIBCPP_ASSERT_VALID_ALLOCATOR`;
- `_LIBCPP_ASSERT_INTERNAL`.

Differential Revision: https://reviews.llvm.org/D155349
2023-07-20 10:14:43 -07:00
Mark de Wever
805ce9a696 [libc++][print] Disables tests with (hw)asan.
Next to sanitizer-aarch64-linux-bootstrap-msan it appears asan and
hwasan are broken on aarch64. To unbreak the CI disable these two
sanitizer checks too.

The breakage was introduced by D150044.
2023-07-20 18:26:25 +02:00
yrong
a2160dd34d [libc++][ranges] Implement P2474R2(views::repeat).
- Implement https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2474r2.html
- Implement LWG3875(https://cplusplus.github.io/LWG/issue3875).

Depends on D151629

Reviewed By: #libc, Mordante, philnik, var-const

Differential Revision: https://reviews.llvm.org/D141699
2023-07-20 20:03:01 +08:00
Advenam Tacet
0a35ac6c2e [ASan][libc++] Annotating std::deque with all allocators
This patch is part of our efforts to support container annotations with (almost) every allocator.
Annotating std::deque with default allocator is implemented in D132092.

Support in ASan API exests since rG1c5ad6d2c01294a0decde43a88e9c27d7437d157.

The motivation for a research and those changes was a bug, found by Trail of Bits, in a real code where an out-of-bounds read could happen as two strings were compared via a `std::equals` function that took `iter1_begin`, `iter1_end`, `iter2_begin` iterators (with a custom comparison function).
When object `iter1` was longer than `iter2`, read out-of-bounds on `iter2` could happen. Container sanitization would detect it.

If you have any questions, please email:
- advenam.tacet@trailofbits.com
- disconnect3d@trailofbits.com

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D146815
2023-07-20 10:17:26 +02:00
Edoardo Sanguineti
d16115ddfc [libc++] Fix tests for the runtime assertions in <barrier>
As @ldionne pointed out to me in a newer revision, there is a //REQUIRE comment in both files edited by this patch that prevents the test to run on some platforms where it should actually run.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D155755
2023-07-20 08:15:02 +00:00
Haowei Wu
310255abef [libcxx] Fix copy_move.pass test
When LLVM is built under MSVC and libcxx ABI is set to 2, the
'copy_move.pass' test will unexpectedly pass. This patch mitigate
this issue by setting this test will only expecting FAIL when libcxx
ABI version is set to 1.

This is a re-land of be9f55f4fff47badcdca17be5bcc0a4a15894739

Differential Revision: https://reviews.llvm.org/D155760
Fixes: https://github.com/llvm/llvm-project/issues/63442
2023-07-19 16:52:10 -07:00
Louis Dionne
b9a599cfe2 [libc++] Revert "[libcxx] Fix copy_move.pass test"
This reverts commit be9f55f4fff47badcdca17be5bcc0a4a15894739.

The commit was both not approved by the libc++ review group, and also
the only change it contained was incorrect.
2023-07-19 19:10:27 -04:00
Haowei Wu
be9f55f4ff [libcxx] Fix copy_move.pass test
When LLVM is built under MSVC and libcxx ABI is set to 2, the
'copy_move.pass' test will unexpectedly pass. This patch mitigate this
issue by setting this test will only expecting FAIL when libcxx ABI
version is set to 1.

Differential Revision: https://reviews.llvm.org/D155760
Fixes: https://github.com/llvm/llvm-project/issues/63442
2023-07-19 15:51:27 -07:00
Louis Dionne
dc37d5ec80 [libc++] Temporarily disable back-deployment testing on arm64 until we figure out ongoing issues 2023-07-19 17:58:33 -04:00
Louis Dionne
09705e67c1 [libc++][NFC] Fix annoying line break in test synopsis comment 2023-07-19 17:39:27 -04:00
Edoardo Sanguineti
42a024fad9 [libc++] Add basic runtime assertions to <semaphore>
Adding assertions will aid users that have bugs or logic mistakes in
their code to receive error messages when debugging.

Differential Revision: https://reviews.llvm.org/D155399
2023-07-19 17:29:59 -04:00
Mark de Wever
60647e6a29 [libc++][print] Disables tests with msan.
These tests break with msan on the sanitizer-aarch64-linux-bootstrap-msan
builder. Note the x86_64 builder is not affected. To unbreak the CI
temporary disable the tests completely with msan.

The breakage was introduced by D150044.
2023-07-19 20:59:44 +02:00
Piotr Fusik
8ecb959164 [libc++] Work around dynamic linking of stringbuf::str() on Windows
https://github.com/llvm/llvm-project/issues/40363 caused the C++20
`str() const &` and `str() &&` to be dllimport'ed despite _LIBCPP_HIDE_FROM_ABI.
This is a temporary solution until #40363 is fixed.

Reviewed By: #libc, hans, ldionne, Mordante

Differential Revision: https://reviews.llvm.org/D155185
2023-07-19 17:13:34 +02:00
Martin Storsjö
7506cb3c92 [libcxx] Link to fewer MSVC CRT libraries
The library msvcrt.lib pulls in ucrt.lib and vcruntime.lib anyway,
there's no need to manually link against the individual dependencies.

This matches how the tests link against libraries - they only link
against msvcrt and msvcprt, not directly against ucrt and vcruntime.

Differential Revision: https://reviews.llvm.org/D155555
2023-07-19 11:31:53 +03:00
Andrew Ng
f9e54a5c0f [libcxx] [test] Remove a stray double space from a test config. NFC.
Differential Revision: https://reviews.llvm.org/D155553
2023-07-19 11:31:52 +03:00
Mark de Wever
1cad87c07a [libc++][test] Fixes transitives includes. 2023-07-18 22:21:10 +02:00
Mark de Wever
7941e5df76 [libc++][print] Fixes tests.
The exception message improvements for `<format>` were not applied to
print. The issue has been reported by Ian Anderson.
2023-07-18 21:49:26 +02:00
Mark de Wever
b9f3d241f4 [libc++][format] Fixes times before epoch.
The number of days should be rounded down, for both positive and
negative times since epoch. The original code truncated, which is
correct for positive values, but wrong for negative values.

Depends on D138826

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D154865
2023-07-18 21:17:11 +02:00
Mark de Wever
402eb2ef09 [libc++][format] Improves diagnostics.
Improves both the compile-time and run-time errors.
At compile-time it does a bit more work to get more specific errors.
This could be done at run-time too, but that has a performance penalty.
Since it's expected most use-cases use format* instead of vformat* the
compile-time errors are more common.

For example when using

  std::format_to("{:-c}", 42);

Before compile output would contain

  std::__throw_format_error("The format-spec should consume the input or end with a '}'");

Now it contains

  std::__throw_format_error("The format specifier does not allow the sign option");

Given a better indication the sign option is not allowed. Note the
output is still not user-friendly; C++ doesn't have good facilities to
generate nice messages from the library.

In general all messages have been reviewed and improved, using a more
consistent style and using less terms used in the standard. For example

  format-spec -> format specifier
  arg-id -> argument index

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D152624
2023-07-18 21:11:12 +02:00
Mark de Wever
a0ffeccc70 [libc++][format] Improves run-time diagnostics.
After parsing a std-format-spec it's validated, depending on the type used some
format options are not allowed. This improves the error messages in the
exceptions thrown upon failure.

Depends on D155364

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D155366
2023-07-18 21:01:52 +02:00