Commit Graph

10541 Commits

Author SHA1 Message Date
Mark de Wever
ffe0495105 [NFC][libc++] Addresses LWG3927.
Changes to preconditions have no impact on the library.

Implements
- LWG3927 Unclear preconditions for operator[] for sequence containers

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153286
2023-06-20 17:19:55 +02:00
Mark de Wever
946116fc05 [NFC][libc++] Addresses LWG3935.
Note libc++ implemented this in its initial version.

Implements
- LWG3935 template<class X> constexpr complex& operator=(const complex<X>&) has no specification

Reviewed By: #libc, philnik, ldionne

Differential Revision: https://reviews.llvm.org/D153287
2023-06-20 17:16:06 +02:00
Louis Dionne
2da049a141 [libc++] Add incomplete availability markup for std::pmr
This fixes rdar://110330781, which asked for the feature-test macro
for std::pmr to take into account the deployment target. It doesn't
fix https://llvm.org/PR62212, though, because the availability markup
itself must be disabled until some Clang bugs have been fixed.

This is pretty vexing, however at least everything should work once
those Clang bugs have been fixed. In the meantime, this patch at least
adds the required markup (as disabled) and ensures that the feature-test
macro for std::pmr is aware of the deployment target requirement.

Differential Revision: https://reviews.llvm.org/D135813
2023-06-20 10:59:05 -04:00
Louis Dionne
3350ec9b3e [libc++] Add missing 'return 0' from main functions in tests 2023-06-19 13:43:34 -04:00
Louis Dionne
1288e72d10 [libc++][NFC] Sort header list in header_information.py 2023-06-19 11:54:04 -04:00
Louis Dionne
5aa03b648b [libc++][NFC] Apply clang-format on large parts of the code base
This commit does a pass of clang-format over files in libc++ that
don't require major changes to conform to our style guide, or for
which we're not overly concerned about conflicting with in-flight
patches or hindering the git blame.

This roughly covers:
- benchmarks
- range algorithms
- concepts
- type traits

I did a manual verification of all the changes, and in particular I
applied clang-format on/off annotations in a few places where the
result was less readable after than before. This was not necessary
in a lot of places, however I did find that clang-format had pretty
bad taste when it comes to formatting concepts.

Differential Revision: https://reviews.llvm.org/D153140
2023-06-19 11:19:51 -04:00
Mark de Wever
f805c799bf [libc++] "Implements" new SI prefixis.
Like yocto, zepto, zetta, and yotta. The new prefixes quecto, ronto,
ronna, and quetta can't be implemented in a intmax_t. So their
implementation does nothing.

Implements
- P2734R0 Adding the new SI prefixes

Depends on D153192

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153200
2023-06-19 17:04:35 +02:00
Mark de Wever
cdcfc5ec9b [libc++][regex] Removes operator!=.
Implements part of:
- P1614R2 The Mothership has Landed

Reviewed By: #libc, H-G-Hristov, philnik

Differential Revision: https://reviews.llvm.org/D153222
2023-06-19 17:01:56 +02:00
Mark de Wever
a4f0764aef [libc++] Marks __cpp_lib_bitops as implemented.
This FTM was introduced in
  P0553R4 Bit operations

Which has been implemented since libc++ 9.

This was noticed while working on D153192.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153225
2023-06-19 17:01:27 +02:00
Mark de Wever
3f05d044f4 [libc++] Update status after Varna meeting.
This updates:
- The status tables
- Feature test macros
- New headers for modules
The latter avoids forgetting about modules when implementing the feature
in a new header.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153192
2023-06-19 16:55:30 +02:00
Louis Dionne
3956a34e4f [libc++] Move non operator new definitions outside of new.cpp
This makes it such that new.cpp contains only the definitions of
operator new and operator delete, like its libc++abi counterpart.

