Commit Graph

13331 Commits

Author SHA1 Message Date
Dan Katz
a2bd2164c0 Serialization/Deserialization of expansion statements.
Should fix #165.
2025-06-30 14:20:19 -04:00
Barry Revzin
97a102f706 Improve <meta> compile time (#164)
* 1. Remove variant usage

* 2. Remove <algorithm>

* 3. Remove most of <ranges>
2025-06-29 09:30:19 -04:00
Dan Katz
83819c9535 Add missing function. 2025-06-26 15:40:16 -04:00
Dan Katz
9bcfc343cb Handle StructuralValue-type template arguments in define_aggregate.
Fixes #159.
2025-06-25 10:30:54 -04:00
Dan Katz
e5f36c85d0 Remove references to removed '-fno-access-context' flag.
Closes #157.
2025-06-24 11:28:48 -04:00
Dan Katz
630bdd010b Update test includes. 2025-06-24 11:01:59 -04:00
Dan Katz
9b20135598 Merge remote-tracking branch 'origin/p2996' into p2996 2025-06-24 10:55:26 -04:00
Dan Katz
6df11649b9 Merge branch 'main' into p2996 2025-06-24 08:51:25 -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
Dan Katz
f03acdb7a4 The experiment has ended and the results have been good. 2025-06-22 13:09:35 -04: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
Dan Katz
2a631b61e3 Separate parameter/variable reflections. 2025-06-19 19:17:03 +03: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
Dan Katz
bebe293731 No mixing annotations and attributes. 2025-06-19 10:02:34 +03: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
Barry Revzin
a2548ff890 Fixing alignment_of references members (#153) 2025-06-13 07:52:18 -04: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
Dan Katz
3e871e8698 naming -> designating 2025-06-12 12:13:29 -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
Dan Katz
84be714bf8 Merge branch 'main' into wip 2025-06-11 14:35:33 -04: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
Dan Katz
b5a6e6d1f2 Merge branch 'p2996' into wip 2025-06-11 11:16:43 -04:00