aboutsummaryrefslogtreecommitdiff
path: root/libcxx/src
AgeCommit message (Collapse)AuthorFilesLines
2024-01-21[NFC][libc++] tab -> spaceMark de Wever1-1/+1
2024-01-21[libc++] Install modules. (#75741)Mark de Wever1-0/+5
Installs the source files of the experimental libc++ modules. These source files (.cppm) are used by the Clang to build the std and std.compat modules. The design of this patch is based on a discussing in SG-15 on 12.12.2023. (SG-15 is the ISO C++ Tooling study group): - The modules are installed at a location, that is not known to build systems and compilers. - Next to the library there will be a module manifest json file. This json file contains the information to build the module from the libraries sources. This information includes the location where the sources are installed. @ruoso supplied the specification of this json file. - If possible, the compiler has an option to give the location of the module manifest file (https://github.com/llvm/llvm-project/pull/76451). Currently there is no build system support, but it expected to be added in the future. Fixes: https://github.com/llvm/llvm-project/issues/73089
2024-01-20[libc++][hardening] Categorize assertions that produce incorrect results ↵Konstantin Varlamov2-4/+3
(#77183) Introduce a new `argument-within-domain` category that covers cases where the given arguments make it impossible to produce a correct result (or create a valid object in case of constructors). While the incorrect result doesn't create an immediate problem within the library (like e.g. a null pointer dereference would), it always indicates a logic error in user code and is highly likely to lead to a bug in the program once the value is used.
2024-01-16[libc++][print] Enables it on Apple backdeployment. (#76293)Mark de Wever1-1/+1
As suggested in #73262 this enable the stream printing on Apple backdeployment targets. This omits the check whether the file is a terminal. This is not entirely conforming, but the differences should be minor and are typically not observable. Fixes https://github.com/llvm/llvm-project/issues/75225
2024-01-11[libc++] Re-export libc++abi symbols on Apple platforms when using ↵a-n-n-a-l-e-e1-1/+1
system-libcxxabi (#77218) When using LIBCXX_CXX_ABI=system-libcxxabi on Apple platforms, we would not re-export the libc++abi symbols unlike when LIBCXX_CXX_ABI=libcxxabi. This was caused by overly strict string matching in CMake. https://github.com/NixOS/nixpkgs/issues/269548
2024-01-07Reapply "[libc++][streams] P1759R6: Native handles and file streams" (#77190)Hristo Hristov2-0/+38
Fixes build on Windows in C++26 mode. Reverted in: https://github.com/llvm/llvm-project/commit/40c07b559aa6ab4bac074c943967d3207bc07ae0 Original PR: https://github.com/llvm/llvm-project/pull/76632 --------- Co-authored-by: Zingam <zingam@outlook.com>
2024-01-05Revert "[libc++][streams] P1759R6: Native handles and file streams (#76632)"Haowei Wu2-38/+0
This reverts commit 255f95a40377677dd762df5a1aa65bcbb4f75c79, which contains a breaking libcxx test on Windows when using C++26
2024-01-05[libc++][hardening] Categorize more assertions. (#75918)Konstantin Varlamov7-18/+18
Also introduce `_LIBCPP_ASSERT_PEDANTIC` for assertions violating which results in a no-op or other benign behavior, but which may nevertheless indicate a bug in the invoking code.
2024-01-05[libc++][streams] P1759R6: Native handles and file streams (#76632)Hristo Hristov2-0/+38
Implements: `P1759R6` https://wg21.link/P1759R6 - https://eel.is/c++draft/filebuf - https://eel.is/c++draft/ifstream - https://eel.is/c++draft/ofstream - https://eel.is/c++draft/fstream --------- Co-authored-by: Zingam <zingam@outlook.com>
2023-12-20[libc++][hardening] Categorize more 'valid-element-access' checks. (#71620)Konstantin Varlamov1-1/+1
2023-12-19[libc++][print] Adds ostream overloads. (#73262)Mark de Wever3-0/+45
Finishes implementation of - P2093R14 Formatted output - P2539R4 Should the output of std::print to a terminal be synchronized with the underlying stream? Differential Revision: https://reviews.llvm.org/D156609
2023-12-18[libc++] Restore order of includes on Windows to unbreak the buildLouis Dionne1-2/+2
As reported in [1], it looks like the Windows headers are picky about the order in which they are included, and the clang-format change broke the build by reordering the headers. [1]: https://github.com/llvm/llvm-project/pull/74334#issuecomment-1861719927
2023-12-18[libc++] Format the code base (#74334)Louis Dionne67-9868/+7780
This patch runs clang-format on all of libcxx/include and libcxx/src, in accordance with the RFC discussed at [1]. Follow-up patches will format the benchmarks, the test suite and remaining parts of the code. I'm splitting this one into its own patch so the diff is a bit easier to review. This patch was generated with: find libcxx/include libcxx/src -type f \ | grep -v 'module.modulemap.in' \ | grep -v 'CMakeLists.txt' \ | grep -v 'README.txt' \ | grep -v 'libcxx.imp' \ | grep -v '__config_site.in' \ | xargs clang-format -i A Git merge driver is available in libcxx/utils/clang-format-merge-driver.sh to help resolve merge and rebase issues across these formatting changes. [1]: https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
2023-12-05[libc++] Replace uses of _VSTD:: by std:: (#74331)Louis Dionne10-77/+77
As part of the upcoming clang-formatting of libc++, this patch performs the long desired removal of the _VSTD macro. See https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all for the clang-format proposal.
2023-12-04[libc++][NFC] Add a few clang-format annotations (#74352)Louis Dionne1-0/+2
This is in preparation for clang-formatting the whole code base. These annotations are required either to avoid clang-format bugs or because the manually formatted code is significantly more readable than the clang-formatted alternative. All in all, it seems like very few annotations are required, which means that clang-format is doing a very good job in most cases.
2023-12-04[libc++] Rename _LIBCPP_INLINE_VISIBILITY to _LIBCPP_HIDE_FROM_ABI (#74095)Louis Dionne6-26/+26
In preparation for running clang-format on the whole code base, we are also removing mentions of the legacy _LIBCPP_INLINE_VISIBILITY macro in favor of the newer _LIBCPP_HIDE_FROM_ABI. We're still leaving the definition of _LIBCPP_INLINE_VISIBILITY to avoid creating needless breakage in case some older patches are checked-in with mentions of the old macro. After we branch for LLVM 18, we can do another pass to clean up remaining uses of the macro that might have gotten introduced by mistake (if any) and remove the macro itself at the same time. This is just a minor convenience to smooth out the transition as much as possible. See https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all for the clang-format proposal.
2023-11-29[libc++] Speed up classic locale (take 2) (#73533)Louis Dionne1-52/+46
Locale objects use atomic reference counting, which may be very expensive in parallel applications. The classic locale is used by default by all streams and can be very contended. But it's never destroyed, so the reference counting is also completely pointless on the classic locale. Currently ~70% of time in the parallel stringstream benchmarks is spent in locale ctor/dtor. And the execution radically slows down with more threads. Avoid reference counting on the classic locale. With this change parallel benchmarks start to scale with threads. This is a re-application of f8afc53d641c (aka PR #72112) which was reverted in 4e0c48b907f1 because it broke the sanitizer builds due to an initialization order fiasco. This issue has now been fixed by ensuring that the locale is constinit'ed. Co-authored-by: Dmitry Vyukov <dvyukov@google.com>
2023-11-28[libc++] Properly guard std::filesystem with >= C++17 (#72701)Louis Dionne2-4/+4
<filesystem> is a C++17 addition. In C++11 and C++14 modes, we actually have all the code for <filesystem> but it is hidden behind a non-inline namespace __fs so it is not accessible. Instead of doing this unusual dance, just guard the code for filesystem behind a classic C++17 check like we normally do.
2023-11-27Revert "[libc++] Speed up classic locale (#72112)"Kirill Stoimenov1-45/+52
Looks like it broke the ASAN build: https://lab.llvm.org/buildbot/#/builders/168/builds/17053/steps/9/logs/stdio This reverts commit f8afc53d641ce9d4ad8565aae9e7b5911b572a02.
2023-11-27[libc++] Fix UTF-8 decoding in codecvts (#68442)Dimitrij Mijoski1-23/+49
This patch fixes one case where the decoding member function `in()` was returning `partial` instead of `error`. Additionally, it adds large testsuite that tests all `codecvt` facets that were added in C++11 and in C++20. The testsuite covers this bug. Fixes #60177.
2023-11-27[libc++] Remove experimental pmr headers now shipped in mainline (#73172)Louis Dionne4-152/+11
Several experimental headers around std::pmr have been slated for removal for a while now. This patch actually performs the removal and cleanups from the code base.
2023-11-27[libc++] Speed up classic locale (#72112)Dmitry Vyukov1-52/+45
Locale objects use atomic reference counting, which may be very expensive in parallel applications. The classic locale is used by default by all streams and can be very contended. But it's never destroyed, so the reference counting is also completely pointless on the classic locale. Currently ~70% of time in the parallel stringstream benchmarks is spent in locale ctor/dtor. And the execution radically slows down with more threads. Avoid reference counting on the classic locale. With this change parallel benchmarks start to scale with threads. Co-authored-by: Louis Dionne <ldionne.2@gmail.com> ``` │ baseline │ optimized │ │ sec/op │ sec/op vs base │ Istream_numbers/0/threads:1 4.672µ ± 0% 4.419µ ± 0% -5.42% (p=0.000 n=30+39) Istream_numbers/0/threads:72 539.817µ ± 0% 9.842µ ± 1% -98.18% (p=0.000 n=30+40) Istream_numbers/1/threads:1 4.890µ ± 0% 4.750µ ± 0% -2.85% (p=0.000 n=30+40) Istream_numbers/1/threads:72 66.44µ ± 1% 10.14µ ± 1% -84.74% (p=0.000 n=30+40) Istream_numbers/2/threads:1 4.888µ ± 0% 4.746µ ± 0% -2.92% (p=0.000 n=30+40) Istream_numbers/2/threads:72 494.8µ ± 0% 410.2µ ± 1% -17.11% (p=0.000 n=30+40) Istream_numbers/3/threads:1 4.697µ ± 0% 4.695µ ± 5% ~ (p=0.391 n=30+37) Istream_numbers/3/threads:72 421.5µ ± 7% 421.9µ ± 9% ~ (p=0.665 n=30) Ostream_number/0/threads:1 183.0n ± 0% 141.0n ± 2% -22.95% (p=0.000 n=30) Ostream_number/0/threads:72 24196.5n ± 1% 343.5n ± 3% -98.58% (p=0.000 n=30) Ostream_number/1/threads:1 250.0n ± 0% 196.0n ± 2% -21.60% (p=0.000 n=30) Ostream_number/1/threads:72 16260.5n ± 0% 407.0n ± 2% -97.50% (p=0.000 n=30) Ostream_number/2/threads:1 254.0n ± 0% 196.0n ± 1% -22.83% (p=0.000 n=30) Ostream_number/2/threads:72 28.49µ ± 1% 18.89µ ± 5% -33.72% (p=0.000 n=30) Ostream_number/3/threads:1 185.0n ± 0% 185.0n ± 0% 0.00% (p=0.017 n=30) Ostream_number/3/threads:72 19.38µ ± 4% 19.33µ ± 5% ~ (p=0.425 n=30) ```
2023-11-24[libc++][NFC] Refactor _LIBCPP_AVAILABILITY_HAS_* macros to always be ↵philnik7771-1/+1
defined (#71002) This makes the conditionals quite a bit simpler to understand, since it avoids double negatives and makes sure we have <__availability> included. For vendors which use availability macros, it also enforces that they check when specific features are introduced and define the macro for their platform appropriately.
2023-11-23[libc++] Refactor the creation of the global and classic locales (#72581)Louis Dionne1-30/+23
The creation of the global and the classic locales was pretty twisty. This patch refactors how this is done to reduce the amount of indirections and prepare the terrain for a future where GCC implements the no_destroy attribute.
2023-11-21[libc++][hardening] Categorize all `ryu` assertions as internal (#71853)Konstantin Varlamov5-28/+28
These assertions can only be triggered by bugs in the algorithm's implementation; all user inputs should be handled gracefully.
2023-11-07[libc++][hardening] Add `_LIBCPP_ASSERT_NON_NULL` to check for null pointers ↵Konstantin Varlamov2-5/+5
(#71428)
2023-11-05[libc++] Handle threads-related .cpp files like we do all other source files ↵Louis Dionne11-118/+99
(#71100) Source files in libc++ are added to the CMake targets only if they are required by the configuration. We do this pretty consistently for all configurations like no-filesystem, no-random-device, etc. but we didn't do it for no-threads. This patch makes this consistent for no-threads, which is helpful in reducing the amount of work required to port libc++ to some platforms without threads. Indeed, with the previous approach, several threads-related source files would end up including headers that might fail to compile properly on some platforms. This issue is sidestepped entirely by making the approach for no-threads consistent with the other configurations.
2023-11-05[libc++] Guard the whole print.cpp file with _LIBCPP_WIN32API (#71122)Louis Dionne1-6/+6
The print.cpp source file is only used when building on Windows. Avoid including anything else but <__config> in the file in the case where there's nothing to compile here at all. As a drive-by change, use _LIBCPP_WIN32API consistently instead of _WIN32.
2023-11-05[libc++] Bump the C++ Standard used to compile the dylib to C++23 (#66824)Louis Dionne2-4/+6
This is necessary in order to implement some papers like P2467R1, which require using C++23 declarations in the dylib. It is a good habit to keep building the dylib with a recent standard version regardless. With this patch, we also stop strictly enforcing that the targets are built with C++23. Concretely, C++23 will soon be required in order to build the dylib, but not enforcing it strictly works around some issues like the documentation bots using an old and unsupported compiler. Since these bots do not actually build the library, not strictly enforcing the C++ Standard makes our CMake build more resilient to these kinds of situation. This is just a workaround though, the better way of going about would be to update the compiler on the documentation bot but we don't seem to have control over that.
2023-10-29[libc++] Remove a few transitive includes (#70553)philnik7771-0/+1
2023-10-18[libc++][NFC] Refactor the core logic of operator new into helper functions ↵Louis Dionne1-15/+21
(#69407) This will make it easier to implement new(nothrow) without calling the throwing version of new when exceptions are disabled. See https://llvm.org/D150610 for the full discussion.
2023-10-18[libc++][NFC] Reformat new.cpp and stdlib_new_delete.cppLouis Dionne1-213/+123
This makes it a lot easier to make wide ranging changes like I am about to do in https://llvm.org/D150610.
2023-10-06[libc++] Recategorize additional instantiations in the dylib as availability ↵Nikolas Klauser1-1/+1
macros Adding additional instantiations to the dylib isn't actually an ABI break as long as programs targeting an older dylib don't start to depend on them. Making additional instantiations a matter of availability allows us to add them without an ABI break. Reviewed By: #libc, ldionne, Mordante Spies: arichardson, ldionne, Mordante, libcxx-commits Differential Revision: https://reviews.llvm.org/D154796
2023-10-05[libc++] Make future_error constructor standard-compliantMarek Kurdej1-3/+1
This patch removes the non compliant constructor of std::future_error and adds the standards compliant constructor in C++17 instead. Note that we can't support the constructor as an extension in all standard modes because it uses delegating constructors, which require C++11. We could in theory support the constructor as an extension in C++11 and C++14 only, however I believe it is acceptable not to do that since I expect the breakage from this patch will be minimal. If it turns out that more code than we expect is broken by this, we can reconsider that decision. This was found during D99515. Differential Revision: https://reviews.llvm.org/D99567 Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-10-04[libc++] Remove dead code in legacy_debug_handler.cpp (#68155)Louis Dionne1-54/+0
We removed all traces of the legacy debug mode a while back, but we forgot to remove the actual `.cpp` file that implemented the legacy debug handler. The file is not referenced from anywhere so this is effectively a NFC.
2023-09-27[libc++] Don't add reference to system_category when exceptions disabled ↵Daniel Thornburgh1-2/+9
(#67504) This fixes a size regression in Fuchsia when building a static libc++ multilib with exceptions disabled. Referring to `system_category` in `__throw_system_error` brings in a relatively large amount of additional exception classes into the link without substantially improving the error message.
2023-09-19[libc++][NFC] Clean up std::__call_onceDaniel McIntosh1-40/+25
__call_once is large and cluttered with #ifdef preprocessor guards. This cleans it up a bit by using an exception guard instead of try-catch. Differential Revision: https://reviews.llvm.org/D112319 Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-09-15[libc++][NFC] Introduce named states in std::call_once (#66289)Louis Dionne1-9/+9
This idea is extracted from https://reviews.llvm.org/D112319. It makes the code easier to read but doesn't otherwise change any functionality.
2023-09-12[libc++] Simplify the implementation of locale::id (#65781)Louis Dionne1-29/+2
Since we use C++20 to build the dylib, we can use a lambda to do the first-time initialization instead of emulating std::bind. This should not change the behavior of the code at all, it merely simplifies it. This removes a symbol from the dylib, however that symbol was only ever used inside the dylib so it shouldn't break the ABI for anyone. I confirmed that by searching for that symbol on the ABI boundary of a large number of programs and couldn't find any references to that function.
2023-09-11[libc++] Mark static variables of locale::id as constinit (#65783)Louis Dionne1-11/+11
The dylib contains multiple global variables of type locale::id. Those can be marked as constinit to make it clear that static initialization is performed.
2023-09-10[libc++] Use inline instead of static in headers.Mark de Wever1-6/+6
This has been tested as part of D156609.
2023-09-08[libc++] Fix warnings when compiling libc++ for Windows with clang-cl /W4Colin Finck2-3/+3
Differential Revision: https://reviews.llvm.org/D96408
2023-09-08[libc++][NFC] tidy up strstreambuf::seekoff and strstreambuf::seekposDaniel McIntosh1-57/+56
Should be the same logic, but hopefully easier to read this way. Gets rid of some superfluous state variables, and uses early returns. Differential Revision: https://reviews.llvm.org/D112956
2023-09-08[libc++][NFC] Run clang-format on strstream.cppLouis Dionne1-262/+181
I'm about to land https://reviews.llvm.org/D112956 which touches many lines in that file anyway, so we might as well clang-format it first.
2023-09-06[libc++][chrono] Adds tzdb_list implementation.Mark de Wever3-0/+266
This is the first step to implement time zone support in libc++. This adds the complete tzdb_list class and a minimal tzdb class. The tzdb class only contains the version, which is used by reload_tzdb. Next to these classes it contains documentation and build system support needed for time zone support. The code depends on the IANA Time Zone Database, which should be available on the platform used or provided by the libc++ vendors. The code is labeled as experimental since there will be ABI breaks during development; the tzdb class needs to have the standard headers. Implements parts of: - P0355 Extending <chrono> to Calendars and Time Zones Addresses: - LWG3319 Properly reference specification of IANA time zone database Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D154282
2023-09-06[libc++] Remove unused include in __threading_supportLouis Dionne1-0/+2
Differential Revision: https://reviews.llvm.org/D138528
2023-09-05[libc++] Avoid destructor call for error_category singletonsChris Bowler5-43/+67
When a handle to an error_category singleton object is used during the termination phase of a program, the destruction of the error_category object may have occurred prior to execution of the current destructor or function registered with atexit, because the singleton object may have been constructed after the corresponding initialization or call to atexit. For example, the updated tests from this patch will fail if using a libc++ built using a compiler that updates the vtable of the object on destruction. This patch attempts to avoid the issue by causing the destructor to not be called in the style of ResourceInitHelper in src/experimental/memory_resource.cpp. This approach might not work if object lifetime is strictly enforced. Differential Revision: https://reviews.llvm.org/D65667 Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-08-29[libc++][hardening] Mark the remaining stray assertions as uncategorizedKonstantin Varlamov1-2/+2
This avoids enabling them unconditionally in all hardening modes. Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D158970
2023-08-29[libc++] Adds __throw_system_error overload.Mark de Wever2-14/+3
This was mention in D150044 and D154995 that this would be useful. This addresses the last review coment of D150044. Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D156019
2023-08-25[libc++] Fix GNU/Hurd buildSamuel Thibault2-2/+2
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