Commit Graph

13077 Commits

Author SHA1 Message Date
Qinkun Bao
06a4394b50 Disable HWSan for thread_creae_failure.pass.
See https://github.com/llvm/llvm-project/pull/130145
2025-06-26 14:49:12 +00:00
Nikolas Klauser
0905767610 [libc++] Address remaining comments from #130145
I've accidentally merged the PR before addressing all
comments. This patch fixes the remaining ones.
2025-06-26 12:34:19 +02:00
Nikolas Klauser
696c0f92e0 [libc++] Don't try to wait on a thread that hasn't started in std::async, take 2 (#130145)
If the creation of a thread fails, this causes an idle loop that will
never end because the thread wasn't started in the first place.

This also adds a test for the regression reported in #125433 to make
sure we're not reintroducing it later.

Fixes #125428
2025-06-26 12:13:19 +02:00
Hristo Hristov
f2f4b557aa [libc++] P2944R3: Constrained comparisions - variant (#141396)
This is a follow-up and depends on #139368 being merged first.

Implements [P2944R3](https://wg21.link/P2944R3) partially, which adds
constrained comparisons to `std::variant`

Closes #136769

Depends on #139368

# References

[variant.relops](https://wg21.link/variant.relops)
2025-06-25 12:12:23 +03:00
Louis Dionne
52b27c2bd6 [libc++] Refactor basic_filebuf::overflow() (#144793)
Refactor the function to streamline the logic so it matches the
specification in [filebuf.virtuals] more closely. In particular, avoid
modifying the put area pointers when we loop around after a partial
codecvt conversion.

Note that we're technically not up-to-spec in this implementation, since
the Standard says that we shouldn't try more than once after a partial
codecvt conversion. However, this refactoring attempts not to change any
functionality.
2025-06-24 13:58:49 -04:00
Hui
0b8f3cc6b7 [libc++] Fix no-localisation CI failure on <complex> (#145213) 2025-06-24 13:56:17 -04:00
Peng Liu
d80766152c [libc++] Fix bitset conversion functions and refactor constructor (#121348)
This patch addresses several implementation issues in `bitset`'s
conversion functions `to_ullong` and `to_ulong`, and refactors its
converting constructor `__bitset(unsigned long long __v)` to a more
generic and elegant implementation.
2025-06-24 12:38:10 -04:00
Nikolas Klauser
be00098632 [libc++] Remove a bunch of now unnecessary indirections in __tree (#142397)
Most notably, this removes the notion of a distinct `value_type` and
`__container_value_type` from `__tree`, since these are now always the
same type. There are a few places we need to keep `__value_type` around,
since they are ABI visibile. In these cases `_Tp` is used directly. The
second simplification here is that we use `const value_type&` instead of
`const key_type&` in a few places and make use of the fact that the
comparator is capable of comparing any combination of `key_type` and
`value_type`.

This is a follow-up to #134819.
2025-06-23 10:47:47 +02:00
Nikolas Klauser
43260b01dd [libc++] Add test to ensure that the mangling of types stays the same (#143556) 2025-06-23 10:43:47 +02:00
Hui
831fcb5e91 [libc++] constexpr flat_map (#137453)
Fixes #128673
2025-06-21 13:41:32 +01:00
Jakub Mazurkiewicz
1bb2328fd3 [libc++] Implement views::join_with (#65536)
* Implement "P2441R2 `views::join_with`" (https://wg21.link/P2441R2),
closes #105185
* Implement LWG4074 (https://wg21.link/LWG4074), closes #105346
* Complete implementation of "P2711R1 Making multi-param constructors of
views explicit" (https://wg21.link/P2711R1), closes #105252
* Complete implementation of "P2770R0 Stashing stashing iterators for
proper flattening" (https://wg21.link/P2770R0), closes #105250
2025-06-21 10:54:50 +01:00
Nikolas Klauser
685af55fe0 [libc++] Simplify <limits> a bit (#140021)
This does a few small things:
- inline `__libcpp_compute_min`, since we can don't have to put the
arithmetic behind a constraint. Simple arithmetic also tends to be
faster to compile than instantiating a type.
- Remove an unused include (and add missing includes elsewhere)
- Remove `__min` and `__max` from the `bool` specialization

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2025-06-21 09:58:45 +02:00
Nikolas Klauser
2050d2e181 [libc++] Simplify std::function further after removing allocator support (#144443)
Since we've removed allocator support, we can remove a few support
structures. This only affects the policy implementation, so this
shouldn't even be ABI sensitive.
2025-06-21 09:47:54 +02:00
Aiden Grossman
7157f33c6c [libc++] Disable a std::unexpected test in modules build (#144466)
This patch disables unexpected_disabled_cpp17.verify.cpp under clang
modules builds because it changes diagnostics criteria post #143423,
causing the test to fail.

This patch follows a similar style to 853059a150.
This was found when working on trying to land #144033.
2025-06-20 12:58:59 -04:00
Hristo Hristov
945ce1aa3d [libc++] Update the value of __cpp_lib_constrained_equality after P3379R0 (#144553)
https://wg21.link/P3379R0 updated the value of __cpp_lib_constrained_equality,
but we forgot to update it when we implemented the paper.
2025-06-20 12:36:46 -04:00
Nikolas Klauser
20245bbf66 [libc++][NFC] Format abs.pass.cpp test
I will modify the test in an upcoming PR. I'm formatting it now to avoid
a bunch of whitespace changes in that PR.
2025-06-19 10:41:12 +02:00
Nikolas Klauser
584cc37687 [libc++] Move std::abs into __math/abs.h (#139586)
`template <class = int>` is also added to our implementations to avoid
an ambiguity between the libc's version and our version when both are
visible.

This avoids including `<stdlib.h>` in `<math.h>`.
2025-06-19 10:37:18 +02:00
Nikolas Klauser
650b451d00 [libc++] Simplify the implementation of pointer_traits a bit (#142260) 2025-06-19 10:06:59 +02:00
S. B. Tam
a9a71b6d31 [libc++][test] Don't pass ill-formed UTF-8 to MAKE_STRING_VIEW (#136403) 2025-06-19 15:21:28 +08:00
Kazu Hirata
ca9a09dbe6 [libc++] Fix a typo in documentation (#144763) 2025-06-18 15:03:17 -04:00
Peng Liu
9827440f1e [libc++] Optimize ranges::{for_each, for_each_n} for segmented iterators (#132896)
Previously, the segmented iterator optimization was limited to `std::{for_each, for_each_n}`. This patch
extends the optimization to `std::ranges::for_each` and `std::ranges::for_each_n`, ensuring consistent
optimizations across these algorithms. This patch first generalizes the `std` algorithms by introducing
a `Projection` parameter, which is set to `__identity` for the `std` algorithms. Then we let the `ranges`
algorithms to directly call their `std` counterparts with a general `__proj` argument. Benchmarks
demonstrate performance improvements of up to 21.4x for ``std::deque::iterator`` and 22.3x for
``join_view`` of ``vector<vector<char>>``.

Addresses a subtask of #102817.
2025-06-18 12:22:47 -04:00
Peng Liu
dd40c460c4 [libc++] Clean up casts in std::forward_list (#130310)
The patch removes unnecessary casts to `void*` pointers, inline some
casts, and eliminates an identity cast.
2025-06-18 12:16:01 -04:00
Peng Liu
13510c0736 [libc++] Make list constexpr as part of P3372R3 (#129799)
This patch makes `std::list` constexpr as part of P3372R3.

Fixes #128659.
2025-06-18 12:13:50 -04:00
Nikolas Klauser
9db7502d22 [libc++] Move __has_iterator_typedefs to the up-to-C++17 implementation of iterator_traits (#144265)
`__has_iterator_typedefs` is only used in the up-to-C++17 implementation
of `type_traits`. To make that clearer the struct is moved into that
code block.
2025-06-18 15:55:06 +02:00
Martin Storsjö
c3efe7d64c [libcxx] [test] Fix odr_signature tests with optimizations enabled (#144317)
If optimization is enabled, the inline `f()` function actually gets
inlined, meaning that the functions `tu1()` and `tu2()` trivially return
1 and 2, instead of actually referencing the potentially linker
deduplicated function `f()`, which is what the test tries to test.

Therefore, this test previously actually failed to test what it was
supposed to test, if optimization was enabled.

Mark the inline functions with `TEST_NOINLINE` to make sure that they
don't get inlined even with optimizations enabled.

Also update the TODO comments to explain why we have an XFAIL for msvc
mode here.

This avoids these tests unexpectedly passing if building in msvc mode,
with optimizations enabled
(`-DLIBCXX_TEST_PARAMS="optimization=speed"`).
2025-06-18 14:12:14 +03:00
Daniel Thornburgh
fd7e46b864 Revert "[libc++] Remove trailing newline from _LIBCPP_ASSERTION_HANDLER calls" (#144615)
Reverts llvm/llvm-project#143573
2025-06-17 15:50:42 -07:00
Sam Clegg
a5a0d88073 [libc++] Remove trailing newline from _LIBCPP_ASSERTION_HANDLER calls (#143573)
This newline was originally added in https://reviews.llvm.org/D142184
but I think updating `__libcpp_verbose_abort` to add newline instead is
more consistent, and works for other callers of `_LIBCPP_VERBOSE_ABORT`.

The `_LIBCPP_ASSERTION_HANDLER` calls through to either
`_LIBCPP_VERBOSE_ABORT` macro or the `__builtin_verbose_trap`. From what
I can tell neither of these function expect a trailing newline (at least
none of the usage of `_LIBCPP_VERBOSE_ABORT` or `__builtin_verbose_trap`
that I can find include a trailing newline except `_LIBCPP_ASSERTION_HANDLER`).

I noticed this discrepancy when working on
https://github.com/emscripten-core/emscripten/pull/24543
2025-06-17 17:07:16 -04:00
Louis Dionne
8d1610afd0 [libc++] Mark two assertion tests as unsupported in C++03 mode
Our assertion checking facility requires at least C++11, so these
tests were failing when run in C++03 mode.
2025-06-17 16:51:35 -04:00
Louis Dionne
7c4b2be983 [libc++][NFC] Refactor basic_streambuf to use public API functions when possible (#144547)
The implementation of std::basic_streambuf used private member variables
to manipulate the get and the put areas. Using public API functions is
equivalent but leads to code that is easier to understand, since the
public API functions are known more widely than our internal member
variables. Using the public API functions removes the need to map the
internal member variables back to get/put area manipulation functions in
one's head.

Finally, it also makes it easier to find subtle issues by instrumenting
accessor functions, which is impossible if the class uses the member
variables directly.
2025-06-17 16:38:27 -04:00
Louis Dionne
b1aa845595 [libc++][NFC] Consistently qualify calls to C functions in <fstream> (#144539) 2025-06-17 15:48:58 -04:00
Nikolas Klauser
79a2b15a4c [libc++] Remove a few workarounds for old Clang versions (#143858) 2025-06-16 11:12:15 +02:00
Hristo Hristov
a0c00ccd5f [libc++] P2944R3: Constrained comparisons - update reference_wrapper implementation (#139368)
Updates the implementation `std::reference_wrapper` -
[P2944R3](https://wg21.link/P2944R3) as discussed in
https://github.com/llvm/llvm-project/pull/117664#discussion_r1857826166
This PR also refactors the tests in preparation to implements the
constrained comparisons for `optional`, `variant` etc.

- Moves the test helpers (concepts and types) for testing constrained
comparisons to `test_comparisons.h`.
- Updates the `std::reference_wrapper` implementation to use the concept
`__core_convertible_to<bool>` as per comments in #135759.

Closes #138233

# References:
- [refwrap.comparisons](https://wg21.link/refwrap.comparisons)

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
2025-06-15 07:45:48 +03:00
halbi2
eab1a1d491 [libc++][test] Improve test coverage for flat_set (lack of) SCARY iterators (#139649)
Missing from 5e94e26a7a.
2025-06-12 13:15:41 -04:00
kotborealis
a53003fe23 [libc++] Update GDB pretty-printer to work with GDB 17 (#142106)
This patch fixes an issue in libcxx/utils/gdb/libcxx/printers.py.

With gdb 17 (binutils 2_44) pretty-printers do not work anymore because
calls to `gdb.printing` requires `import gdb.printing` statement, which
was missing from the `printers.py`.

This was broken after commit https://github.com/bminor/binutils-gdb/commit/fc14343205d3a
and `import gdb.printing` was first referenced in https://github.com/bminor/binutils-gdb/commit/ee06c79b0f.

Co-authored-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2025-06-12 11:51:22 -04:00
tynasello-google
13fe07d670 [libc++] Expand Android libc++ test config files (#142846)
Parameterize (and rename) existing libc++/libc++abi test configuration
files for the Android NDK to work for both the NDK and platform.

Android LLVM downstream seeks to test libc++ for both the NDK and
platform build (currently only testing the NDK), which will use almost
identical test configuration files. The only difference is the name of
the libc++ shared object used. Because of this we parameterize the
current test files (for both libc++ and libc++abi) with the existing
LIBCXX_SHARED_OUTPUT_NAME cmake variable, and rename the file
accordingly.
2025-06-12 11:39:28 -04:00
Kazu Hirata
5c1a021f7f [libc++] Fix typos in documentation (#143912) 2025-06-12 10:54:36 -04:00
A. Jiang
bba4ded3c2 [libc++] Fix constructing bitset from non-null-terminated arrays (#143691)
Unconditional evaluation of `char_traits<_CharT>::length(__str)` is problematic, because it causes
UB when `__str` points to a non-null-terminated array. We should only call `length` (currently, in
`basic_string_view`'s constructor) when `__n == npos` per [bitset.cons]/8.

Drive-by change: Reduction of conditional compilation, given that
- both `basic_string_view<_CharT>::size_type` and `basic_string<_CharT>::size_type` must be 
  `size_t`, and thus
- both `basic_string_view<_CharT>::npos` and `basic_string<_CharT>::npos` must be `size_t(-1)`.

For the type sameness in the standard wording, see:
- [string.view.template.general]
- [basic.string.general]
- [allocator.traits.types]/6
- [default.allocator.general]/1

Fixes #143684
2025-06-12 10:53:41 -04:00
Nikolas Klauser
b979311842 [libc++] Remove allocator support from std::function (#140395)
The allocator support was removed in P0302R1, since it was impossible to
implement. We're currently providing the API for this, but ignore the
allocator in all cases but one (which is almost certainly an oversight).
That case is the `function(allocator_arg_t, const Alloc&, Func)`
constuctor. IMO we should remove the API entirely at a later date, but
this only removes most of the code for now, leaving only the public
functions. This not only simplifies the code quite a bit, but also
results in the constructor being instantiated ~8x faster.

Fixes #133901
2025-06-12 14:21:29 +02:00
Nikolas Klauser
0c62571d9f [libc++] Remove static_assert from hash.cpp that fires unconditionall 2025-06-11 20:57:07 +02:00
Nikolas Klauser
773d357b98 [libc++] Simplify the implementation of __next_prime a bit (#143512) 2025-06-11 20:39:45 +02:00
Nikolas Klauser
42c82fcc29 [libc++] Upgrade to GCC 15 (#138293) 2025-06-11 20:19:26 +02:00
Peng Liu
38fb0117ab [libc++] Make forward_list constexpr as part of P3372R3 (#129435)
Fixes #128658
2025-06-11 12:13:36 -04:00
Nikolas Klauser
b10d711362 [libc++][NFC] Move __libcpp_is_integral into the else branch (#142556)
This makes it clear that `__libcpp_is_integral` is an implementation
detail of `is_integral` if we don't have `__is_integral` and not its own
utility.
2025-06-11 14:33:41 +02:00
Nikolas Klauser
3c56437eaf [libc++] Refactor signed/unsigned integer traits (#142750)
This patch does a few things:
- `__libcpp_is_signed_integer` and `__libcpp_is_unsigned_integer` are
refactored to be variable templates instead of class templates.
- the two traits are merged into a single header
`<__type_traits/integer_traits.h>`.
- `__libcpp_signed_integer`, `__libcpp_unsigned_integer` and
`__libcpp_integer` are moved into the same header.
- The above mentioned concepts are renamed to `__signed_integer`,
`__unsigned_integer` and `__signed_or_unsigned_integer` respectively.
2025-06-11 14:31:13 +02:00
Nikolas Klauser
b49c7896c0 [libc++] Fix constraints in __countr_zero and __popcount
Currently these two functions are constrained on `is_unsigned`, which is
more permissive than what is required by the standard for their public
counterparts. This fixes the constraints to match the public functions
by using `__libcpp_is_unsigned_integer` instead.
2025-06-11 14:29:52 +02:00
maflcko
a17e97e677 [libc++] Add missing C++20 [time.point.arithmetic] (#143165)
This was part of https://wg21.link/p0355r7, but apparently never
implemented.

---------

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
Co-authored-by: Hristo Hristov <zingam@outlook.com>
2025-06-11 08:43:23 +02:00
Louis Dionne
616f83530f [libc++] Move swap test to a .compile.pass.cpp (#143167) 2025-06-10 15:22:42 -04:00
Louis Dionne
baceb7923f [libc++] Don't skip localization-related headers in header tests (#134877)
When localization is disabled, we used to skip testing a lot of headers.
However, these headers are now "no-ops" when localization is disabled,
so they can actually be included. As such, we should test their
inclusion in our usual header inclusion tests.
2025-06-10 14:12:46 -04:00
Nikolas Klauser
f2fede6095 [libc++] Document our ABI guarantees and what ABI flags exist to modify these guarantees (#132615) 2025-06-10 12:59:08 +02:00
Nikolas Klauser
eccd81f20b [libc++] Simplify the implementation of std::hash (#140407)
Instead of providing full specializations of `hash` for every arithmetic
type, this moves the implementation to a base class, which is
specialized via `enable_if`s instead.
2025-06-10 06:32:56 +02:00