926 Commits

Author SHA1 Message Date
Mark de Wever
a9a6f977bb [libc++][doc] Updates the release notes.
This is a preparation for the upcoming LLVM 17 release.

Reviewed By: ldionne, philnik, avogelsgesang, jloser, #libc

Differential Revision: https://reviews.llvm.org/D141304
2023-01-13 17:46:45 +01:00
Nikolas Klauser
633927db84 [libc++] Add [[nodiscard]] extensions in <math.h>
There are quite a few functions marked `[[gnu::const]]` inside the compiler. This patch adds `[[nodiscard]]` to libc++-provided overloads of these functions to match the diagnostics produced.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D140855
2023-01-12 18:34:49 +01:00
Arthur O'Dwyer
64fc3cd55d [libc++] Hold mutex lock while notify_all is called at notify_all_at_thread_exit
Releasing the mutex before the call to notify_all is an optimization.
This optimization cannot be used here. The thread waiting on the
condition might destroy the associated resources — mutex + condition
variable — and the notifier thread will access an destroyed variable
— the condition variable. In fact, notify_all_at_thread_exit is meant
exactly to join on detached threads, and the waiting thread doesn't
expect for the notifier thread to access any further shared resources,
making this scenario very likely to happen. The waiting thread might
awake spuriously on the release of the mutex lock. The reorder is
necessary to prevent this race.

Further details can be found at https://cplusplus.github.io/LWG/issue3343.

Differential Revision: https://reviews.llvm.org/D105758
2023-01-11 17:01:21 -05:00
James Y Knight
73d94b1916 [Libcxx] Add <source_location> header.
This requires the __builtin_source_location() builtin, as implemented
by GCC and Clang.

Fixes https://github.com/llvm/llvm-project/issues/56363

Differential Revision: https://reviews.llvm.org/D120634
2023-01-11 16:01:30 -05:00
Louis Dionne
e4897c7c43 [libc++][NFC] Improve consistency in status csv files 2023-01-11 10:30:49 -05:00
Marek Kurdej
7223bcf04c [libc++] [C++20] [P0415] Constexpr for std::complex.
This patch adds constexpr to <complex> header: operators, member operators, and member functions (real, imag, norm, conj).

https://eel.is/c++draft/complex.numbers
https://wg21.link/p0415

Reviewed By: ldionne, #libc

Spies: philnik, danilaml, Quuxplusone, wmaxey, arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D79555
2023-01-08 15:46:51 +01:00
Nikolas Klauser
52bff450dd [libc++] Implement constexpr {isfinite, isinf, isnan, isnormal}
This starts implementing P0533

Reviewed By: Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D140277
2022-12-25 20:14:29 +01:00
Mark de Wever
105fef5dca [libc++][chrono] Add calendar type formatters.
Some of the calendar types have landed before, this adds the missing
set. Note this does not complete the implementation of the chrono
formatters.

This removes the `chrono` header for some transitive include in C++17
mode. This is needed to avoid inclusion cycles.

Partially implements:
- P1361 Integration of chrono with text formatting
- P2372 Fixing locale handling in chrono formatters

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D137022
2022-12-24 15:11:41 +01:00
Mark de Wever
0edc92e6e0 [libc++] LWG3738 Validates a missing precondition.
No real changes were needed, but add an assert for the pre-condition.

This implements:
- 3738 Missing preconditions for take_view constructor

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D140568
2022-12-23 17:20:57 +01:00
Mark de Wever
83c1816224 [libc++] LWG3745 noexcept for atomic_wait.
The noexcept was already implemented, this only updates the synposis and
adds tests to validate that the functions are noexcept.

This implements:
- LWG3745 std::atomic_wait and its friends lack noexcept

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D140575
2022-12-23 17:17:00 +01:00
Mark de Wever
eb6e13cb32 [libc++][format] Adds formatter for tuple and pair
Implements parts of
- P2286R8 Formatting Ranges

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D136775
2022-12-22 19:36:28 +01:00
Mark de Wever
2b6ce25a2a [libc++] Adds __cpp_lib_constexpr_algorithms to utility.
Implements:
- LWG3792 __cpp_lib_constexpr_algorithms should also be defined in <utility>

Depends on D140407

Reviewed By: #libc, philnik, ldionne

Differential Revision: https://reviews.llvm.org/D140413
2022-12-21 17:30:16 +01:00
Mark de Wever
44ea075d9c [libc++][doc] Adds Kona plenary papers and issues.
Directly marked entries with Nothing to do where applicable.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D140407
2022-12-21 17:29:02 +01:00
Igor Zhukov
c45f382a12 Implement LWG-3646 std::ranges::view_interface::size returns a signed type
Reviewed By: Mordante, philnik, #libc

