Commit Graph

8884 Commits

Author SHA1 Message Date
Louis Dionne 54c4c01553 [libc++] Enable format_to and vformat_to tests even outside of Debug mode
These tests don't seem specific to the debug mode, so it makes sense to
run them even when the debug mode is disabled. When we run with the debug
mode enabled, we'll get the out-of-bounds checking that this test seems
to be concerned with.

Differential Revision: https://reviews.llvm.org/D121241
2022-03-09 12:38:30 -05:00
Mark de Wever 3925f98de4 [libc++][NFC] Cleanups in <charconv>.
Based on review comments in D97705 applied some code cleanups in
<charconv>. The header now uses a more recent libc++ style.

Reviewed By: Quuxplusone, #libc, philnik

Differential Revision: https://reviews.llvm.org/D121223
2022-03-09 17:52:02 +01:00
Louis Dionne 0f622bd281 [libc++] Don't manually override NDEBUG in the dylib build
LIBCXX_ENABLE_ASSERTIONS does not have any relationship to the `assert`
macro -- it only controls assertions that are internal to the library.
Playing around with `NDEBUG` only muddies the picture further than it
already is.

Also, remove a failing assertion in the benchmarks. That assertion had
never been exercised because we defined `NDEBUG` manually, and it was
failing since we introduced the ability to generate a benchmark vector
with the Quicksort adversary ordering (which is obviously not sorted).

This was split off of https://llvm.org/D121123.

Differential Revision: https://reviews.llvm.org/D121244
2022-03-09 10:05:38 -05:00
David Spickett 406d418c0c [libcxx][CI] Use temporary clang-13 bots for Arm/AArch64
This is a stop gap until I am able to update the usual bots
to clang-13.

Differential Revision: https://reviews.llvm.org/D121224
2022-03-09 09:16:41 +00:00
Martin Storsjö 9286a8238b [libcxx] [test] XFAIL the get/put long_double_ru_RU tests on Glibc < 2.27
Those older versions used a different monetary decimal separator.
To avoid unnecessary churn to support that, just XFAIL the test
on those older versions. (Up until
df1e43c496, the whole test was XFAILed
on all versions of glibc.)

Differential Revision: https://reviews.llvm.org/D120979
2022-03-09 10:17:20 +02:00
Martin Storsjö abe46776f3 [libcxx] [test] Fix the classic_table test on Windows
On Windows, constants like F::alpha and F::print are bitmasks
consisting of multiple bits (e.g. F::alpha consisting of both the
bits F::upper and F::lower). In such a case, we can't check that
all the bits from all the expected constants are set. Instead,
check that (p[i] & mask) != 0 returns the expected value.

Differential Revision: https://reviews.llvm.org/D120802
2022-03-09 10:12:55 +02:00
Arthur O'Dwyer 2b0ec7ca44 [libc++] Fix a use-after-move introduced in D118003.
Thanks to Eric Fiselier for catching this!
2022-03-08 21:57:40 -05:00
Nikolas Klauser c2cd15a665 [libc++][ranges] Implement ranges::mismatch
Implement `ranges::mismatch`

Reviewed By: Quuxplusone, ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D117817
2022-03-08 23:20:40 +01:00
Louis Dionne 508d7dd2a2 [libc++] Remove stray #undef
I think that was left after we removed _CONSTEXPR_TERNARY based on a
review comment -- the #undef was never removed.
2022-03-08 16:34:28 -05:00
Louis Dionne 276ca87382 [libc++] Remove extension to support allocator<const T>
This extension is a portability trap for users, since no other standard
library supports it. Furthermore, the Standard explicitly allows
implementations to reject std::allocator<cv T>, so allowing it is
really going against the current.

This was discovered in D120684: this extension required `const_cast`ing
in `__construct_range_forward`, a fishy bit of code that can be removed
if we don't support the extension anymore.

This is a re-application of dbc647643577, which was reverted in 9138666f5
because it broke std::shared_ptr<T const>. Tests have now been added and
we've made sure that std::shared_ptr<T const> wouldn't be broken in this
version.

