Commit Graph

9028 Commits

Author SHA1 Message Date
Konstantin Varlamov bcdb11e741 [libc++][NFC] Reindent `take_view` in accordance with the style guide. 2022-04-18 20:54:50 -07:00
Richard Smith e43c93dd63 Don't treat 'T &forward(T&&)' as builtin.
This allows the standard library to diagnose it properly. Suppress
warning in libc++ testsuite for unused result of call to std::forward.
2022-04-18 11:11:21 -07:00
Richard Smith c105bcbf98 Specify -fno-builtin when testing to make sure that certain stdlib
functions are not treated as [[nodiscard]].

The compiler might choose to treat them as [[nodiscard]] without the
involvement of libc++ if we allow it to recognize them as builtins.
2022-04-17 19:41:34 -07:00
Jonathan Wakely ef94609d6e [libcxx] [test] Use LIBCPP_ASSERT for libc++-specific checks
This makes it a little easier to reuse the libc++ tests for another
std::lib (specifically libstdc++).

The regex_error::what() strings are different in other
implementations, so should be tested with LIBCPP_ASSERT so that those
checks are skipped for other implementations.

The value of ECMAScript constant is non-zero in other implementations,
and conditionally for libc++, so adjust the preprocessor condition for
that too.

Reviewed By: ldionne, #libc, philnik, Mordante

Spies: Mordante, philnik, libcxx-commits

Differential Revision: https://reviews.llvm.org/D122574
2022-04-17 01:23:24 +02:00
Nikolas Klauser 1d83750f63 [libc++] Implement ranges::copy{, _n, _if, _backward}
Reviewed By: Mordante, var-const, #libc

Spies: sstefan1, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D122982
2022-04-15 13:44:11 +02:00
Louis Dionne c4f059e509 [libc++][NFC] Add missing 'return 0' to test 2022-04-14 16:08:43 -04:00
Mark de Wever 48fbcedb38 [libc++] Adds a missing include.
This fixes the modular build.
2022-04-14 19:28:00 +02:00
Fabian Wolff 4ff70dba38 [libc++] Fix undefined behavior in `std::filebuf`
Fixes https://github.com/llvm/llvm-project/issues/49267.
Fixes https://github.com/llvm/llvm-project/issues/49282.
Fixes https://github.com/llvm/llvm-project/issues/49789.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D122257
2022-04-14 16:20:51 +02:00
Nikolas Klauser 58d9ab70ae [libc++][ranges] Implement ranges::minmax and ranges::minmax_element
Reviewed By: var-const, #libc, ldionne

Spies: sstefan1, ldionne, BRevzin, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D120637
2022-04-14 15:37:22 +02:00
Nikolas Klauser 667925d45a [libc++] `bitset::operator[] const` should return bool
Fixes https://github.com/llvm/llvm-project/issues/10686

Reviewed By: Mordante, ldionne, var-const, #libc