Differential Revision: https://reviews.llvm.org/D139791
2022-12-16 07:14:00 +07:00
Nikolas Klauser
3ec6c997c6 [libc++] Implement P1169R4 (static operator())
Reviewed By: ldionne, huixie90, #libc

Spies: EricWF, libcxx-commits, royjacobson

Differential Revision: https://reviews.llvm.org/D135016
2022-12-15 02:18:54 +01:00
Hui Xie
e356f681f6 [libc++] Implement std::expected P0323R12
Implement `std::expected` https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p0323r12.html

Added tests

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

address comment
2022-12-14 15:43:42 +00:00
Mark de Wever
e8fdf8e31b [libc++][doc] Fixes a formating issue. 2022-12-10 15:28:15 +01:00
Konstantin Varlamov
21ca9c8d28 [libc++][ranges][NFC] Update Ranges status.
Add a link to an in-progress patch.
2022-12-09 19:32:18 -08:00
Nikolas Klauser
181cce6b69 [libc++] Implement P0339R6 (polymorphic_allocator<> as a vocabulary type)
Reviewed By: ldionne, #libc

Spies: LRFLEW, libcxx-commits, arichardson, krytarowski, jdoerfert

Differential Revision: https://reviews.llvm.org/D137739
2022-12-07 18:50:26 +01:00
Leonard Chan
96d63993dd Revert "[CMake] Use LLVM_TARGET_TRIPLE in runtimes"
This reverts commit bec8a372fc0db95852748691c0f4933044026b25.

This causes many of these errors to appear when rebuilding runtimes part
of fuchsia's toolchain:

ld.lld: error:
/usr/local/google/home/paulkirth/llvm-upstream/build/lib/x86_64-unknown-linux-gnu/libunwind.a(libunwind.cpp.o)
is incompatible with elf64-x86-64

This can be reproduced by making a complete toolchain, saving any source
file with no changes, then rerunning ninja distribution.
2022-12-05 22:20:51 +00:00
varconst
2c5a548b53 [libc++][ranges][NFC] Revamp the Ranges status page
Focus on the not-yet-implemented features: remove most details about the
already-implemented C++20 stuff, list out the major C++23 additions.

Differential Revision: https://reviews.llvm.org/D136657
2022-11-29 14:40:35 -08:00
Nikolas Klauser
65df5bf2d1 [lbc++] Implement the rest of P0600R1 (nodiscard in the library)
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D137597
2022-11-29 19:42:38 +01:00
Petr Hosek
bec8a372fc [CMake] Use LLVM_TARGET_TRIPLE in runtimes
This variable is derived from LLVM_DEFAULT_TARGET_TRIPLE by default,
but using a separate variable allows additional normalization to be
performed if needed.

Differential Revision: https://reviews.llvm.org/D137451
2022-11-29 04:08:24 +00:00
Louis Dionne
396fbe264f [libc++] Bump AppleClang compiler requirement
Per our policy, the latest released AppleClang has been 14 for a while,
so libc++ is removing support for AppleClang 13. Our CI bots have been
moved to AppleClang 14 a few weeks ago.

Differential Revision: https://reviews.llvm.org/D138685
2022-11-25 09:51:44 -05:00
Louis Dionne
08a0faf4cd [libc++] Keep char_traits<T> for arbitrary T around until LLVM 18
This is in response to failures seen after landing D138307.

Differential Revision: https://reviews.llvm.org/D138596
2022-11-24 08:22:39 -05:00
Nikolas Klauser
c418dccdbd [libc++] Remove P1908 from the status page
The paper doesn't include anything affecting the library. AFAICT there isn't even anything to do for the compiler, since it just reserved the std attribute namespace.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D138128
2022-11-24 14:10:19 +01:00
Louis Dionne
09f7554890 [libc++][NFC] Fix documentation build 2022-11-23 10:31:21 -05:00
Louis Dionne
aeecef08c3 [libc++] Remove default definition of std::char_traits
This patch removes the base template implementation for std::char_traits.
If my reading of http://eel.is/c++draft/char.traits is correct, the
Standard mandates that the library provides specializations for several
types like char and wchar_t, but not any implementation in the base
template. Indeed, such an implementation is bound to be incorrect for
most types anyways, since things like `eof()` and `int_type` will definitely
have to be customized.

Since the base template implementation should not have worked for anyone,
this shouldn't be a breaking change (I expect that anyone defining a
custom character type today will already have to provide their own
specialization of char_traits). However, since we're aware of some users
of char_traits for unsigned char and signed char, we're keeping those two
specializations around for two releases to give people some time to migrate.

