aboutsummaryrefslogtreecommitdiff
path: root/libcxx
AgeCommit message (Collapse)AuthorFilesLines
2023-07-25Bump trunk version to 18.0.0gitTobias Hieta1-1/+1
2023-07-24[libc++] Fix template parameter naming and enforce it through ↵Nikolas Klauser20-139/+148
readability-identifier-naming Reviewed By: #libc, Mordante Spies: Mordante, aheejin, libcxx-commits Differential Revision: https://reviews.llvm.org/D156059
2023-07-25[NFC] Fix release notes about ASanAdvenam Tacet1-5/+6
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-24[libc++][hardening] Categorize more assertions.varconst7-49/+61
Differential Revision: https://reviews.llvm.org/D155873
2023-07-24[NFC][libc++] Update comments to reflect changes in ASanAdvenam Tacet2-4/+12
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-22[libc++][doc] Uses the proper paper number.Mark de Wever2-2/+2
This was brought to my attention in https://github.com/llvm/llvm-project/commit/88622aabf10764cc32d546f448076d25b13e94cd#r122279717
2023-07-22[libc++][print] Adds stdout functions.Mark de Wever8-4/+218
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-20[libc++][hardening] Don't trigger uncategorized assertions in the hardened mode.varconst53-57/+57
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[libc++][ranges] Implement `ranges::to`.varconst32-283/+1645
Differential Revision: https://reviews.llvm.org/D142335
2023-07-20[libc++][hardening][NFC] Rename `HardenedMode.rst` to `Hardening.rst`.Konstantin Varlamov3-4/+4
This addresses a comment from https://reviews.llvm.org/D154997.
2023-07-20[libc++][PSTL] Implement std::sortNikolas Klauser8-1/+205
Reviewed By: #libc, ldionne Spies: ldionne, libcxx-commits, mgrang Differential Revision: https://reviews.llvm.org/D152860
2023-07-20[libc++] Make sure we use the libdispatch backend on Apple platformsLouis Dionne5-16/+51
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[libc++][Modules] Make top level modules for all C++ headers with OS/clang ↵Ian Anderson26-2136/+2037
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[libc++][NFC] Fix synopsis comments in cout testsLouis Dionne13-13/+13
2023-07-20[libc++][hardening] Categorize most assertions inside the container classes.varconst17-194/+233
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[libc++][print] Disables tests with (hw)asan.Mark de Wever2-2/+2
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[libc++][ranges] Implement P2474R2(`views::repeat`).yrong39-6/+1692
- 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[ASan][libc++] Annotating std::deque with all allocatorsAdvenam Tacet3-5/+93
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[libc++] Fix tests for the runtime assertions in <barrier>Edoardo Sanguineti2-6/+4
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-19[libcxx] Fix copy_move.pass testHaowei Wu1-1/+1
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[libc++] Revert "[libcxx] Fix copy_move.pass test"Louis Dionne1-1/+1
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[libcxx] Fix copy_move.pass testHaowei Wu1-1/+1
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[libc++] Temporarily disable back-deployment testing on arm64 until we ↵Louis Dionne1-14/+16
figure out ongoing issues
2023-07-19[libc++][NFC] Fix annoying line break in test synopsis commentLouis Dionne1-2/+1
2023-07-19[libc++] Add basic runtime assertions to <semaphore>Edoardo Sanguineti4-6/+121
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[libc++][print] Disables tests with msan.Mark de Wever2-0/+10
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[libc++] Work around dynamic linking of stringbuf::str() on WindowsPiotr Fusik1-8/+16
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[libcxx] Link to fewer MSVC CRT librariesMartin Storsjö1-2/+0
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[libcxx] [test] Remove a stray double space from a test config. NFC.Andrew Ng1-1/+1
Differential Revision: https://reviews.llvm.org/D155553
2023-07-18[libc++][test] Fixes transitives includes.Mark de Wever7-7/+0
2023-07-18[libc++][print] Fixes tests.Mark de Wever1-4/+4
The exception message improvements for `<format>` were not applied to print. The issue has been reported by Ian Anderson.
2023-07-18[libc++][format] Fixes times before epoch.Mark de Wever4-1/+62
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[libc++][format] Improves diagnostics.Mark de Wever37-1356/+1449
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[libc++][format] Improves run-time diagnostics.Mark de Wever13-214/+318
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[libc++][format] Improves compile-time diagnostics.Mark de Wever1-12/+50
Then a std-format-spec option is invalid for a type the compile-time validation will detect its usage and issue a diagnostic. Before it validated after parsing the entire std-format-spec, which meant the diagnostic was less precise. It would be possible to do this validation run-time but that has a performance overhead. When using the format family of functions, this would be unneeded overhead; the validation was done at run-time. For the vformat family it would give better diagnostics. To avoid paying what you don't use, it has been decided to aim for the better performance. It's more likely users will use the format family of functions. Depends on D155264 Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D155364
2023-07-18[NFC][libc++][format] Generalizes bracket parsing.Mark de Wever3-45/+50
Both the tuple formatter and range formatter parse a bracket. Instead of implementing this twice do it in the generic parser. This is preparation to improve the diagnostics in the format library. Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D155264
2023-07-18[libc++][print] Adds FILE functions.Mark de Wever32-14/+1533
Drive-by fix to make sure the __retarget_buffer works correctly whan using a hint of 1. This was discovered in one of the new tests. Drive-by fixes __retarget_buffer when initialized with size 1. Implements parts of - P2093R14 Formatted output - P2539R4 Should the output of std::print to a terminal be synchronized with the underlying stream? Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D150044
2023-07-18[libc++] Encode the version in the ReleaseNotes fileLouis Dionne4-3/+66
This way, we don't need to remove the contents of the ReleaseNotes file after the branch. This should make it much easier and natural to cherry-pick changes onto the release branch. Typically, we need two patches for those. First, we need the code changes against `main`, and then we need a patch that updates the release notes on the just-created branch. By versioning the release notes, it becomes easy to author a change against `main` that targets a just-branched LLVM release by simply adding it to the release notes for the right version. This has been a pain point in previous releases. Differential Revision: https://reviews.llvm.org/D155024
2023-07-18[libc++][LWG 2996] Implement c++20 shared_ptr rvalue overloads.pateldeev7-14/+123
Implement c++20 `shared_ptr` rvalue overloads for aliasing constructor and pointer casts. See https://cplusplus.github.io/LWG/issue2996 Commit from "patedeev" <dkp10000@gmail.com> Reviewed By: philnik, #libc, ldionne, pateldeev Differential Revision: https://reviews.llvm.org/D135548
2023-07-18[libc++][ranges] Implement the changes to node-based containers from P1206 ↵varconst55-307/+4664
(`ranges::to`): - add the `from_range_t` constructors and the related deduction guides; - add the `insert_range`/`assign_range`/etc. member functions. (Note: this patch is split from https://reviews.llvm.org/D142335) Differential Revision: https://reviews.llvm.org/D149830
2023-07-18[libc++][chrono] Fixes month inc and dec operations.Mark de Wever6-128/+135
The operator++, operator++(int), operator--, and operator--(int) need to change the month to a valid value. The wording is specified in terms of operator+(const month& x, const months& y) noexcept; which has the correct behavior. The aforementioned operators instead used ++/-- on the internal value direction, resulting in incorrect behaviour. As a drive-by improve the unit tests: - use the typical constexpr test method - test whether the month is valid after the operations - format the tests Fixes: https://llvm.org/PR63912 Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D155504
2023-07-17[libc++] Remove broken self test for the libc++ Lit formatLouis Dionne1-11/+0
The empty.sh.cpp test never tested what it was intended to test, because it did contain an unexpected RUN: command. This was discovered in https://reviews.llvm.org/D154987 while trying to land an unrelated change. Since there is no reliable way to test what I was trying to test from the libc++ test suite, just remove the test.
2023-07-17[libc++] Use _LIBCPP_VERBOSE_ABORT in a few remaining __throw_FOO functionsLouis Dionne12-46/+11
This provides better error messages when the program terminates due to an exception being thrown in -fno-exceptions mode. Those seem to have been missed in https://reviews.llvm.org/D141222. Differential Revision: https://reviews.llvm.org/D154995
2023-07-17[libc++][NFC] Remove unused macro definitionNikolas Klauser1-3/+0
2023-07-17[libc++] Move _LIBCPP_NO_THREAD_SAFETY_ANALYSIS to __configLouis Dionne2-6/+6
This makes __threading_support contain nothing but the base threading API provided by the system. Differential Revision: https://reviews.llvm.org/D155458
2023-07-17[libc++][doc] Updates the release notes.Mark de Wever3-7/+39
This is a preparation for the upcoming LLVM 17 release. Reviewed By: ldionne, jloser, H-G-Hristov, #libc Differential Revision: https://reviews.llvm.org/D154874
2023-07-17[libc++][format] Fixes an off by one error.Mark de Wever2-3/+400
The post-condition on the functions is that the buffer is not full. This post-conditon is used as pre-condition of the push_back function. When a copy, fill, of transform function exactly fit in the buffer this post-condition was validated. Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D155397
2023-07-17[libc++][NFC] Remove unnecessary declarations in __thread/id.hLouis Dionne1-8/+0
2023-07-17[libc++][NFC] clang-format __thread/id.h since it just got movedLouis Dionne2-63/+44
2023-07-17[libc++] Remove internal "build-with-external-thread-library" configurationLouis Dionne6-87/+1
Our threading support layer is currently a huge mess. There are too many configurations with too many confusing names, and none of them are tested in the usual CI. Here's a list of names related to these configurations: LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL This patch cleans this up by removing the ability to build libc++ with an "external" threading library for testing purposes, removing 4 out of 6 "names" above. That setting was meant to be used by libc++ developers, but we don't use it in-tree and it's not part of our CI. I know the ability to use an external threading API is used by some folks out-of-tree, and this patch doesn't change that. This only changes the way they will have to test their external threading support. After this patch, the intent would be for them to set `-DLIBCXX_HAS_EXTERNAL_THREAD_API=ON` when building the library, and to provide their usual `<__external_threading>` header when they are testing the library. This can be done easily now that we support custom lit configuration files in test suites. The motivation for this patch is that our threading support layer is basically unmaintainable -- anything beyond adding a new "backend" in the slot designed for it requires incredible attention. The complexity added by this setting just doesn't pull its weigh considering the available alternatives. Concretely, this will also allow future patches to clean up `<__threading_support>` significantly. Differential Revision: https://reviews.llvm.org/D154466