This makes __debug_three_way_comp consistent with __debug_less and
in particular gets rid of a potential use-after-move caused by the
use of std::forward. In the previous version of the code, we would
call `__do_compare_assert` after forwarding the arguments into the
comparator, which could end up using the arguments after they've been
moved from.
This also simplifies how we call `__do_compare_assert` by using
`if constexpr` and adds a missing test for proxy iterators in
lexicographical_compare_three_way, which could have found this
issue.
Differential Revision: https://reviews.llvm.org/D152753
This file was reformatted using the Black tool, which led to entirely
unreadable code due to how lines are broken. Formatting tools are fine,
but not when they lead to code that humans have trouble reading. In the
case of features.py, a lot of it was meant to be aligned in a repetitive
but consistent way to make the structure of the code stand out.
Reformatting with the tool lost that property.
Differential Revision: https://reviews.llvm.org/D152737
Some tests in our test suite are unbelievably slow on GCC due to the
use of the always_inline attribute. See [1] for more details.
This patch introduces the GCC-ALWAYS_INLINE-FIXME lit feature to
disable tests that are plagued by that issue. At the same time, it
moves several existing tests from ad-hoc `UNSUPPORTED: gcc-12` markup
to the new GCC-ALWAYS_INLINE-FIXME feature, and marks the slowest tests
reported by the CI as `UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME`.
[1]: https://discourse.llvm.org/t/rfc-stop-supporting-extern-instantiations-with-gcc/71277/1
Differential Revision: https://reviews.llvm.org/D152736
[libc++] Android temp dir is /data/local/tmp, enable Windows test
On Android, std::filesystem::temp_directory_path() should fall back to
/data/local/tmp when no environment variable is set. There is no /tmp
directory. Most apps can't access /data/local/tmp, but they do have a
"cache dir" (Context#getCacheDir()) that is usable for temporary files.
However, there is no obvious and reliable way for libc++ to query this
directory in contexts where it is available. The global fallback
/data/local/tmp is available for "adb shell", making it useful for test
suites.
On Windows, temp_directory_path falls back to the Windows directory
(e.g. "C:\Windows"), so call GetWindowsDirectoryW to do the test.
Reviewed By: ldionne, #libc, enh
Differential Revision: https://reviews.llvm.org/D137131
This is an extension and only adds the functions that are a considered a
but when called and ignoring the result.
Drive-by sort all nodiscard extensions in the documentation.
Reviewed By: #libc, philnik
Differential Revision: https://reviews.llvm.org/D152097
Implements parts of P1614R2:
- Removed global `operator!=` from `allocator`
Reviewed By: #libc, Mordante
Differential Revision: https://reviews.llvm.org/D152612
Depends on D146066
Depends on D132268
Implements parts of P1614R2 `operator<=>` for `stack`
Reviewed By: #libc, Mordante
Differential Revision: https://reviews.llvm.org/D146094
Implements part of P1614R2 "The Mothership has Landed"
Depends on D150188
Reviewed By: Mordante, #libc
Differential Revision: https://reviews.llvm.org/D132268
An issue with `operator()` was found during the implementation of https://reviews.llvm.org/D132268.
This patch aims to resolve the issues by updating the operator to use perfect forwarding.
The original motivation for `three_way_comp_ref_type` is given in: https://reviews.llvm.org/D131395
`three_way_comp_ref_type`'s implementation is inspired by `comp_ref_type`, which has two overloads:
```
template <class _Tp, class _Up>
bool operator()(const _Tp& __x, const _Up& __y);
template <class _Tp, class _Up>
bool operator()(_Tp& __x, _Up& __y);
```
`__debug_three_way_comp` is missing the first overload and also declares the typealias`_three_way_comp_ref_type ` incorrectly.
Reviewed By: #libc, philnik
Differential Revision: https://reviews.llvm.org/D150188
These concepts are used to ensure valid iterators are passed to PSTL algorithms, but can also be used for other interfaces.
Reviewed By: ldionne, #libc
Spies: EricWF, libcxx-commits
Differential Revision: https://reviews.llvm.org/D150493
This checks whether a pointer is within a range, even during constant evaluation. This allows running optimized code paths during constant evaluation, instead of falling back to the general-purpose implementation all the time. This is also a central place for comparing unrelated pointers, which is technically UB.
Reviewed By: ldionne, #libc
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D143327
This makes it clearer that the availability macro only pertains to
<filesystem>, and not to whether the platform has support for a file
system.
Differential Revision: https://reviews.llvm.org/D152172
LIBCXX_ENABLE_FILESYSTEM should represent whether the platform has
support for a filesystem, not just whether we support <filesystem>.
This patch slightly generalizes the setting to also encompass whether
we provide <fstream>, since that only makes sense when a filesystem is
supported.
Differential Revision: https://reviews.llvm.org/D152168
This simplifies the usage of `__less` by making the class not depend on the types compared, but instead the `operator()`. We can't remove the template completely because we explicitly instantiate `std::__sort` with `__less<T>`.
Reviewed By: ldionne, #libc
Spies: arichardson, EricWF, libcxx-commits, mgrang
Differential Revision: https://reviews.llvm.org/D145285
Back in 2020 [1], we went very close to enabling Filesystem on MSVC
by disabling int128_t, but decided to wait because MSVC support
for int128_t was supposed to come shortly after. Since it's not
there yet, I propose turning off int128_t support by default on MSVC.
This will make <filesystem> available by default on MSVC, and most
importantly will open the possibility for changing
LIBCXX_ENABLE_FILESYSTEM to mean "the system doesn't have support
for a filesystem" instead of simply "don't build the std::filesystem
library", which is what I'm really after with this change.
In a way, this is a resurection of D91139.
[1]: https://reviews.llvm.org/D91139#2429595
Differential Revision: https://reviews.llvm.org/D134912
Instead of guarding header tests using #ifdefs inside the tests,
use Lit markup to mark all the tests as unsupported. This is simpler
but also provides better feedback about which tests are being run
when running the test suite.
Differential Revision: https://reviews.llvm.org/D151893
CMake older than 3.20.0 is no longer supported.
This removes work-arounds for no longer supported versions.
Reviewed By: #libc, jloser, philnik
Differential Revision: https://reviews.llvm.org/D152099
- add the `from_range_t` constructors and the related deduction guides;
- add the `push_range` member function.
(Note: this patch is split from https://reviews.llvm.org/D142335)
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D149829
This makes it less ambiguous what the parameter is meant to get.
Reviewed By: #libc, ldionne
Spies: ldionne, libcxx-commits
Differential Revision: https://reviews.llvm.org/D152040
This finishes the transition of tests covered in generate_header_tests.py
to the new .gen.py format.
Differential Revision: https://reviews.llvm.org/D152008
On Windows, the underlying file descriptors for stdout/stdin/stderr
can be reconfigured to wide mode. In the default (narrow) mode, the
charset usually isn't utf8 (as libcxx assumes), but normally a locale
specific codepage (where each codepage only can represent a small
subset of unicode characters).
By configuring the stdout file descriptor to wide mode, the user can
output wchar_t based strings without convesion to the narrow charset.
Within libcxx, don't try to use codecvt to convert this to a narrow
character encoding, but output these strings as such with fputwc.
In wide mode, such strings could be output directly with fwrite too,
but if the file descriptor hasn't been configured in wide mode, that
breaks the output (which currently works reasonably). By always
outputting one character at a time with fputwc, it works regardless
of mode of the stdout file descriptor.
For the narrow output stream, std::cout, outputting (via fwrite)
does fail when the file descriptor is set to wide mode. This matches
how it behaves with both MS STL and GNU libstdc++ too, so this is
probably acceptable.
This fixes https://github.com/llvm/llvm-project/issues/46646, and
the downstream bugs https://github.com/mstorsjo/llvm-mingw/issues/145
and https://github.com/mstorsjo/llvm-mingw/issues/222.
Differential Revision: https://reviews.llvm.org/D146398
In addition to reducing the amount of boilerplate we need to generate
whenever a new header is added, this also improves the existing tests
by running them in separate Lit tests (so they can be parallelized).
This also creates separate translation units for most header tests,
which is what we really should have done from the start since it
isolates each header we're testing.
Differential Revision: https://reviews.llvm.org/D151654
This allows removing a bunch of boilerplate from the test suite and
reducing the amount of manual stuff contributors have to do when they
add a new public header.
Differential Revision: https://reviews.llvm.org/D151830