Differential Revision: https://reviews.llvm.org/D138307
2022-11-23 09:51:01 -05:00
Alex Richardson
4559864897 [libc++] Fix __regex_word value when using newlib/picolibc
The ctype mask for newlib/picolibc is fully saturated, so __regex_word
has to overlap with one of the values. This commit uses the same workaround
as bionic did (uint16_t for char_class_type inside regex_traits). It
should be possible to have libc++ provide the default rune table instead,
but that will require a new mechanism to detect newlib inside __config
since the header defining the newlib/picolibc macros has not been included
yet inside __config. Doing it this way also avoids duplicating the ctype
table for newlib, reducing the global data size.

Differential Revision: https://reviews.llvm.org/D138195
2022-11-23 09:04:42 +00:00
David Spickett
75e09ce9b3 [libcxx] Add BOT_OWNERS.txt
Buildkite doesn't provide a way to list bot owners so currently
we are pinging people on Discord and Phabricator.

Which works ok until that person is on vacation. This file gives us
a place to list multiple people, or group contacts for each bot.

I've stuck to the CODE_OWNERS.txt format because there's no great
reason to change it.

Reviewed By: #libc, EricWF, ldionne

Differential Revision: https://reviews.llvm.org/D138445
2022-11-22 15:41:23 +00:00
Christopher Di Bella
ab46648082 [libcxx] adds an include-what-you-use (IWYU) mapping file
This makes it possible for programmers to run IWYU and get more accurate
standard library inclusions. Prior to this commit, the following program
would be transformed thusly:

```cpp
// Before
 #include <algorithm>
 #include <vector>

void f() {
  auto v = std::vector{0, 1};
  std::find(std::ranges::begin(v), std::ranges::end(v), 0);
}
```

```cpp
// After
 #include <__algorithm/find.h>
 #include <__ranges/access.h>
 #include <vector>
...
```

There are two ways to fix this issue: to use [comment pragmas](https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md)
on every private include, or to write a canonical [mapping file](https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUMappings.md)
that provides the tool with a manual on how libc++ is laid out. Due to
the complexity of libc++, this commit opts for the latter, to maximise
correctness and minimise developer burden.

To mimimise developer updates to the file, it makes use of wildcards
that match everything within listed subdirectories. A script has also
been added to ensure that the mapping is always fresh in CI, and makes
the process a single step.

Finally, documentation has been added to inform users that IWYU is
supported, and what they need to do in order to leverage the mapping
file.

Closes #56937.

Differential Revision: https://reviews.llvm.org/D138189
2022-11-22 01:09:49 +00:00
David Spickett
3ae3162cb6 [libcxx] Fix link to Buildbot interface
Reviewed By: #libc, philnik, ldionne

Differential Revision: https://reviews.llvm.org/D138286
2022-11-18 15:47:21 +00:00
Louis Dionne
bf68a595f6 [libc++] Start classifying debug mode features with more granularity
I am starting to granularize debug-mode checks so they can be controlled
more individually. The goal is for vendors to eventually be able to select
which categories of checks they want embedded in their configuration of
the library with more granularity.

Note that this patch is a bit weird on its own because it does not touch
any of the containers that implement iterator bounds checking through the
__dereferenceable check of the legacy debug mode. However, I added TODOs
to string and vector to change that.

Differential Revision: https://reviews.llvm.org/D138033
2022-11-15 11:18:22 -05:00
Louis Dionne
13ea134323 [libc++] Make it an error to define _LIBCPP_DEBUG
We have been transitioning off of that macro since LLVM 15.

Differential Revision: https://reviews.llvm.org/D137975
2022-11-15 09:48:13 -05:00
Mark de Wever
0c111dd86f [libc++] Documents details of the pre-commit CI.
This documentation aims to make it cleare how the libc++ pre-commit CI
works. For libc++ developers and other LLVM projects whose changes can
affect libc++.

This was discusses with @aaron.ballman as a follow on some unclearities
for the Clang communitee how the libc++ pre-commit CI works.

Note some parts depend on patches under review as commented in the
documentation.

Reviewed By: ldionne, #libc, philnik

Differential Revision: https://reviews.llvm.org/D133249
2022-11-10 20:20:17 +01:00
Nikolas Klauser
b7c0a4065e [libc++] Add FTM for constexpr vector
It looks like we forgot to set the FTM when adding constexpr vector support.

Reviewed By: ldionne, #libc