Differential Revision: https://reviews.llvm.org/D153136
2023-06-19 09:46:40 -04:00
Louis Dionne
c7d3c84449 [libc++] Split sources for <filesystem>
The operations.cpp file contained the implementation of a ton of
functionality unrelated to just the filesystem operations, and
filesystem_common.h contained a lot of unrelated functionality as well.

Splitting this up into more files will make it possible in the future
to support parts of <filesystem> (e.g. path) on systems where there is
no notion of a filesystem.

Differential Revision: https://reviews.llvm.org/D152377
2023-06-19 09:07:05 -04:00
Louis Dionne
dc71a77d33 [libc++][NFC] Move several .fail.cpp tests to .verify.cpp
A few tests were also straightforward to translate to SFINAE tests
instead, so in a few cases I did that and removed the .fail.cpp test
entirely.

Differential Revision: https://reviews.llvm.org/D153149
2023-06-19 09:06:13 -04:00
Louis Dionne
d8655fb365 [libc++][NFC] Rename __lower_bound_impl to __lower_bound
For consistency with other algorithms.

Differential Revision: https://reviews.llvm.org/D153141
2023-06-19 09:05:14 -04:00
Hristo Hristov
0dda8691b2 [libc++][ranges] Mark views::stride in progress 2023-06-19 11:48:12 +03:00
Hristo Hristov
4f7680ceda [libc++][spaceship][NFC] P1612R2: Mark remove operator!= from "Ranges Library" items as "Complete"
Marked already implemented parts of P1612R2 as "Complete":
- `ranges::iota_view::iterator` https://reviews.llvm.org/D110774
- `iota_view::sentinel` https://reviews.llvm.org/D107396
- `filter_view::iterator` https://reviews.llvm.org/D109086
- `filter_view::sentinel` https://reviews.llvm.org/D109086
- `ranges::transform_view::iterator` https://reviews.llvm.org/D110774
- `transform_view::sentinel` https://reviews.llvm.org/D103056
- `take_view::sentinel` https://reviews.llvm.org/D123600
- `join_view::iterator` https://reviews.llvm.org/D107671
- `join_view::sentinel ` https://reviews.llvm.org/D107671
- `split_view::outer_iterator` https://reviews.llvm.org/D142063
- `split_view::inner_iterator` https://reviews.llvm.org/D142063

Note these operators were added and removed in C++20.

Reviewed By: Mordante, #libc

Differential Revision: https://reviews.llvm.org/D152721
2023-06-18 21:18:40 +03:00
Hui
cea4285949 [libc++][NFC] Granularise <thread> header
- This was to make implementing jthread easier and requested in https://reviews.llvm.org/D151559

Differential Revision: https://reviews.llvm.org/D151792
2023-06-17 12:28:52 +01:00
Louis Dionne
100cb5bacc [libc++] Fix signedness comparison issue on GCC in a test 2023-06-16 13:30:58 -04:00
Mark de Wever
b72a7cb320 [libc++][doc] Move not yet adopted issues to C++26.
The development of C++23 is complete, so these issues will be adopted in
C++26 (or later).

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153053
2023-06-16 17:39:08 +02:00
Nikolas Klauser
31eeba3f7c [libc++] Introduce __make_uninitialized_buffer and use it instead of get_temporary_buffer
This will also be used in some PSTL backends.

Reviewed By: ldionne, #libc, Mordante

Spies: arichardson, mstorsjo, Mordante, sstefan1, jplehr, libcxx-commits

Differential Revision: https://reviews.llvm.org/D152208
2023-06-16 07:53:56 -07:00
Louis Dionne
5e73fda53c [libc++][NFC] Consistently qualify malloc and free calls with std:: 2023-06-16 09:40:31 -04:00
Louis Dionne
d53cf0fdd1 [libc++] Make libc++ and libc++abi's definitions of operator new be exact copies
This allows mechanically copying any changes made to `operator new`
from libc++ into libc++abi as-is. This is also a step towards
de-duplicating this code entirely.

