summaryrefslogtreecommitdiff
path: root/libcxx/include/string.h
AgeCommit message (Collapse)Author
2024-12-21[libc++][C++03] Use `__cxx03/` headers in C++03 mode (#109002)Nikolas Klauser
This patch implements the forwarding to frozen C++03 headers as discussed in https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc. In the RFC, we initially proposed selecting the right headers from the Clang driver, however consensus seemed to steer towards handling this in the library itself. This patch implements that direction. At a high level, the changes basically amount to making each public header look like this: ``` // inside <vector> #ifdef _LIBCPP_CXX03_LANG # include <__cxx03/vector> #else // normal <vector> content #endif ``` In most cases, public headers are simple umbrella headers so there isn't much code in the #else branch. In other cases, the #else branch contains the actual implementation of the header.
2024-12-10[libc++] Add #if 0 block to all the top-level headers (#119234)Nikolas Klauser
Including The frozen C++03 headers results in a lot of formatting changes in the main headers, so this splits these changes into a separate commit instead. This is part of https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc.
2023-12-18[libc++] Format the code base (#74334)Louis Dionne
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-05-05[libc++] Remove Solaris related codeLouis Dionne
This was contributed ~10 years ago, but we don't officially support it and I am not aware of any bot testing it, so this has likely rotten to the point where it is unusable. Differential Revision: https://reviews.llvm.org/D138680
2022-11-25[libc++] Use builtins when redeclaring <string.h> functionsLouis Dionne
When we define the const-correct overloads of <string.h> functions in libc++ itself, use builtins whenever possible. This avoids depending on the presence of these functions in the C library headers. Also, as a fly-by, improve the tests for these functions since we basically didn't check anything but their signature. We could have used the wrong builtin (as long as the signature matched) without ever noticing, which was quite scary. Differential Revision: https://reviews.llvm.org/D138684
2022-11-17[libc++] Only include_next C library headers when they existLouis Dionne
Some platforms don't provide all C library headers. In practice, libc++ only requires a few C library headers to exist, and only a few functions on those headers. Missing functions that libc++ doesn't need for its own implementation are handled properly by the using_if_exists attribute, however a missing header is currently a hard error when we try to do #include_next. This patch should make libc++ more flexible on platforms that do not provide C headers that libc++ doesn't actually require for its own implementation. The only downside is that it may move some errors from the #include_next point to later in the compilation if we actually try to use something that isn't provided, which could be somewhat confusing. However, these errors should be caught by folks trying to port libc++ over to a new platform (when running the libc++ test suite), not by end users. NOTE: This is a reapplicaton of 226409, which was reverted in 674729813 because it broke the build. The issue has now been fixed with https://reviews.llvm.org/D138062. Differential Revision: https://reviews.llvm.org/D136683
2022-11-15Revert "[libc++] Only include_next C library headers when they exist"Nico Weber
This reverts commit 226409c62879bf5ff9928cd23a4255cd7c614fe0. Breaks check-clang on mac, see comments on https://reviews.llvm.org/D136683
2022-11-15[libc++] Only include_next C library headers when they existLouis Dionne
Some platforms don't provide all C library headers. In practice, libc++ only requires a few C library headers to exist, and only a few functions on those headers. Missing functions that libc++ doesn't need for its own implementation are handled properly by the using_if_exists attribute, however a missing header is currently a hard error when we try to do #include_next. This patch should make libc++ more flexible on platforms that do not provide C headers that libc++ doesn't actually require for its own implementation. The only downside is that it may move some errors from the #include_next point to later in the compilation if we actually try to use something that isn't provided, which could be somewhat confusing. However, these errors should be caught by folks trying to port libc++ over to a new platform (when running the libc++ test suite), not by end users. Differential Revision: https://reviews.llvm.org/D136683
2022-02-04[libc++] Normalize all our '#pragma GCC system_header', and regression-test.Arthur O'Dwyer
Now we'll notice if a header forgets to include this magic phrase. Differential Revision: https://reviews.llvm.org/D118800
2021-11-17[runtimes][NFC] Remove filenames at the top of the license noticeLouis Dionne
We've stopped doing it in libc++ for a while now because these names would end up rotting as we move things around and copy/paste stuff. This cleans up all the existing files so as to stop the spreading as people copy-paste headers around.
2021-04-20[libc++] NFC: Normalize `#endif //` comment indentationLouis Dionne
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2016-02-11Instead of asking glibc to provide correct C++ signatures for <string.h>Richard Smith
functions, ask it whether it did provide them after the fact. Some versions of glibc fail to compile if you make this request and don't also claim to be at least GCC 4.3. llvm-svn: 260622
2016-02-11Work around regression in glibc 2.22: request that glibc provides the correctRichard Smith
prototypes for <string.h> functions that are converted into overload sets in C++. This matches the existing workaround in <wchar.h>. llvm-svn: 260570
2016-02-10Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr fromRichard Smith
<string.h> and wcschr, wcspbrk, wcsrchr, wmemchr, and wcsstr from <wchar.h> to provide a const-correct overload set even when the underlying C library does not. This change adds a new macro, _LIBCPP_PREFERRED_OVERLOAD, which (if defined) specifies that a given overload is a better match than an otherwise equally good function declaration without the overload. This is implemented in modern versions of Clang via __attribute__((enable_if)), and not elsewhere. We use this new macro to define overloads in the global namespace for these functions that displace the overloads provided by the C library, unless we believe the C library is already providing the correct signatures. llvm-svn: 260337
2015-10-29Revert r249929 ("Split <string.h> out of <cstring>").Richard Smith
This change caused problems when building code like povray that: a) uses 'using namespace std;' b) is built on an environment where the C library provides the "wrong" (non-const-correct) interface for the str* functions c) makes an unqualified call to one of those str* functions A patch is out for review to add a facility to fix this (and to give the correct signatures for these functions whenever possible, even when the C library does not do so). This revert is expected to be temporary. llvm-svn: 251665
2015-10-10Split <string.h> out of <cstring>.Richard Smith
Also fix the overload set for the five functions whose signatures change in the case where we can fix it. This is already covered by existing tests for the affected systems. llvm-svn: 249929