Spies: libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D137729
2022-11-09 22:45:20 +01:00
Nikolas Klauser
660b243120 [libc++] Add [[nodiscard]] extensions to ranges algorithms
This mirrors what we have done in the classic algorithms

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D137186
2022-11-05 16:38:46 +01:00
Nikolas Klauser
29378ab24b [libc++] Implement P2438R2 (std::string::substr() &&)
This doesn't affect our ABI because `std::string::substr()` isn't in the dylib and the mangling of `substr() const` and `substr() const&` are different.

Reviewed By: ldionne, Mordante, var-const, avogelsgesang, #libc

Spies: arphaman, huixie90, libcxx-commits

Differential Revision: https://reviews.llvm.org/D131668
2022-11-02 20:28:47 +01:00
Mark de Wever
883b749779 [libc++][doc] Updates implementation status.
Claim some tasks for formatting and mark some parts as complete, which
was missed in the commits completing the task.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D137014
2022-11-01 20:22:57 +01:00
Mark de Wever
45f81e904f [libc++] Validates valid weekday indexed range.
No code changes, but only increased the range in the tests.

Completes:
- LWG3273. Specify weekday_indexed to range of [0, 7]

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D137015
2022-11-01 20:20:57 +01:00
Nikolas Klauser
28e399fa1e [libc++][PMR] Deprecate the implementation in std::experimental
This commit deprecates <experimental/memory_resource> since we now ship the non-experimental
version of it. Per the libc++ policy [1], we are deprecating the experimental feature in
upcoming LLVM 16 and will remove it entirely in LLVM 18.

[1]: https://libcxx.llvm.org/DesignDocs/ExperimentalFeatures.html#id4

Reviewed By: ldionne, #libc

Spies: EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D136245
2022-11-01 00:37:08 +01:00
Nikolas Klauser
35d0e27618 [libc++][PMR] Mark completed papers and issues as such
Reviewed By: ldionne, #libc

Spies: krytarowski, Quuxplusone, tschuett, libcxx-commits

Differential Revision: https://reviews.llvm.org/D136194
2022-11-01 00:37:01 +01:00
Mark de Wever
a48007355a [libc++][format] Implements string escaping.
Implements parts of
- P2286R8 Formatting Ranges

Reviewed By: #libc, tahonermann

Differential Revision: https://reviews.llvm.org/D134036
2022-10-20 17:29:34 +02:00
Mark de Wever
8c489bd1f1 [libc++][doc] Fixes status pages.
Addresses post-commit review comment in D134742.
2022-10-19 19:26:37 +02:00
Nikolas Klauser
dbe60caa92 [libc++] Remove std::function in C++03
We've said that we'll remove `std::function` from C++03 in LLVM 16, so we might as well do it now before we forget.

Reviewed By: ldionne, #libc, Mordante

Spies: jloser, Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D135868
2022-10-19 11:08:35 +02:00
Mark de Wever
719c3dc6f2 [libc++][chrono] Implements formatter duration.
Partially implements:
- P1361 Integration of chrono with text formatting
- P2372 Fixing locale handling in chrono formatters
- LWG3270 Parsing and formatting %j with durations

Completes:
- P1650R0 std::chrono::days with 'd' suffix
- LWG3262 Formatting of negative durations is not specified
- LWG3314 Is stream insertion behavior locale dependent when Period::type is micro?

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D134742
2022-10-18 20:39:39 +02:00
Hui Xie
594fa1474f [libc++][ranges] implement std::ranges::drop_while_view
Differential Revision: https://reviews.llvm.org/D135460
2022-10-18 19:34:47 +01:00
Mark de Wever
91dd072354 [libc++][format] Move iterators when needed.
LWG-3539 was already implemented but not marked as done.
LWG-3567 is implemented in this commit.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D112368
2022-10-18 18:45:41 +02:00
Mark de Wever
a1e13a80d0 [libc++] Implements constexpr <charconv>.
Implements:
- P2291R3 Add Constexpr Modifiers to Functions to_chars and from_chars for
  Integral Types in <charconv> Header

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D131317
2022-10-12 17:43:23 +02:00
Arthur O'Dwyer
243da90ea5 [libc++] Add the C++17 <memory_resource> header (mono-patch)
This patch is the rebase and squash of three earlier patches.
It supersedes all three of them.

- D47111: experimental monotonic_buffer_resource.
- D47358: experimental pool resources.
- D47360: Copy std::experimental::pmr to std::pmr.

The significant difference between this patch and the-sum-of-those-three
is that this patch does not add `std::experimental::pmr::monotonic_buffer_resource`
and so on. This patch simply adds the C++17 standard facilities, and
leaves the `std::experimental` namespace entirely alone.

Differential Revision: https://reviews.llvm.org/D89057
2022-10-11 08:40:46 -04:00