Differential Revision: https://reviews.llvm.org/D120996
2022-03-08 15:05:12 -05:00
Louis Dionne 3f66882417 [libc++][NFC] Rename ostreambuf_iterator test 2022-03-08 14:49:20 -05:00
Arthur O'Dwyer 79d08e398c [libc++] "Bottom-up heapsort" improvement to sort_heap.
https://en.wikipedia.org/wiki/Heapsort#Bottom-up_heapsort
In `pop_heap` specifically, the item we insert at the top and
sift downward is guaranteed to be leaf-sized, so we expect it
to go pretty far down. Sift it down as if it were INT_MIN, and
then bubble it back up if needed.
Also known as "heapsort with bounce."

Numbers are here: https://godbolt.org/z/cvfnYW6fe

Fixes #10008.

Differential Revision: https://reviews.llvm.org/D118003
2022-03-08 13:48:21 -05:00
Arthur O'Dwyer e3d3755c47 [libc++] Complexity regression tests for make_heap and sort_heap.
Reviewed as part of D118003.
2022-03-08 13:48:20 -05:00
Louis Dionne 95c0f2d115 [libc++] Remove workarounds for re-defining _LIBCPP_ASSERT in the test suite
As a fly-by fix, enable the complexity-changing assertions in __debug_less
only when the full debug mode is enabled, since debugging level 0 is usually
understood to only contain basic assertions that do not change the complexity
of algorithms.

Differential Revision: https://reviews.llvm.org/D121129
2022-03-08 10:41:38 -05:00
Nikolas Klauser 7aef4a0cae [libc++] Enable more clang-tidy checks and list potential candidates
These are some checks that make sense in libc++ IMO. The checks after `#TODO: investigate these checks` are candidates, but they can't be enabled without some cleanup.

Reviewed By: ldionne, #libc

Spies: aheejin, libcxx-commits

Differential Revision: https://reviews.llvm.org/D120925
2022-03-08 14:14:55 +01:00
Kai Luo a7adf7b9e9 [libcxx][AIX] Remove `LIBCXX-AIX-FIXME` in isalwayslockfree check after 86478c7ad8
The workaround has been removed via https://reviews.llvm.org/D119931, checks passed on AIX-32.

Reviewed By: ldionne, daltenty, jsji, #libc

Differential Revision: https://reviews.llvm.org/D121081
2022-03-08 01:23:33 +00:00
Louis Dionne 9138666f54 Revert "[libc++] Remove extension to support allocator<const T>"
This reverts commit bed3240bf7.

I will need to add more tests for std::shared_ptr<T const> before
re-landing this.
2022-03-07 17:35:12 -05:00
Arthur O'Dwyer 844a9c0ef4 [libc++] Make common_iterator's proxy types into aggregates.
Saves one move in each case, which is basically nothing perf-wise;
this is more about simplifying the code.

Differential Revision: https://reviews.llvm.org/D121130
2022-03-07 15:44:10 -05:00
Martin Storsjö ebde6fc23b [libcxxabi] Fix cmake order dependency wrt dllexporting
If LIBCXX_ENABLE_SHARED isn't explicitly set on the cmake command
line, isn't set in the cache, and the libcxxabi project is configured
before libcxx, then LIBCXX_ENABLE_SHARED isn't defined yet. Once
the libcxx cmake project has been parsed, LIBCXX_ENABLE_SHARED would
have been set to its default value of ON.

This makes sure that the symbols are properly dllexported in such
a configuration scenario.

Differential Revision: https://reviews.llvm.org/D120982
2022-03-07 15:36:04 -05:00
Louis Dionne bed3240bf7 [libc++] Remove extension to support allocator<const T>
This extension is a portability trap for users, since no other standard
library supports it. Furthermore, the Standard explicitly allows
implementations to reject std::allocator<cv T>, so allowing it is
really going against the current.

This was discovered in D120684: this extension required `const_cast`ing
in `__construct_range_forward`, a fishy bit of code that can be removed
if we don't support the extension anymore.

Differential Revision: https://reviews.llvm.org/D120996
2022-03-07 15:36:03 -05:00
Jinsong Ji 706e37c8e0 [libc++][AIX][test] Enable put_double/long_double locale tests
AIX print -0.0 , inf, nan differently, which are causing the test
failures. We are OK for most other tests.

This patch remove the tests related these limitations conditionally on AIX,
so that we can enable the other tests to avoid losing test coverage.

The general direction is:

```
if strings don't differ between environments, keep the string literal "INF" and the padding, instead of folding them into variables.
```

Reviewed By: ldionne, #libc, Mordante

