Drive-by: Rename `constexpr_noexcept.compile.pass.cpp` to
`ctor.default.pass.cpp` as test coverage is added to it, and compile and
run it in all modes.
Consistency improvements and other small tweaks.
A follow-up to https://github.com/llvm/llvm-project/pull/193891 - the
changes were deferred to reduce the size of an already large and
approved PR.
I believe these headers were relevant when we actually implemented
functions in `<cmath>`, but they are not anymore. Note that ::hypot in
particular is obtained from <math.h> like all the other math functions.
Co-authored-by: A. Jiang <de34@live.cn>
[mem.res.monotonic.buffer.ctor] requires initial_size to be greater than
zero for the two constructors that take one, but we silently accepted
zero. Add a hardening assertion for that precondition.
Fixes#213059
Two insert benchmarks were registered with lambdas capturing insert_iter_iter_bench
by reference, unlike every other registration in this file, which captures by value.
RegisterBenchmark() stores the lambda by value and only invokes it from
RunSpecifiedBenchmarks(), which happens long after associative_container_benchmarks()
has returned, creating a dangling reference.
This essentially copies the `.clang-tidy` file from libc++ into
libc++abi, except that the naming conventions are updated to not add
underscores and some checks are disabled that don't pass currently. They
will be fixed in follow-ups.
This PR adds an implementation of parallel
`std::lexicographical_compare()` based on parallel `std::mismatch()`.
The implementation is close to a one-liner:
```c++
auto __res = _Mismatch()(__policy, __first1, __last1, __first2, __last2, [&](_Ref1 __lhs, _Ref2 __rhs) {
return !__comp(__lhs, __rhs) && !__comp(__rhs, __lhs);
});
```
Included tests check that:
- Semantics of the iterator-only version is correct.
- Semantics of the predicated version is correct.
- The functions correctly SFINAE out when the first argument is not an
execution policy.
- The `noexcept` policy is followed.
- The `nodiscard` policy is followed.
- `static_assert` verifies iterators' categories.
Part of #99938.
This fixes incorrect expectations in:
```
libcxx/test/std/ranges/range.adaptors/range.adjacent/iterator/member_types.compile.pass.cpp
libcxx/test/std/ranges/range.adaptors/range.zip.transform/iterator/member_types.compile.pass.cpp
libcxx/test/std/ranges/range.adaptors/range.adjacent.transform/iterator/member_types.compile.pass.cpp
```
These iterators define difference_type as `range_difference_t<Base>`.
For `ForwardSizedView` and `InputCommonView`, the `difference_type` of
the underlying iterators is `std::intptr_t` in `test_iterators.h`.
The tests instead assert `std::ptrdiff_t`. That happens to hold on
platforms where `std::intptr_t` and `std::ptrdiff_t` are the same type,
but fails elsewhere.
---------
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
This PR fixes a bug in `std::mersenne_twister_engine::seed(_Sseq&)`
where the initialization twist is bypassed when the vectorized engine
optimization (`_LIBCPP_ABI_VECTORIZED_MERSENNE_TWISTER_ENGINE`) is
enabled.
In the vectorized implementation introduced in #206423, the engine state
must be pre-twisted during initialization by calling
`__update_all_states()` at the end of the `seed` functions.
However, in `seed(_Sseq& __q)`, the all-zero state check contains an
early `return;` when a non-zero state is verified. This early return
bypasses the trailing `__update_all_states()` call. Consequently, the
generator is initialized with raw, untwisted seed values (tempered)
rather than the standard twisted values.
This only manifests when compiled with unstable ABI settings
(`_LIBCPP_ABI_VERSION >= 2`) which enables the vectorized
implementation.
I replaced the early `return;` inside the all-zero state verification
block with a loop break, and conditionalized the zero-state fix using
the loop index `__i`, ensuring `__update_all_states()` is always
executed at the end of the function. Added regression tests to
`seed_sseq.pass.cpp` asserting the exact deterministic outputs for both
32-bit and 64-bit engines.
Implements https://wg21.link/P3059R2 (DR)
Closes#189599
1. Made constructors of iterator and sentinel types of the following
views private:
- `iota_view`
- `basic_istream_view`
- `filter_view`
- `transform_view`
- `take_view`
- `take_while_view`
- `join_view`
- `lazy_split_view`
- `split_view`
- `elements_view`
2. Updated all relevant tests to fix the usages of the now private
constructor, including:
1. Removed now obsolete tests (files and cases).
2. Updated all relevant tests to get the iterators and the sentinels via
`begin()` and `end()`, wherever applicable .
3. Added test cases to confirm that P3059R2 was implemented properly.
4. Minor other (necessary) tweaks.
---------
Co-authored-by: Hristo Hristov <zingam@outlook.com>
Co-authored-by: A. Jiang <de34@live.cn>
We have multiple macros for different Windows. However, most of them
don't actually define different things. We can condense the macros to
- `_WIN32` directly if it only depends on windows, or
- `_LIBCPP_MSVCRT`
This patch drops `_LIBCPP_MSVCRT_LIKE` and `_LIBCPP_WIN32API`, since
they are equivalent to `_WIN32`.
These two papers also added parallel algorithm overloads, which were
never implemented but the papers were still marked as implemented. Mark
the papers as Partial instead.
CF #103640 and #104095
This refactors `streambuf` to contain a `_GetArea` and a `_PutArea`.
This makes the code significantly easier to read, since the pointers
belonging together are bundled in a struct.
Certain headers require `optional<T&>`, so it may be beneficial to split
out `optional<T>` and `optional<T&>`. This can allow consumers to only
bring in the `optional` flavour it needs..
- Parcel out the respective pieces into their own header.
- Certain sources rely on transitive includes brought in by
`<optional>`, so they're kept there for now, and only tests have been
fixed.
---------
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
This PR implements a parallel `std::adjacent_find()` based on parallel
`std::mismatch`. The implementation reshapes the input range as two ranges
offset by 1 element and asks `std::mismatch` to find the first equal pair.
Part of #99938.
We don't support any compilers which don't have the atomic builtins, so
we don't need to check whether they exist. There is also no need for an
anonymous namespace, since all the functions are inline.
This verifies that libc++ has implemented the resolution of LWG3133,
which modernizes the requirements on `T` for `std::complex<T>` and
`std::valarray<T>` in [numeric.requirements].
- No code changes were needed for `std::valarray<T>`: its `operator[]`
already indexes through a raw pointer and never relies on a
user-overloadable `operator&`, so it already conforms to the revised
wording.
- Added o`perator_hijacker`-based tests to `valarray`'s
`access.pass.cpp`/`const_access.pass.cpp`, confirming `operator[]`
doesn't rely on a user-overloadable `operator&`.
The sequence containers were registered for 32, 1024 and 8192. This
patch drops the mid-size point to get roughly a 30% speedup when running
the benchmarks.
The string benchmarks instantiated every benchmark for char, char8_t and
wchar_t. char8_t exercises the same code paths as char, so drop it to
get roughly a 30% speedup on this benchmark time.
Rather than removing the escape hatches for trivially default
constructible allocator and bitset's const reference type in LLVM 24,
keep them around for another release since they have not been widely
deployed yet.
After #206453 we don't correctly handle `unget()` anymore. This fixes
the issue by updating the internal buffer to contain the tail of the
read data.
Fixes#210203
It was intentional in https://llvm.org/PR204116 that tests for
`operator<<`, `operator<<=`, `operator>>`, `operator>>=` used `bool`
operands, because `bool` is an integral type and thus satisfies the
constraints of these operators.
However, MSVC considers `bool` is unsafe as an operand of bitwise shift
operators and emits warning C4804. So this patch suppresses the warning
for MSVC.
Currently, library support for `_BitInt(N)` is an extension explicitly
supported by libc++. However, when using Clang with other standard
library implementations, `TEST_HAS_BITINT` is currently `1` as the
condition only detects compiler support of `_BitInt`.
This patch disables `_BitInt` coverage for other implementations for
now.
This does two things:
- replace `_Not<T>::value` with `!T::value` when we already evaluate
lazily
- remove `_And`s that aren't useful because they only have a single
argument
Fixes#99984
Implement P0528R3 The Curious Case of Padding Bits, Featuring Atomic
Compare-and-Exchange
The unit test padding.pass.cpp is assisted by Cursor. However, all tests
have been modified to test what I wanted to test
---------
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
The LNT instance on http://lnt.llvm.org was wiped since I created the
original schema, and we can now start over clean with a new test suite
named `libcxx`.
`__grow_by` is an internal function, and we deprecated it to avoid
accidental use of it inside the library. `_LIBCPP_DEPRECATED_` is meant
for user-configuration, which doesn't apply here.
Fixes#124940