Spies: jloser, libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D122092
2022-04-13 22:55:04 +02:00
Louis Dionne 1352ea4ea1 [libc++] Mark completed paper as complete 2022-04-13 10:16:44 -04:00
Louis Dionne db6421ec58 [libc++] Post-commit adjustments after rebasing D117656 2022-04-13 09:51:43 -04:00
Arthur O'Dwyer 2fb026ee4d Implement move_sentinel and C++20 move_iterator.
Differential Revision: https://reviews.llvm.org/D117656
2022-04-13 09:51:43 -04:00
Louis Dionne 2b424f4ea8 [libc++] Implement ranges::filter_view
Differential Revision: https://reviews.llvm.org/D109086
2022-04-13 09:03:46 -04:00
Konstantin Varlamov e53c461bf3 [libc++][ranges] Implement `lazy_split_view`.
Note that this class was called just `split_view` in the original One
Ranges Proposal and was renamed to `lazy_split_view` by
[P2210](https://wg21.link/p2210).

Co-authored-by: zoecarver <z.zoelec2@gmail.com>

Differential Revision: https://reviews.llvm.org/D107500
2022-04-12 22:28:38 -07:00
Yuanfang Chen 81b51b61f8 Fix libcxx build after cd0a5889d7 2022-04-12 15:42:56 -07:00
Louis Dionne 0cc34ca7ec [libc++] Define legacy symbols for inline functions at a finer-grained level
When we build the library with the stable ABI, we need to include some
functions in the dylib that were made inline in later versions of the
library (to avoid breaking code that might be relying on those symbols).

However, those methods were made non-inline whenever we'd be building
the library, which means that all translation units would end up using
the old out-of-line definition of these methods, as opposed to the new
inlined version. This patch makes it so that only the translation units
that actually define the out-of-line methods use the old definition,
opening up potential optimization opportunities in other translation
units.

This should solve some of the issues encountered in D65667.

Differential Revision: https://reviews.llvm.org/D123519
2022-04-12 13:44:30 -04:00
Mark de Wever 7738db2c06 [NFC][libc++][test] Move time tests.
In the C++20 Standard time is no longer section under utilities, but
became its own chapter. This moves the time tests accordingly so their
location matches the current Standard.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122745
2022-04-12 17:49:48 +02:00
Louis Dionne 8b5e4c038e [runtimes][CI] Add a 20 minutes individual test time out
If a single test has been running for more than 20 minutes on a CI node,
something is wrong and it should time-out instead of running until the
node potentially times out itself.

Differential Revision: https://reviews.llvm.org/D114896
2022-04-11 17:47:05 -04:00
zijunzhao 2d0475e371 [libcxx] locale_bionic.h: skip ndk-version.h on Android platform
The Android platform does not have ndk-version.h, but it will always
have up-to-date libc headers, so it does not need any compatibility
code intended for past versions of NDK_MAJOR. If ndk-version.h is missing,
assume NDK_MAJOR is (conceptually) infinite

Bug: https://buganizer.corp.google.com/issues/222341313
Test: None
2022-04-11 17:51:12 +00:00
Martin Storsjö 64e4dd329c [libcxx] [test] Fix back-to-back use of get_temp_file_name() on Windows
On non-Windows platforms, get_temp_file_name() uses `mkstemp()`,
which picks a unique name and creates a file atomically. The
Windows implementation uses `_mktemp_s()`, which doesn't create the
file. The documentation of `_mktemp_s()` also says that by design,
the function uses the same pattern within a process, as long as that
file doesn't exist.

Thus previously, two consecutive calls to `get_temp_file_name()`
on Windows returned the same file name.

Try to create the suggested temp file with `_O_EXCL` (marking the
file name as already used for future calls to `_mktemp_s`) and retry
if we weren't able to exclusively create the file.

This fixes the test failures on Windows observed in D122257.

Differential Revision: https://reviews.llvm.org/D122612
2022-04-11 19:46:40 +03:00
Louis Dionne b9ca1e5a5a [libc++][NFC] Use noexcept instead of _NOEXCEPT for code compiled into the library
We build the library with C++20 anyways, so we can use noexcept directly.
2022-04-11 12:30:38 -04:00
Louis Dionne c292b6066c [libc++] Implement P1007R3: std::assume_aligned
This supersedes and incoroporates content from both D108906 and D54966,
and also some original content.

Co-Authored-by: Marshall Clow <mclow.lists@gmail.com>
Co-Authored-by: Gonzalo Brito Gadeschi

Differential Revision: https://reviews.llvm.org/D118938
2022-04-11 10:46:52 -04:00
Louis Dionne 2c6217f252 [libc++] Make .version.pass.cpp tests be compile-only tests
We don't really need to run them.
2022-04-11 10:40:04 -04:00
Nikolas Klauser 732920d847 [libc++] Remove the usage of __init in operator+
`operator+` currently calls `__init`. This patch removes the usage of implementation details.

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D123058
2022-04-11 15:59:52 +02:00
Nikolas Klauser aed0e8b805 [libc++] Rename the template arguments of the algorithm result types
Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D123463
2022-04-10 14:22:13 +02:00
Nikolas Klauser a96443edde [libc++] Implement P0401R6 (allocate_at_least)
Reviewed By: ldionne, var-const, #libc

Spies: mgorny, libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D122877
2022-04-09 16:03:45 +02:00
Mark de Wever fb9a692be5 [libc++][format][4/6] Improve formatted_size.
Use a specialized "buffer" to count the number of insertions instead of
using a `string` as storage type.

Depends on D110497.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D110498
2022-04-09 09:36:29 +02:00
Mark de Wever 889302292b [libc++][format][3/6] Adds a __container_buffer.
Instead of writing every character directly into the container by using
a `back_insert_iterator` the data is buffered in an `array`. This buffer
is then inserted to the container by calling its `insert` member function.

Since there's no guarantee every container's `insert` behaves properly
containers need to opt-in to this behaviour. The appropriate standard
containers opt-in to this behaviour.

This change improves the performance of the format functions that use a
`back_insert_iterator`.

Depends on D110495

Reviewed By: ldionne, vitaut, #libc

Differential Revision: https://reviews.llvm.org/D110497
2022-04-09 09:35:48 +02:00
Louis Dionne 72cd50b6fd [libc++] Add missing 'return 0;' to main() in test 2022-04-08 17:10:58 -04:00
Nilay Vaish f950ba004b [libcxx][NFC] Format sort.h
This is to simplify the changes made in D122780.  This diff was generated using the command:

```
clang-format include/__algorithm/sort.h  -i
```

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D122858
2022-04-08 17:05:02 -04:00
Gustavo Henrique Nihei 4fe6a5d69a [libc++] Rename PS() macro to avoid clashing with Xtensa register name
This patch addresses a clash with the PS register from Xtensa
defined in the <specreg.h> header file, which is commonly included in
OS implementation.

Issue identified while building libc++ port for Apache NuttX, targeting
Xtensa-based chips (e.g. Espressif's ESP32).

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

Differential Revision: https://reviews.llvm.org/D122479
2022-04-08 17:00:29 -04:00
Azat Khuzhin c3d0205ee7 [libc++] Avoid using anonymous struct with base classes (fixes GCC 12)
GCC 12 reports:

     libcxx/include/string:727:13: error: anonymous struct with base classes
     727 |             : __padding<value_type>

Differential Revision: https://reviews.llvm.org/D122598
2022-04-08 16:14:44 -04:00
Mark de Wever d49c0ba5ab [libc++][test] Use the Japanese locale.
This change is done to see whether all platforms have a CI with the
Japanese locale installed.

This wires in the locale in the tests and uses it in one test. This is
a preparation for the tests of the chrono formatters.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122738
2022-04-08 20:00:34 +02:00
Mark de Wever 476047bf8e [libc++] Adds back_insert_iterator::__get_container.
Adds a `__get_container` member as suggested by @Quuxplusone in D110497.

Includes  s/_LIBCPP_INLINE_VISIBILITY/_LIBCPP_HIDE_FROM_ABI/.

Reviewed By: Quuxplusone, #libc, ldionne

Differential Revision: https://reviews.llvm.org/D110573
2022-04-08 17:13:50 +02:00
Mark de Wever 7277b00a29 [NFC][libc++][format] Prepare unit tests.
Before implementing P2216's format-string adjust the unit tests.
After P2216 the format* functions require a compile-time string literal.
This changes prepares the tests.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D122534
2022-04-08 17:11:45 +02:00
Nikolas Klauser 08920cc043 [libc++] Add __is_callable type trait and begin granularizing type_traits
`__is_callable` is required to ensure that the classic algorithms are only called with functions or functors. I also begin to granularize `<type_traits>`.

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D123114
2022-04-08 12:23:52 +02:00
Nikolas Klauser 628fcfd520 [libc++] Add tests for std::string default constructor and destructor
Reviewed By: ldionne, var-const, #libc, nilayvaish

Spies: nilayvaish, libcxx-commits

Differential Revision: https://reviews.llvm.org/D123129
2022-04-08 12:21:43 +02:00
Marco Gelmi 194d1965d2 Introduce branchless sorting functions for sort3, sort4 and sort5.
We are introducing branchless variants for sort3, sort4 and sort5.
These sorting functions have been generated using Reinforcement
Learning and aim to replace __sort3, __sort4 and __sort5 variants
for integral types.

The libc++ benchmarks were run on isolated machines for Skylake, ARM and
AMD architectures and achieve statistically significant improvement in
sorting random integers on test cases from sort1 to sort262144 for
uint32 and uint64.

A full performance overview for Intel Skylake, AMD and Arm can be
found here: https://bit.ly/3AtesYf

Reviewed By: ldionne, #libc, philnik

Spies: daniel.mankowitz, mgrang, Quuxplusone, andreamichi, philnik, libcxx-commits, nilayvaish, kristof.beyls

Differential Revision: https://reviews.llvm.org/D118029
2022-04-08 09:00:30 +02:00
Mark de Wever b05027aaf9 Revert "[libc++][format] Use a helper constant."
This reverts commit 82427685ea.

This seems to break the AIX-32 bit build.
2022-04-07 22:40:08 +02:00
Mark de Wever 82427685ea [libc++][format] Use a helper constant.
The code accidentally uses a hard-coded value. Use a constant to make
sure the same value is used at both places.
2022-04-07 19:25:13 +02:00
Arthur Eubanks 0a77e63322 [libcxx] Add flag to disable __builtin_assume in _LIBCPP_ASSERT
Introduce _LIBCPP_ASSERTIONS_DISABLE_ASSUME which makes _LIBCPP_ASSERT
not call __builtin_assume when _LIBCPP_ENABLE_ASSERTIONS == 0.

Calling __builtin_assume was introduced in D122397.

__builtin_assume is generally supposed to improve optimizations, but can
cause regressions when LLVM has trouble handling the calls to
`llvm.assume()` (see comments in D122397).

Reviewed By: philnik

Differential Revision: https://reviews.llvm.org/D123175
2022-04-07 09:00:31 -07:00
Louis Dionne b7042b73a3 [libc++] Add back-deployment testing on arm64 macs
Differential Revision: https://reviews.llvm.org/D123081
2022-04-07 10:15:40 -04:00
Nikolas Klauser 1306b1025c [libc++][ranges] Implement ranges::count{, _if}
Reviewed By: var-const, Mordante, ldionne, #libc

Spies: tcanens, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D121523
2022-04-07 15:18:14 +02:00
Nikolas Klauser 1b9c5f60aa [libc++] Remove redundant __invoke_constexpr functions
There are `constexpr` versions for the different `__invoke` functions, which seem to be identical other than begin `constexpr` since C++11 instead of being `constexpr` since C++20.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D123003
2022-04-07 13:56:11 +02:00
Nikolas Klauser cd7b444078 [libc++][ranges] Add implicit conversion to bool test for ranges::find{, if, if_not}
Reviewed By: ldionne, var-const, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D122011
2022-04-07 12:03:43 +02:00
Martin Storsjö 7594e23679 [libcxx] [test] Stop defining LIBCXX-WINDOWS-FIXME
There are no such markings left - all of them have been fixed or
analyzed.

This closes llvm.org/PR32730 (github issue #32077).

Differential Revision: https://reviews.llvm.org/D123145
2022-04-06 22:54:39 +03:00
Mark de Wever 3fb3770983 [libc++] Use cpp20_output_iterator in tests.
Adds the new cpp20_output_iterator in the ranges::transform test.

Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D123139
2022-04-06 17:48:27 +02:00
Mark de Wever d78624975b [NFC][libc++] Modularize chrono's calendar.
The is a followup of D116965 to split the calendar header. This is a
preparation to add the formatters for the chrono header.

The code is only moved no other changes have been made.

Reviewed By: ldionne, #libc, philnik

Differential Revision: https://reviews.llvm.org/D122995
2022-04-06 17:47:53 +02:00
Louis Dionne e27a122b3a [libc++] Support arrays in make_shared and allocate_shared (P0674R1)
This patch implements P0674R1, i.e. support for arrays in std::make_shared
and std::allocate_shared.

Co-authored-by: Zoe Carver <z.zoelec2@gmail.com>

Differential Revision: https://reviews.llvm.org/D62641
2022-04-06 08:42:55 -04:00