Differential Revision: https://reviews.llvm.org/D153035
2023-06-16 09:40:08 -04:00
Louis Dionne
f7679bcfb6 [libc++][NFC] Reformat params.py
After the Black reformatting changes, the code became pretty hard to
read and inconsistently formatted. This fixes that.

Differential Revision: https://reviews.llvm.org/D152839
2023-06-15 14:46:14 -04:00
Nikolas Klauser
3a7876f6e2 [libc++][PSTL] Implement std::is_partitioned
Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D152853
2023-06-15 11:23:07 -07:00
Nikolas Klauser
b935ab8e74 [libc++] Add tests to make sure that stable algorithms work without memory available
Reviewed By: #libc, ldionne

Spies: power-llvm-team, ldionne, libcxx-commits, arichardson, mstorsjo

Differential Revision: https://reviews.llvm.org/D152939
2023-06-15 10:59:34 -07:00
Mark de Wever
9b08c8a225 [libc++][modules] Adds the C++23 std module.
The patch is based on D144994.

D151030 added the module definitions for the module std.
This patch wires in the module and enables the basic testing.

Some notable features are missing:
- There is no test that libc++ can be fully imported as a module.
- This lacks the parts for the std.compat module.
- The module is not shipped with libc++.

Implements parts of
- P2465R3 Standard Library Modules std and std.compat

Reviewed By: ldionne, aaronmondal, #libc

Differential Revision: https://reviews.llvm.org/D151814
2023-06-15 18:14:15 +02:00
Mark de Wever
6551e59802 [libc++][modules] Update the .cppm files.
There are some minor fixes in the definiton and it is synced with
upstream changes.

This has been reviewed as part of D151814.
2023-06-15 18:12:06 +02:00
Nikolas Klauser
f1ea0b11ca [libc++] Merge _LIBCPP_FUNC_VIS, _LIBCPP_TYPE_VIS and _LIBCPP_EXCEPTION_ABI into _LIBCPP_EXPORTED_FROM_ABI
These macros are always defined identically, so we can simplify the code a bit by merging them.

Reviewed By: ldionne, #libc

Spies: libcxx-commits, krytarowski, smeenai

Differential Revision: https://reviews.llvm.org/D152652
2023-06-15 08:56:45 -07:00
Louis Dionne
fa90e2b988 [libc++] Don't automatically define LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS with libcxxrt
libcxxrt is only used on FreeBSD and the FreeBSD CMake cache already
sets LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS to ON, as it should. This
avoids defining LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS redundantly in
a place where it doesn't belong.

Differential Revision: https://reviews.llvm.org/D152971
2023-06-15 11:23:45 -04:00
Louis Dionne
aee3a9f5bc [libc++][NFC] clang-format new_handler.cpp 2023-06-15 11:14:26 -04:00
Louis Dionne
80e4ccab79 [libc++] Move the definition of std::new_handler out of new.cpp
This reduces the difference between libc++'s new.cpp and libc++abi's
stdlib_new_delete.cpp files, which are essentially copies of each other.

Differential Revision: https://reviews.llvm.org/D152956
2023-06-15 11:14:14 -04:00
Hristo Hristov
e7e36d56d6 [libc++][ranges][NFC] Status page: Adds views::enumerate 2023-06-15 00:53:15 +03:00
Hristo Hristov
9838dd7f76 [libc++][spaceship][NFC] P1614R2: Status page - mark header synopsis sections as "Complete"
Header synospis sections of P1614R2 are implemented by other items usually. For completeness, let's mark some of them as "Complete".

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D152775
2023-06-15 00:28:10 +03:00
Louis Dionne
3456b2f60a [libc++] Refactor __debug_three_way_comp
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
2023-06-13 14:24:56 -07:00
Louis Dionne
52310ce9c1 [libc++][NFC] Reformat features.py
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
2023-06-13 10:24:46 -07:00
Louis Dionne
520c7fbbd0 [libc++] Mark slow tests as unsupported on GCC
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
2023-06-13 10:20:30 -07:00
Nikolas Klauser
7d3bba5e2f [libc++] Add [[nodiscard]] extensions to the functions in <bit>
Reviewed By: #libc, ldionne, Mordante

