7219 Commits

Author SHA1 Message Date
Nikolas Klauser
c861fe8a71
[libc++] Introduce ABI sensitive areas to avoid requiring _LIBCPP_HIDE_FROM_ABI everywhere (#131156)
This patch introduces `_LIBCPP_{BEGIN,END}_EXPLICIT_ABI_ANNOTATIONS`,
which allow us to have implicit annotations for most functions, and just
where it's not "hide_from_abi everything" we add explicit annotations.
This allows us to drop the `_LIBCPP_HIDE_FROM_ABI` macro from most
functions in libc++.
2025-05-18 15:47:05 +02:00
Nikolas Klauser
f6867709a7
[libc++] Fix set::operator= when instantiating with a std::pair (#140385)
This has been introduced by #134819, most likely due to a merge conflict
I didn't resolve properly (I thought I did in that patch what I'm now
doing here).
2025-05-18 12:40:34 +02:00
Nikolas Klauser
962aa2666f
[libc++] Don't instantiate allocators in __tree on an incomplete type (#140225)
This causes a mismatch between `value_type` and
`allocator_type::value_type` in `__tree`, but I think that's acceptable.
`__tree` primarily gets a `__value_type` wrapper due to potential ABI
breaks and unwraps it to the same as `allocator_type::value_type` in the
end. A cleanup patch will also change `__tree::value_type` to be the
same as `allocator_type::value_type`, making the type mismatch only
visible where `__tree` is instantiated in `map`.
2025-05-18 12:38:06 +02:00
Hui
4b104c6853
[libc++] Fix flat_{multi}set insert_range (#137462)
Fixes #136656
2025-05-16 13:17:21 -04:00
Christopher Di Bella
c41812e6ea
[libcxx] applies #134819 to insert_or_assign with const key_type& (#140124)
This was missed due to using prvalues in the test case, which were
picked up by the rvalue-reference overload instead.
2025-05-16 08:56:45 +02:00
cor3ntin
381a649fb9
[Clang] Add warnings when mixing different charN_t types (#138708)
charN_t represent code units of different UTF encodings. Therefore the
values of 2 different charN_t objects do not represent the same
characters.

In order to avoid comparing apples and oranges, we add new warnings to
warn on:
  - Implicit conversions
  - Comparisons
  - Other cases involving arithmetic conversions

We only produce the warning if we cannot establish the comparison would
be safe through constant evaluation.

The new `-Wimplicit-unicode-conversion` warning is enabled by default.

Note that this PR intentionally doesn;t touches char/wchar_t, but it
would be worth considering also warning on extending the new warnings to
these types (in a follow up)

Additionally most arithmetic operations on charN_t don't really make
sense (ie what does it mean to addition code units), so we could add
warnings for that.

Fixes #138526
2025-05-15 18:16:05 +02:00
Nikolas Klauser
49bced456c
[libc++] Add basic constant folding for std::format (#107197)
```
-------------------------------------------------------------------
Benchmark                                        old            new
-------------------------------------------------------------------
BM_format_string<char>/1                     42.1 ns        7.67 ns
BM_format_string<char>/2                     22.3 ns        3.84 ns
BM_format_string<char>/4                     10.6 ns        1.92 ns
BM_format_string<char>/8                     5.31 ns       0.815 ns
BM_format_string<char>/16                    2.79 ns       0.480 ns
BM_format_string<char>/32                    1.63 ns       0.550 ns
BM_format_string<char>/64                   0.782 ns       0.276 ns
BM_format_string<char>/128                  0.397 ns       0.145 ns
BM_format_string<char>/256                  0.211 ns       0.066 ns
BM_format_string<char>/512                  0.154 ns       0.035 ns
BM_format_string<char>/1024                 0.146 ns       0.021 ns
BM_format_string<char>/2048                 0.125 ns       0.033 ns
BM_format_string<char>/4096                 0.097 ns       0.016 ns
BM_format_string<char>/8192                 0.077 ns       0.012 ns
BM_format_string<char>/16384                0.066 ns       0.010 ns
BM_format_string<char>/32768                0.062 ns       0.016 ns
BM_format_string<char>/65536                0.062 ns       0.016 ns
BM_format_string<char>/131072               0.443 ns       0.015 ns
BM_format_string<char>/262144               0.629 ns       0.017 ns
BM_format_string<char>/524288               0.715 ns       0.020 ns
BM_format_string<char>/1048576              0.757 ns       0.020 ns
BM_format_string<wchar_t>/1                  38.8 ns        34.0 ns
BM_format_string<wchar_t>/2                  19.4 ns        16.9 ns
BM_format_string<wchar_t>/4                  9.88 ns        8.45 ns
BM_format_string<wchar_t>/8                  6.30 ns        6.47 ns
BM_format_string<wchar_t>/16                 3.11 ns        3.21 ns
BM_format_string<wchar_t>/32                 1.60 ns        1.63 ns
BM_format_string<wchar_t>/64                0.899 ns       0.925 ns
BM_format_string<wchar_t>/128               0.676 ns       0.693 ns
BM_format_string<wchar_t>/256               0.658 ns       0.685 ns
BM_format_string<wchar_t>/512               0.556 ns       0.531 ns
BM_format_string<wchar_t>/1024              0.428 ns       0.402 ns
BM_format_string<wchar_t>/2048              0.328 ns       0.319 ns
BM_format_string<wchar_t>/4096              0.276 ns       0.274 ns
BM_format_string<wchar_t>/8192              0.252 ns       0.251 ns
BM_format_string<wchar_t>/16384             0.248 ns       0.246 ns
BM_format_string<wchar_t>/32768             0.229 ns       0.232 ns
BM_format_string<wchar_t>/65536             0.248 ns       0.246 ns
BM_format_string<wchar_t>/131072            0.250 ns       0.240 ns
BM_format_string<wchar_t>/262144             3.03 ns        3.03 ns
BM_format_string<wchar_t>/524288             3.14 ns        3.15 ns
BM_format_string<wchar_t>/1048576            3.60 ns        3.61 ns
BM_string_without_formatting<char>           32.2 ns       0.470 ns
BM_string_without_formatting<wchar_t>        38.8 ns        10.2 ns
```
2025-05-15 10:37:32 +02:00
Nikolas Klauser
fbdf38ed43
[libc++] run clang-tidy on src/ in the CI (#121198)
This adds a new test to run clang-tidy on the `src/` directory and
temporarily disables and clang-tidy checks that currently fail. They
will be enabled in follow-up patches.
2025-05-15 10:34:09 +02:00
Nikolas Klauser
53f11dd4d6
[libc++] Avoid type-punning between __value_type and pair (#134819)
Before this patch, we were dereferencing pointers to objects which were
never constructed. Now we always assume that nodes store `pair<const
KeyT, ValueT>` for maps instead, as they actually do. This patch also
allows for significant follow-up simplifications, since
`__node_value_type` and `__container_value_type` are the same type now.
2025-05-15 09:01:56 +02:00
Louis Dionne
8c435886aa
[libc++] Refactor and add benchmark coverage for [alg.sort] (#128236)
This patch adds missing benchmark coverage for partial_sort,
partial_sort_copy, is_sorted and is_sorted_until.

It also refactors the existing benchmarks for sort and stable_sort to
follow the consistent style of the new algorithm benchmarks. However,
these benchmarks were notoriously slow to run since they tested multiple
data patterns on multiple data types. To try to alleviate this, I
reduced the benchmarks to only run on integral types and on a single
non-integral type, which should faithfully show how the algorithm
behaves for anything non-integral. However, this is technically a
reduction in coverage.
2025-05-14 14:52:17 -04:00
Peng Liu
f1ecff8f88
[libc++] Improve test coverage and readability for swap_ranges (#133752)
This patch enhances the test coverage of `{std,ranges}::swap_ranges` by
adding larger test cases with 100 elements across different containers.
It also inlines standalone tests for better readability, avoiding
unnecessary navigation.

This patch addresses a follow-up suggestion from PR #121138 to extend
test coverage beyond 3 elements.
2025-05-14 13:02:01 -04:00
Nikolas Klauser
edc9d91ca4
[libc++] Enable the GDB pretty printers for Clang (#135484)
The GDB pretty printer test works just fine with Clang in the CI now,
except that it breaks (not exactly unexpectedly) with optimizations
enabled.
2025-05-14 10:12:01 -04:00
A. Jiang
e9ce752769
[libc++] Remove the constexpr hash<vector<bool>> extension (#132617)
libc++ makes the `hash<vector<bool, A>>::operator()` `constexpr` since
C++20, which is a conforming extension, but it was unintended.

This patch removes the extension, with an escape hatch macro for it, and
the escape hatch will be removed in the future. Test cases for
`constexpr` along with the assumption of hash values are moved to the
`libcxx/test/libcxx/` subdirectory.

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2025-05-14 07:20:27 +08:00
A. Jiang
ab60910e01
[libc++][format] Discard contents since null-terminator in character arrays in formatting (#116571)
Currently, built-in `char`/`wchar_t` arrays are assumed to be
null-terminated sequence with the terminator being the last element in
formatting. This doesn't conform to [format.arg]/6.9.

> otherwise, if `decay_t<TD>` is `char_type*` or `const char_type*`,
> initializes value with `static_cast<const char_type*>(v)`;

The standard wording specifies that character arrays are decayed to
pointers. When the null terminator is not the last element or there's no
null terminator (the latter case is UB), libc++ currently produces
different results.

Also fixes and hardens `formatter<CharT[N], CharT>::format` in
`<__format/formatter_string.h>`. These specializations are rarely used.

Fixes #115935. Also checks the preconditions in this case, which fixes
#116570.
2025-05-12 16:49:25 -04:00
Nikolas Klauser
c8f2cdafd4
[libc++] Simplify the implementation of std::get for pairs (#114984)
This makes it clearer what the functions actually do. As a nice
side-effect it also avoids a function call. If the C++03 header split is
successful we could drop `__get_pair` entirely.
2025-05-12 22:40:17 +02:00
halbi2
5e94e26a7a
[libc++] Improve test coverage for containers' scary.pass.cpp (#131550) 2025-05-12 16:35:05 -04:00
Nikolas Klauser
948bffa951
[libc++] Simplify __promote (#136101)
This avoids instantiating an extra class for every variant `__promote`
is used in.
2025-05-08 16:48:57 -04:00
Hui
f39ac3f569
[libc++] Add test for flat_set::insert not creating temporaries (#138387)
Fixes #119016
2025-05-08 16:42:01 -04:00
Louis Dionne
45d493b680
[libc++] Add the __is_replaceable type trait (#132408)
That type trait represents whether move-assigning an object is
equivalent to destroying it and then move-constructing a new one from
the same argument. This will be useful in a few places where we may want
to destroy + construct instead of doing an assignment, in particular
when implementing some container operations in terms of relocation.

This is effectively adding a library emulation of P2786R12's
is_replaceable trait, similarly to what we do for trivial relocation.
Eventually, we can replace this library emulation by the real
compiler-backed trait.

This is building towards #129328.
2025-05-08 16:35:00 -04:00
Ryan Prichard
93aba1e240
[libc++][Android] Disable fdsan in filebuf close.pass.cpp (#102412)
fdsan is Bionic's "File Descriptor Sanitizer". Starting in API 30+, it
aborts this close.pass.cpp test, because it closes the FD belonging to
std::filebuf's FILE*. For `__BIONIC__`, disable that part of the test.
2025-05-07 15:27:19 -04:00
yronglin
13c464be84
[libc++] Implement P3379R0 Constrain std::expected equality operators (#135759)
Closes #118135

Co-authored-by: A. Jiang <de34@live.cn>
2025-05-07 15:25:00 -04:00
A. Jiang
fc281e1b4f
[libc++][docs] Confirm that P3136R1 Retiring niebloids is Complete (#135932)
As libc++ has been implementing niebloids as CPOs since LLVM 14 due to
https://reviews.llvm.org/D116570.

Also changes some comments in test files to use the formal term
"algorithm function object".

Closes #118133.
2025-05-07 15:20:43 -04:00
Louis Dionne
e33ca9adc8
[libc++] Reword std::advance assertion message for consistency with ranges::advance (#138749)
As brought up in https://github.com/llvm/llvm-project/pull/133276.
2025-05-07 12:59:38 -04:00
Peng Liu
7087ee6bc7
[libc++][NFC] Improve test readability for std::fill_n (#133771)
This patch enhances test readability by inlining standalone tests,
eliminating unnecessary navigation. Additionally, several classes with
ad-hoc names have been renamed for better clarity:
- `A` -> `CharWrapper` as it wraps a char
- `B -> CharTransformer` as it accepts a char `xc` but stores `xc + 1`
- `Storage -> CharUnionStorage` as it stores a union of 2 `char`s.  

This patch addresses a follow-up comment from #120909 to inline tests.
2025-05-06 16:17:18 -04:00
Nikolas Klauser
f25f9e480b
[libc++][NFC] Remove a bunch of redundant ASan existence checks (#128504)
There are currently lots of `_LIBCPP_HAS_ASAN` and
`__libcpp_is_constant_evaluated()` checks which aren't needed, since it
is centrally checked inside `__debug_utils/sanitizers.h`.
2025-05-06 22:16:58 +02:00
A. Jiang
2f54a843bb
[libc++][test] Test flat_meow with proper underlying iterators (#131290)
Flat container adaptors require the iterators of underlying containers
to be random access, and it is required that random access container
iterators must support three-way comparison ([container.reqmts]/39 - /41).

As a result, we should at least avoid testing "containers" with random
access but not three-way comparable iterators for flat container
adaptors.

This patch adds a new class template `three_way_random_access_iterator`
to `test_iterators.h` and fixes some usages of `MinSequenceContainer`
with the new iterators.
2025-05-06 16:15:19 -04:00
Louis Dionne
d05ab119e1
[libc++] Remove redundant and somewhat confusing assertions around advance() (#133276)
The std::advance function has a clear precondition that it can only be
called with a negative distance when a bidirectional iterator is used.
However, prev() and next() don't have such preconditions explicitly,
they inherit it from calling advance().

This patch removes assertions in prev() and next() that were duplicates
of similar ones in advance(), and removes a copy-pasted comment that was
trying to justify the use of _LIBCPP_ASSERT_PEDANTIC but IMO is creating
confusion with little benefit.
2025-05-06 15:44:26 -04:00
Louis Dionne
60b43ef70b
[libc++] Improve the test coverage for std::vector::emplace (#132440)
This patch refactors the test for std::vector::emplace back to cover new
corner cases, and increase coverage for normal cases as well.

This is building towards #129328.
2025-05-06 15:29:27 -04:00
Louis Dionne
25fc52e655
[libc++] Re-introduce _LIBCPP_DISABLE_AVAILABILITY (#134158)
The `_LIBCPP_DISABLE_AVAILABILITY` macro was removed in afae1a5f32bb as an
intended no-op. It turns out that some projects are making use of that
macro to work around a Clang bug with availability annotations that
still exists: https://github.com/llvm/llvm-project/issues/134151.

Since that Clang bug still hasn't been fixed, I feel that we must sill
honor that unfortunate macro until we've figured out how to get rid of
it without breaking code.
2025-05-05 14:19:13 -07:00
Hristo Hristov
4ed8f38e81
[libc++][pair] P2944R3: Constrain std::pair's equality operator (#136672)
Implements https://wg21.link/P2944R3 (partially):
- [pairs.spec](https://eel.is/c++draft/pairs.spec)

Related issues:
- Related to #105424
- Related to #118135
  - PR https://github.com/llvm/llvm-project/pull/135759
  - PR https://github.com/llvm/llvm-project/pull/117664

Closes: [#136763](https://github.com/llvm/llvm-project/issues/136763)

# References
- https://eel.is/c++draft/concept.booleantestable
- https://eel.is/c++draft/concept.equalitycomparable

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
2025-04-29 22:00:16 +03:00
Martin Storsjö
205d399f30
[libcxx] [test] Clarify the condition for long double hex formatting (#135334)
This test currently hardcodes which environments have got 80 bit long
doubles on x86_64 with a suitable printf formatting; convert the
architecture check into a check specifically for 80 bit long doubles.

Not all x86_64 configurations do have 80 bit long doubles (e.g. 
Android doesn't), and i386 configurations can also have 80 bit long
doubles, compatible with this test.

Also clarify the exact reasons for why specific OSes such as FreeBSD are
skipped for these tests, even though they have 80 bit long doubles.
2025-04-25 09:53:30 +03:00
Yuzhiy
03c2862404
[libc++][ranges] Reject non-class types in ranges::to (#135802)
This patch adds `static_assert` using `is_class_v` and `is_union_v` to
reject no-class type template parameters.

Fixes #132133

---------

Co-authored-by: A. Jiang <de34@live.cn>
2025-04-24 10:29:59 +02:00
Martin Storsjö
d6622df115
[libcxx] [test] Extend mingw workarounds for armv7/aarch64 too (#136419)
This would be more convenient, if ADDITIONAL_COMPILE_FLAGS(target=...)
could be set with a regular expression, just like within e.g. XFAIL
lines.
2025-04-22 22:41:56 +03:00
Peng Liu
e9280a1d39
[libc++] Backport segmented iterator optimization for std::for_each to C++11 (#134960)
Previously, the segmented iterator optimization for `std::for_each` was restricted to C++23 and later due to its dependency on `__movable_box`, which is not available in earlier standards. This patch eliminates that restriction, enabling consistent optimizations starting from C++11. 

By backporting this enhancement, we improve performance across older standards and create opportunities to extend similar optimizations to other algorithms by forwarding their calls to `std::for_each`.
2025-04-19 07:12:43 -04:00
A. Jiang
06de4d52d5
[libc++] Properly decay functions in CTAD for pair (#134544)
This patch makes instantiation of `pair` in CTAD a bit lazier to avoid
instantiating invalid `pair` specialization before the decaying explicit
deduction guide works.
2025-04-19 10:01:48 +08:00
Louis Dionne
860e88411d
[libc++] Make __config_site modular (#134699)
This patch makes the __config_site header modular, which solves various
problems with non-modular headers. This requires going back to
generating the modulemap file, since we only know how to make
__config_site modular when we're not using the per-target runtime dir.

The patch also adds a test that we support
-Wnon-modular-include-in-module, which warns about non-modular includes
from modules.

---------

Co-authored-by: Konstantin Varlamov <varconst@apple.com>
2025-04-18 06:06:25 -07:00
Дмитрий Изволов
51b8c66b08
[libc++] Extend the scope of radix sorting inside std::stable_sort to floating-point types (#129452)
These changes speed up `std::stable_sort` in the case of sorting
floating-point types.
This applies only to IEEE 754 floats.
The speedup is similar to that achieved for integers in PR #104683 (see
benchmarks below).

Why does this worth doing?
Previously, `std::stable_sort` had almost no chance of beating
`std::sort`.
Now there are cases when `std::stable_sort` is preferrable, and the
difference is significant.
```
---------------------------------------------------------------------------
Benchmark             |  std::stable_sort  |   std::sort | std::stable_sort
                      | without radix_sort |             | with radix_sort 
---------------------------------------------------------------------------
float_Random_1        |       1.62 ns      |     2.15 ns |          1.61 ns
float_Random_4        |       18.0 ns      |     2.71 ns |          16.3 ns
float_Random_16       |        118 ns      |      113 ns |           112 ns
float_Random_64       |        751 ns      |      647 ns |           730 ns
float_Random_256      |       4715 ns      |     2937 ns |          4669 ns
float_Random_1024     |      25713 ns      |    13172 ns |          5959 ns <--
float_Random_4096     |     131307 ns      |    56870 ns |         19294 ns <--
float_Random_16384    |     624996 ns      |   242953 ns |         64264 ns <--
float_Random_65536    |    2895661 ns      |  1027279 ns |        288553 ns <--
float_Random_262144   |   13285372 ns      |  4342593 ns |       3022377 ns <--
float_Random_1048576  |   60595871 ns      | 19087591 ns |      18690457 ns <--
float_Random_2097152  |  131336117 ns      | 38800396 ns |      52325016 ns
float_Random_4194304  |  270043042 ns      | 79978019 ns |     102907726 ns
double_Random_1       |       1.60 ns      |     2.15 ns |          1.61 ns
double_Random_4       |       15.2 ns      |     2.70 ns |          16.9 ns
double_Random_16      |        104 ns      |      112 ns |           119 ns
double_Random_64      |        712 ns      |      614 ns |           755 ns
double_Random_256     |       4496 ns      |     2966 ns |          4820 ns
double_Random_1024    |      24722 ns      |    12679 ns |          6189 ns <--
double_Random_4096    |     126075 ns      |    54484 ns |         20999 ns <--
double_Random_16384   |     613782 ns      |   232557 ns |        110276 ns <--
double_Random_65536   |    2894972 ns      |   988531 ns |        774302 ns <--
double_Random_262144  |   13460273 ns      |  4278059 ns |       5115123 ns
double_Random_1048576 |   61119996 ns      | 18408462 ns |      27166574 ns
double_Random_2097152 |  132511525 ns      | 37986158 ns |      54423869 ns
double_Random_4194304 |  272949862 ns      | 77912616 ns |     147670834 ns
```

Comparison for only `std::stable_sort`:
```
Benchmark                                                         Time      Time Old      Time New
--------------------------------------------------------------------------------------------------
BM_StableSort_float_Random_1024                                -0.7997         25438          5096
BM_StableSort_float_Random_4096                                -0.8731        128157         16260
BM_StableSort_float_Random_16384                               -0.9024        621271         60623
BM_StableSort_float_Random_65536                               -0.9081       2922413        268619
BM_StableSort_float_Random_262144                              -0.7766      13386345       2990408
BM_StableSort_float_Random_1048576                             -0.6954      60673010      18481751
BM_StableSort_float_Random_2097152                             -0.6026     130977358      52052182
BM_StableSort_float_Random_4194304                             -0.6252     271556583     101770500
BM_StableSort_float_Ascending_1024                             -0.6430          6711          2396
BM_StableSort_float_Ascending_4096                             -0.7979         38460          7773
BM_StableSort_float_Ascending_16384                            -0.8471        191069         29222
BM_StableSort_float_Ascending_65536                            -0.8683        882321        116194
BM_StableSort_float_Ascending_262144                           -0.8346       3868552        639937
BM_StableSort_float_Ascending_1048576                          -0.7460      16521233       4195953
BM_StableSort_float_Ascending_2097152                          -0.5439      21757532       9922776
BM_StableSort_float_Ascending_4194304                          -0.7525      67847496      16791582
BM_StableSort_float_Descending_1024                            -0.6359         15038          5475
BM_StableSort_float_Descending_4096                            -0.7090         62810         18278
BM_StableSort_float_Descending_16384                           -0.7763        311844         69750
BM_StableSort_float_Descending_65536                           -0.7228       1270513        352202
BM_StableSort_float_Descending_262144                          -0.6785       5484173       1763045
BM_StableSort_float_Descending_1048576                         -0.5084      20223149       9941852
BM_StableSort_float_Descending_2097152                         -0.7646      60523254      14247014
BM_StableSort_float_Descending_4194304                         -0.5638      95706839      41748858
BM_StableSort_float_SingleElement_1024                         +0.3715          1732          2375
BM_StableSort_float_SingleElement_4096                         -0.1685          9357          7781
BM_StableSort_float_SingleElement_16384                        -0.3793         47307         29362
BM_StableSort_float_SingleElement_65536                        -0.4925        227666        115536
BM_StableSort_float_SingleElement_262144                       -0.4271       1075853        616387
BM_StableSort_float_SingleElement_1048576                      -0.3736       5097599       3193279
BM_StableSort_float_SingleElement_2097152                      -0.2470       9854161       7420158
BM_StableSort_float_SingleElement_4194304                      -0.3384      22175964      14670720
BM_StableSort_float_PipeOrgan_1024                             -0.4885         10664          5455
BM_StableSort_float_PipeOrgan_4096                             -0.6340         50095         18337
BM_StableSort_float_PipeOrgan_16384                            -0.7078        238700         69739
BM_StableSort_float_PipeOrgan_65536                            -0.6740       1102419        359378
BM_StableSort_float_PipeOrgan_262144                           -0.7460       4698739       1193511
BM_StableSort_float_PipeOrgan_1048576                          -0.5657      18493972       8032392
BM_StableSort_float_PipeOrgan_2097152                          -0.7116      41089206      11850349
BM_StableSort_float_PipeOrgan_4194304                          -0.6650      83445011      27955737
BM_StableSort_float_QuickSortAdversary_1024                    -0.6863         17402          5460
BM_StableSort_float_QuickSortAdversary_4096                    -0.7715         79864         18247
BM_StableSort_float_QuickSortAdversary_16384                   -0.7800        317480         69839
BM_StableSort_float_QuickSortAdversary_65536                   -0.7400       1357601        352967
BM_StableSort_float_QuickSortAdversary_262144                  -0.6450       5662094       2009769
BM_StableSort_float_QuickSortAdversary_1048576                 -0.5092      21173627      10392107
BM_StableSort_float_QuickSortAdversary_2097152                 -0.7333      61748178      16469993
BM_StableSort_float_QuickSortAdversary_4194304                 -0.5607      98459863      43250182
BM_StableSort_double_Random_1024                               -0.7657         24769          5802
BM_StableSort_double_Random_4096                               -0.8441        126449         19717
BM_StableSort_double_Random_16384                              -0.8269        614910        106447
BM_StableSort_double_Random_65536                              -0.7413       2905000        751427
BM_StableSort_double_Random_262144                             -0.6287      13449514       4994348
BM_StableSort_double_Random_1048576                            -0.5635      60863246      26568349
BM_StableSort_double_Random_2097152                            -0.5959     130293892      52654532
BM_StableSort_double_Random_4194304                            -0.4772     272616445     142526267
BM_StableSort_double_Ascending_1024                            -0.4870          6757          3466
BM_StableSort_double_Ascending_4096                            -0.7360         37592          9923
BM_StableSort_double_Ascending_16384                           -0.7971        183967         37324
BM_StableSort_double_Ascending_65536                           -0.7465        897116        227398
BM_StableSort_double_Ascending_262144                          -0.6764       4020980       1301033
BM_StableSort_double_Ascending_1048576                         -0.6407      16421799       5900751
BM_StableSort_double_Ascending_2097152                         -0.6380      29347139      10622419
BM_StableSort_double_Ascending_4194304                         -0.5934      70439925      28644185
BM_StableSort_double_Descending_1024                           -0.5988         15216          6105
BM_StableSort_double_Descending_4096                           -0.6857         65069         20449
BM_StableSort_double_Descending_16384                          -0.6922        329321        101381
BM_StableSort_double_Descending_65536                          -0.7038       1367970        405242
BM_StableSort_double_Descending_262144                         -0.6472       5361644       1891429
BM_StableSort_double_Descending_1048576                        -0.6656      22031404       7366459
BM_StableSort_double_Descending_2097152                        -0.7593      68922467      16591242
BM_StableSort_double_Descending_4194304                        -0.6392      96283643      34743223
BM_StableSort_double_SingleElement_1024                        +0.9128          1895          3625
BM_StableSort_double_SingleElement_4096                        +0.1475         10013         11490
BM_StableSort_double_SingleElement_16384                       -0.1901         52382         42424
BM_StableSort_double_SingleElement_65536                       -0.2096        254698        201313
BM_StableSort_double_SingleElement_262144                      -0.1833       1248478       1019648
BM_StableSort_double_SingleElement_1048576                     -0.1741       5703397       4710603
BM_StableSort_double_SingleElement_2097152                     -0.1751      10922197       9009835
BM_StableSort_double_SingleElement_4194304                     -0.1538      26571923      22485137
BM_StableSort_double_PipeOrgan_1024                            -0.4406         10752          6014
BM_StableSort_double_PipeOrgan_4096                            -0.5917         49456         20195
BM_StableSort_double_PipeOrgan_16384                           -0.6258        270515        101221
BM_StableSort_double_PipeOrgan_65536                           -0.7098       1159462        336457
BM_StableSort_double_PipeOrgan_262144                          -0.6591       4735711       1614433
BM_StableSort_double_PipeOrgan_1048576                         -0.6620      19353110       6541172
BM_StableSort_double_PipeOrgan_2097152                         -0.7288      49131812      13323391
BM_StableSort_double_PipeOrgan_4194304                         -0.5988      81958974      32878171
BM_StableSort_double_QuickSortAdversary_1024                   -0.6516         17948          6254
BM_StableSort_double_QuickSortAdversary_4096                   -0.7527         82359         20363
BM_StableSort_double_QuickSortAdversary_16384                  -0.7009        340410        101811
BM_StableSort_double_QuickSortAdversary_65536                  -0.6854       1487480        467928
BM_StableSort_double_QuickSortAdversary_262144                 -0.6386       5648460       2041377
BM_StableSort_double_QuickSortAdversary_1048576                -0.6127      22859142       8852587
BM_StableSort_double_QuickSortAdversary_2097152                -0.7161      68693975      19499381
BM_StableSort_double_QuickSortAdversary_4194304                -0.5909      95532179      39077491
OVERALL_GEOMEAN                                                -0.6472             0             0
```
2025-04-16 17:34:11 +08:00
Damien L-G
557e931d95
[libc++] Implement P2897R7 aligned_accessor: An mdspan accessor expressing pointer over-alignment (#122603)
Closes #118372
2025-04-14 17:33:57 -04:00
A. Jiang
5c45e239e8
[libc++][test][NFC] Remove unused inclusions of <iostream> (#134776)
Some test files for flat container adaptors redundantly include
`<iostream>` and, surprisingly, `<cstddef>`. This patch removes the
redundant inclusions.

Inclusions of `<vector>` is also removed since a sane implementation is
expected to make instantiation of `flat_(multi)map<K, V>` or
`flat_(multi)set<K>` valid when only `<flat_map>` or `<flat_set>` is
included.
2025-04-13 15:17:58 +08:00
A. Jiang
3e7be494f8
[libc++][test] Test nasty_string in C++20 (#135338)
It seems that we can only rely on C++20 features and make `nasty_string`
also tested for MSVC STL.
2025-04-13 11:23:13 +08:00
Mark de Wever
6de15379f4
[NFC][libc++][test] Minor updates to generated header version test. (#134543)
Adjusting the existing script to match the new output makes it easy to
review the new script works correctly.

This adjusts the tests to match the changes in the new tests, Notably
- removes the synopsis uses 2 spaces indent in `# if`

It does not implement the conditional include part. This would be quite
some effort and these diffs are easy to review manually.

Note there are no tests for the changes; the existing script will be
phased out when the next generators are complete.
2025-04-12 14:20:01 +02:00
Mark de Wever
df579ce4b6
[libc++] Adds is_implemented function for new ftm generator. (#134538)
At the moment the ftm macro for __cpp_lib_to_chars will have the
following values:

standard_ftms: {
    "c++17": "201611L",
    "c++20": "201611L",
    "c++23": "201611L",
    "c++26": "201611L",
}

implemented_ftms: {
    "c++17": None,
}

This is an issue with the test whether the FTM is implemented it does:
  self.implemented_ftms[ftm][std] == self.standard_ftms[ftm][std]
This will fail in C++20 since implemented_ftms[ftm] does not have the
key c++20. This adds a new helper function and removes the None entries
when a FTM is not implemented.

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2025-04-11 20:27:29 +02:00
Mark de Wever
88e15b7815
[libc++] A quick-fix for the Apple CI. (#135202)
The Apple runners automatically pick up newer XCode versions breaking
the CI. This disables the test to get the CI green which allows us to
investigate the issue properly later on.
2025-04-11 17:05:30 +02:00
Nikolas Klauser
8fc2538f33
Reapply "[libc++] Optimize num_put integral functions" (#131613) (#133572)
This reverts commit d1156fcb56891fb1a426c3e8331a51d47f98a1b8.

This patch fixes the reported incorrect formatting changes and adds
tests for them. The performance should be unaffected, since there are no
significant changes required to fix the bugs.

Specifically, a `>` was changed to a `>=` to also add a `+` in the zero
case, and we're checking for zero now before printing the octal and
hexadecimal prefixes.

Closes #131710
2025-04-11 15:35:58 +02:00
Peter Collingbourne
a4e6a771a6
libcxx: In gdb test detect execute_mi with feature check instead of version check.
The existing version check can lead to test failures on some distribution
packages of gdb where not all components of the version number are
integers, such as Fedora where gdb.VERSION can be something like
"15.2-4.fc41". Fix it by replacing the version check with a feature check.

Reviewers: philnik777

Reviewed By: philnik777

Pull Request: https://github.com/llvm/llvm-project/pull/132291
2025-04-10 10:38:08 -07:00
A. Jiang
ab95005a05
[libc++] P3247R2: Deprecate is_trivial(_v) (#130573)
Requirements on character-like types are updated unconditionally,
because `basic_string` does requires the default-constructibility. It
might be possible to make `basic_string_view` support classes with
non-public trivial default constructor, but this doesn't seem sensible.

libcxxabi's `ItaniumDemangle.h` is also updated to avoid deprecated
features.
2025-04-09 07:40:01 +08:00
Mark de Wever
658f848fed
[NFC][libc++][test] Refactor new ftm generator tests. (#134490)
This uses the python unit test framework instead of just asserts. This
improves the diagnostics when a test fails.
2025-04-08 19:38:26 +02:00
Matheus Izvekov
d057811655
[clang] fix diagnostic printing of expressions ignoring LangOpts (#134693)
Currently when printing a template argument of expression type, the
expression is converted immediately into a string to be sent to the
diagnostic engine, unsing a fake LangOpts.

This makes the expression printing look incorrect for the current
language, besides being inneficient, as we don't actually need to print
the expression if the diagnostic would be ignored.

This fixes a nastiness with the TemplateArgument constructor for
expressions being implicit, and all current users just passing an
expression to a diagnostic were implicitly going through the template
argument path.

The expressions are also being printed unquoted. This will be fixed in a
subsequent patch, as the test churn is much larger.
2025-04-07 23:19:32 -03:00
Damien L-G
9965f3d337
[libc++] Improve diagnostic when violating std::atomic trivially copyable mandates (#131754)
When attempting to instantiate `std::atomic` with a non trivially
copyable type, one gets errors from instantiating internals before the
actual static assertion that check the template parameter type
requirements.

The `verify` test for it had a `// ADDITIONAL_COMPILE_FLAGS: -Xclang
-verify-ignore-unexpected=error` directive to work around this issue.
The changes I propose enable us to drop that directive.
As I understand it, the `verify` test was misplaced so I moved it to
`test/{std -> libcxx}/atomics`.

(I ran into this while working on #121414 in which we would add another
static assertion in `__check_atomic_mandates`)
2025-04-07 15:25:45 -04:00
Mark de Wever
a406fb8f5a
[libc++] Clang-tidy operator& hijacker. (#128366)
Guards against introducing new places where operator& depends on a
template type.
2025-04-07 18:19:58 +02:00