10749 Commits

Author SHA1 Message Date
Konstantin Varlamov
a5e5eb17fd [libc++][hardening] Remove hardening from release notes, undeprecate safe mode
This patch effectively maintains the status quo, making sure that the
safe mode keeps working the same way as before. Hardening will target
the next major release, allowing it to go through RFC and for the
implementation to stabilize and mature.

Differential Revision: https://reviews.llvm.org/D159171
2023-09-11 08:53:47 +02:00
Mark de Wever
078e20cade [libc++][format] Fixes out of bounds access.
Fixes https://llvm.org/PR65011

Reviewed By: #libc, ldionne

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

(cherry picked from commit 8930d04d5580c6a2cf04545c87387cd150cd7b46)
2023-08-31 09:00:27 +02:00
Samuel Thibault
0ec768e415 [libc++] Fix GNU/Hurd build
GNU/Hurd does have clock_gettime, it just doesn't define _POSIX_TIMERS because its support for timers is not complete.

Reviewed By: #libc, Mordante

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

(cherry picked from commit 1cfcc36812ff7857567f7c729c22ae0e2be0fb3a)
2023-08-27 10:56:20 +02:00
Lei Huang
77d7f7d769 [PowerPC] Exclude frexp(long double) on linux
PowerPC on linux currently don't have support for lowering long double for
frexp().  Removing the tests until implementation is provided.

Reviewed By: #libc, amyk, Mordante

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

(cherry picked from commit 5adac8bebcf26841c1d87227c5043af83a9ef94b)
2023-08-27 10:56:00 +02:00
Ian Anderson
2641da8e10 [libc++][Modules] locale fails to compile with clang modules when _LIBCPP_LOCALE__L_EXTENSIONS is undefined
When `__locale_dir/locale_base_api/locale_guard.h is` compiled independently, as it is when it's in its own clang module, it fails to compile due to `locale_t` being undefined. It needs to include `__locale` to get that, instead of just `clocale`.

Reviewed By: ldionne, #libc

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

(cherry picked from commit 6021c78fe55e3c4d3e073710bfe279c6a28566d4)
2023-08-27 10:55:37 +02:00
Konstantin Varlamov
4114813bf2 [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).

(cherry picked from commit 91876eab93a9f0ef29a339ed99bdb1c8ed1e85c6)
2023-08-27 10:55:30 +02:00
Konstantin Varlamov
f63cdbcc0c [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.

(cherry picked from commit 8b9a98661b780a5b50d1d6a1f822d25e0c454382)
2023-08-27 10:55:24 +02:00
Ian Anderson
0521244b24 [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

# Conflicts:
#	libcxx/utils/libcxx/header_information.py
2023-08-27 10:55:16 +02:00
Ian Anderson
5e2c5225f8 [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

# Conflicts:
#	libcxx/utils/libcxx/header_information.py
2023-08-27 10:55:16 +02:00
Ian Anderson
ae49840649 [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-27 10:55:16 +02:00
Ian Anderson
231dab0e40 [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

# Conflicts:
#	libcxx/test/libcxx/system_reserved_names.gen.py
2023-08-27 10:55:16 +02:00
Nikolas Klauser
01f7134c0e [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-27 10:55:06 +02:00
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