Spies: Mordante, ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D152653
2023-06-13 08:01:34 -07:00
Nikolas Klauser
cd916108b4 [libc++][PSTL] Implement std::generate{,_n}
Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D152581
2023-06-13 07:55:06 -07:00
Hristo Hristov
7928ac4e6a [libc++][spaceship] P1612R2: Removed operator!= from locale
Implemented parts of P1612R2:
- Removed `operator!=` from `locale`

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D152654
2023-06-13 07:47:13 +03:00
Hristo Hristov
5a53323d2c [libc++][spaceship][NFC] P1612R2: Mark some items "remove operator!= from *_iterator" as "Complete"
Several parts of P1612R2 are already implemented:
- `common_iterator` (new in C++20) https://reviews.llvm.org/D103335
- `unreachable_sentinel_t` (new in C++20) https://reviews.llvm.org/D107920
- `istream_iterator` (removed) https://reviews.llvm.org/D119620
- `istreambuf_iterator` (removed) https://reviews.llvm.org/D119620

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D152656
2023-06-13 07:44:01 +03:00
Ryan Prichard
1da06804e1 [libc++] Android temp dir is /data/local/tmp, enable Windows test
[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
2023-06-12 20:43:00 -07:00
Nikolas Klauser
ab028d8006 [libc++][PSTL] Update papers and add a status page for the algorithms
Reviewed By: #libc, ldionne

Spies: libcxx-commits, mgrang, arphaman

Differential Revision: https://reviews.llvm.org/D152578
2023-06-12 16:46:06 -07:00
Louis Dionne
d167fe0c4e [libc++][NFC] Refactor filesystem namespace test 2023-06-12 12:43:19 -07:00
Hristo Hristov
0029ad89e8 [libc++][spaceship] P1614R2: Removed operator!= from weekdays
Implements parts of P1614R2. Removed `operator!=` from:
- `weekday`
- `weekday_indexed`
- `weekday_last`
- `month_weekday`
- `month_weekday_last`
- `year_month_weekday`
- `year_month_weekday_last`

Note these operators were added and removed in C++20.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D152699
2023-06-12 22:22:22 +03:00
Mark de Wever
9c053e6993 [libc++][format] Make public functions nodiscard.
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
2023-06-12 18:55:56 +02:00
Hristo Hristov
a9e0321ffe [libc++][spaceship] P1614R2: Added operator== to file_status
Implemented parts of P1614R2:
- Added `operator==` to `file_status`

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D152647
2023-06-12 19:53:50 +03:00
Hristo Hristov
8cf3c2920d [libc++][spaceship] P1614R2: Removed operator!= from scoped_allocator_adaptor
Implements parts of P1614R2
- Removed `operator!=` from `scoped_allocator_adaptor`

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D152678
2023-06-12 19:51:27 +03:00
Hristo Hristov
9a6ca67397 [libc++][spaceship] P1614R2: Removed operator!= from functional
Implements parts of P1614R2:
- Removed `operator!=` from `functional`

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D152704
2023-06-12 19:48:42 +03:00
Hristo Hristov
d1ef99fe1c [libc++][spaceship] P1614R2: Removed global operator!= from allocator
Implements parts of P1614R2:
- Removed global `operator!=` from `allocator`

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D152612
2023-06-12 09:41:56 +03:00
Hristo Hristov
7c96cd35bf [libc++][spaceship] P1612R2: Removed operator!= from bitset
Implements parts of P1612R2:
- Removed `operator!=` from `bitset`

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D152611
2023-06-12 09:26:51 +03:00