Differential Revision: https://reviews.llvm.org/D120448
2022-03-07 14:21:28 -05:00
Arthur O'Dwyer fbcd5236af [libc++] [ranges] Fix `decltype(auto) ranges::iter_move`.
See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92894#c3
https://reviews.llvm.org/D119589#inline-1151299

Differential Revision: https://reviews.llvm.org/D120417
2022-03-07 13:31:16 -05:00
Arthur O'Dwyer 34206b869d [libc++] Overhaul std::quoted; fix its relationship to character traits.
Move `__quoted_output_proxy` into the one file that uses it.

A `const char*` has no associated traits class, so `std::quoted("literal")`
should be printable into any basic_ostream regardless of traits.

Use hidden-friend `operator<<` and `operator>>`, since we're permitted to.
(The exact signature is unspecified because the class itself is unspecified.)

We shouldn't support `std::quoted("literal")` in C++03 or C++11 mode.
(We do need `std::__quoted(s)` and `std::__quoted(cs)` in C++11 mode,
because they're used by `std::__fs::filesystem::path`.)

Differential Revision: https://reviews.llvm.org/D120135
2022-03-07 13:28:58 -05:00
Arthur O'Dwyer 1c6e752cfc [libc++] Better handling for zero-sized types.
Zero-sized types are a GCC extension, also supported by Clang.
In theory it's already invalid to `delete` a void pointer or a
pointer-to-incomplete, so we shouldn't need any special code
to catch those cases; but in practice Clang accepts both
constructs with just a warning, and GCC even accepts `sizeof(void)`
with just a warning! So we must keep the static_asserts.
The hard errors are tested in `unique_ptr_dltr_dflt/*.compile.fail.cpp`.

In ranges::begin/end, check `sizeof >= 0` instead of `sizeof != 0`,
so as to permit zero-sized types while still disallowing incomplete
types.

Fixes #54100.

Differential Revision: https://reviews.llvm.org/D120633
2022-03-07 11:50:00 -05:00
Nikolas Klauser 205557c908 [libc++][ranges] Implement ranges::max_element
Implement ranges::max_element

Reviewed By: Quuxplusone, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D117523
2022-03-07 17:11:23 +01:00
Louis Dionne 27fe8605a8 [libc++][NFC] Improve release note formatting 2022-03-07 10:26:38 -05:00
Louis Dionne 7ab4fe1122 [libc++][NFC] Add missing whitespace in release notes 2022-03-07 09:00:21 -05:00
Louis Dionne 311ff39178 [libc++] Add missing header <cuchar>
Fixes llvm-project#44216

Differential Revision: https://reviews.llvm.org/D97870
2022-03-07 08:48:50 -05:00
Kai Luo 86478c7ad8 [libcxx][atomic] Remove workaround for PR31864
I believe the origin issue in PR31864 has been addressed by https://reviews.llvm.org/D59566.

As discussed in https://github.com/llvm/llvm-project/issues/53840, `ATOMIC_LLONG_LOCK_FREE == 2` sometimes is not consistent with `std::atomic<long long>::is_always_lock_free`, since the macro takes `long long`'s ABI alignment into account. https://reviews.llvm.org/D28213 proposed we should not rely on ABI alignment of types, thus we have consistent `ATOMIC_LLONG_LOCK_FREE` and `std::atomic<long long>::is_always_lock_free` on x86's old cpu. Currently, I plan to move on to remove the workaround which should have been addressed and don't want to break current tests.

Reviewed By: #libc, ldionne, Quuxplusone

Differential Revision: https://reviews.llvm.org/D119931
2022-03-06 00:56:32 +00:00
Nikolas Klauser 52915d78f4 [libc++] Granularize <utility> includes
Reviewed By: ldionne, #libc

Spies: EricWF, libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D120466
2022-03-05 19:31:46 +01:00
Nikolas Klauser 9b03c08e85 [libc++] Don't warn that coroutines aren't supported when including <experimental/coroutine>
This change makes the behavior of `<experimental/coroutine>` consistent with other headers that only work conditionally.

Reviewed By: ldionne, #libc

Spies: Mordante, ChuanqiXu, libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D119964
2022-03-05 19:01:49 +01:00
Arthur O'Dwyer 988dae653f [libc++] Add _LIBCPP_HIDE_FROM_ABI to __quoted_proxy ctors.
ldionne says this looks right to him, too.

Reviewed as part of D120135.
2022-03-04 23:06:28 -05:00
Arthur O'Dwyer 9d93b97222 [libc++] [NFC] Formatting preliminary to D120135 (std::quoted)
This just gets some of the non-functional formatting out of the way
before the meat of D120135.
2022-03-04 23:06:28 -05:00
Arthur O'Dwyer 564c7fa1b7 [libc++] ADL-proof calls to __quoted and noskipws.
Reviewed as part of D120135.
2022-03-04 23:06:28 -05:00
Martin Storsjö 45415ef91b [libcxx] Fix the ctype `is` (pointer version) function for Windows
Previously, this test snippet would report incorrect information:

    F::mask m;
    std::wstring in(L"\u00DA"); // LATIN CAPITAL LETTER U WITH ACUTE
    f.is(in.data(), in.data() + 1, &m);
    // m & F::lower would be set

The single-character version of the `is` function wasn't
affected by this issue though.

Define `_LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA` for Windows,
as the `alpha` / `_ALPHA` constant is a mask consisting of
multiple bits set, which avoids setting `alpha` whenver any
of the bits is set, in the `do_is` implementation.

On Windows, with the "C" locale, wchars are classified according
to their Unicode interpretation, just as in the en_US.UTF-8 locale on
all platforms.

Due to the differing classification of some characters, the
`scan_is` and `scan_not` tests are quite annoying to fix, thus just
ifdef out some of the tests for the "C" locale there - the code gets
tested with the more standard en_US.UTF-8 locale anyway.

Differential Revision: https://reviews.llvm.org/D120796
2022-03-05 00:47:19 +02:00
Arthur O'Dwyer 3347e7d40f [libc++] [LWG3656] Update the return type of std::bit_width.
Fixes LWG3656, "Inconsistent bit operations returning a count".
https://cplusplus.github.io/LWG/issue3656

The fix has been approved for C++23 and left to vendors' discretion
in C++20 (but it sounds like everyone's on the same page that
of course it should be DR'ed back to C++20 too).

Differential Revision: https://reviews.llvm.org/D120444
2022-03-04 17:31:09 -05:00
Arthur O'Dwyer 7e1355eb13 [libc++] Mark __wrap_iter's private constructors as explicit.
This is slightly more user-visible than D119894, because the user is
expected to touch `__wrap_iter` directly. But the affected ctors are
non-public, so the user was never expected to be actually calling them.
And I didn't intentionally omit this from D119894; I just didn't
think of it.

Differential Revision: https://reviews.llvm.org/D120937
2022-03-04 13:24:38 -05:00
Louis Dionne 9fee527eca [runtimes] Trigger CI jobs when only the runtimes/ subdirectory is touched 2022-03-04 10:59:27 -05:00
Martin Storsjö b2d93400a9 [libcxx] [test] Fix get_string_en_US, get_long_double_en_US for Windows
In the en_US locale on Windows, negative currency amounts is formatted
as "($0.01)" instead of "-$0.01".

Differential Revision: https://reviews.llvm.org/D120799
2022-03-04 10:18:07 +02:00
Martin Storsjö d32f46b076 [libcxx] [test] Fix the get/put long_double_zh_CN tests on Windows
Differential Revision: https://reviews.llvm.org/D120889
2022-03-04 10:17:44 +02:00
Mark de Wever 5f26d8636f [libc++] Removes base member from tests.
Change the tests to use the base friend function instead of members.
Also changed some types to have a base friends instead of members.

Reviewed By: #libc, ldionne, Quuxplusone

Differential Revision: https://reviews.llvm.org/D120742
2022-03-03 21:46:04 +01:00
Nikolas Klauser 569d0cc46d [libc++] Remove _LIBCXX_MODULES_BUILD and ext/ headers from header tests
Reviewed By: ldionne, Quuxplusone, #libc

Spies: libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D120896
2022-03-03 19:53:23 +01:00
Louis Dionne 61f2b3ed21 [libc++] Move several defines to ADDITIONAL_COMPILE_FLAGS in the test suite
This avoids -Wmacro-redefined when turning warnings on with GCC.
2022-03-03 13:17:35 -05:00
Louis Dionne 863802ecf3 [libc++] Move .fail.cpp test to .verify.cpp 2022-03-03 13:17:35 -05:00
Ruslan Arutyunyan 41a62cc0b4 [libcxx][test][NFC] Add tests for constructors of unordered [multi]map since C++14
Add tests for C++14 constructors in unordered_map and unordered_multimap

unordered_[multi]map(size_type sz, const allocator_type& alloc);
unordered_[multi]map(size_type sz, const hasher& hash, const allocator_type& alloc);

template <class InputIt>
unordered_[multi]map(InputIt first, InputIt last, size_type sz, const allocator_type& alloc);

template <class InputIt>
unordered_[multi]map(InputIt first, InputIt last, size_type sz, const hasher& hash, const allocator_type& alloc);

unordered_[multi]map(initializer_list<value_type> init, size_type sz, const allocator_type& alloc);
unordered_[multi]map(initializer_list<value_type> init, size_type sz, const hasher& hash, const allocator_type& alloc);

Reviewed By: ldionne, rarutyun, #libc

Differential Revision: https://reviews.llvm.org/D119236
2022-03-03 19:17:18 +03:00
Jake Egan 3e87719177 [libc++] Fix initialization of __fill_
`basic_ios` delays initialization of `__fill_` to `widen(' ')` until `fill()` is called. But, `fill(char_type)` is missing this logic, so the fill character does not get initialized to whitespace if `fill(char_type)` is called first. This patch adds this logic to `fill(char_type)`.

Reviewed By: #libc, ldionne, Quuxplusone

Differential Revision: https://reviews.llvm.org/D120751
2022-03-03 09:28:49 -05:00
Nikolas Klauser bd44174547 [libc++] Use -I instead of -isystem to include headers in the test suite
Using -isystem marks the headers as system headers, which means that we
don't actually get all the warnings that we'd normally get if we included
the headers as user headers.

The goal of the test suite is normally to mirror as closely as possible
how users would use the library. Technically, this change goes against
that philosophy, since users should be using `-isystem` (if they ever
need to specify the libc++ path explicitly, which should be a rare
occurence). However, I believe fishing out additional warnings from
the headers provides more value, hence this change. Ideally, we'd be
able to still use `-isystem`, but instruct Clang to still emit warnings
from the libc++ headers (e.g. we could tell Clang to emit warnings in
any file inside `<...>/usr/include/c++/v1`).

Reviewed By: #libc, ldionne, #libc_abi

Spies: Mordante, EricWF, mstorsjo, mgorny, aheejin, arichardson, philnik, jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D118616
2022-03-03 13:19:47 +01:00
Ruslan Arutyunyan 6cefc30a7f [libcxx][test][NFC] Add tests for C++14 constructors of unordered sets
Add tests for C++14 constructors in unordered_set and unordered_multiset:

unordered_[multi]set(size_type sz, const allocator_type& alloc);
unordered_[multi]set(size_type sz, const hasher& hash, const allocator_type& alloc);

template <class InputIt>
unordered_[multi]set(InputIt first, InputIt last, size_type sz, const allocator_type& alloc);

template <class InputIt>
unordered_[multi]set(InputIt first, InputIt last, size_type sz, const hasher& hash, const allocator_type& alloc);

unordered_[multi]set(initializer_list<value_type> init, size_type sz, const allocator_type& alloc);
unordered_[multi]set(initializer_list<value_type> init, size_type sz, const hasher& hash, const allocator_type& alloc);

Reviewed By: ldionne, Quuxplusone, rarutyun, #libc

Differential Revision: https://reviews.llvm.org/D119243
2022-03-03 15:15:03 +03:00
Martin Storsjö 9e2236fb7b Reapply [lit] Read command stdout/stderr as text on Windows
This takes care of normalizing newlines back to single LF instead
of CRLF.

Fix up a couple tests that accidentally pass binary data to stdout.

Differential Revision: https://reviews.llvm.org/D120623
2022-03-03 13:31:31 +02:00
Martin Storsjö df1e43c496 [libcxx] [test] Fix get/put long_double_ru_RU on Glibc, FreeBSD and Windows
Note, reducing ios.width() in put_long_double instead of using variable
padding, when using a variable width symbol. Some of those tests didn't
actually trigger any padding in the existing form, with a longer
currency symbol; reduce the width so there's no actual padding with the
slightly shorter currency symbol either.

The tests for the international currency symbol use the same amount of
padding on all platforms, so they still exercise the padding properly.

Differential Revision: https://reviews.llvm.org/D120317
2022-03-03 13:30:59 +02:00