956 Commits

Author SHA1 Message Date
Hristo Hristov
40aaa272f1 [libc++][ranges] P2711R1 Making multi-param constructors of views explicit
Implemented [[ https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2711r1.html | P2711R1 ]] for existing views.
 (`join_with_view` is not yet implemented)

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D144822
2023-03-23 19:30:21 +02:00
Nikolas Klauser
e655d8a548 [libc++] Granularize __mutex_base
This also updates the moved code to the current style. (i.e. `_VSTD` -> `std`, `_LIBCPP_INLINE_VISIBILITY` -> `_LIBCPP_HIDE_FROM_ABI`, clang-format).

Reviewed By: Mordante, #libc, EricWF

Spies: arichardson, libcxx-commits, mikhail.ramalho

Differential Revision: https://reviews.llvm.org/D146228
2023-03-22 20:17:26 +01:00
Hristo Hristov
83542e4764 [libc++][spaceship] Implement operator<=> for duration
Implements parts of [[ https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html | P1614R2 ]]
Implemented `operator<=>` for `std::chrono::duration`

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D145881
2023-03-21 20:06:42 +02:00
Louis Dionne
c0cde79e9e [libc++] Remove C++03 extensions for std::allocator_arg & friends
As explained in the release note, libc++ used to provide various
global variables as an extension in C++03 mode. Unfortunately, that
made our definition non-conforming in all standard modes. This was
never a big problem until recently, since we are trying to support
C++20 Modules in libc++, and that requires cleaning up the definition
of these variables.

This change is the first in a series of changes to achieve our end goal.
This patch removes the ability for users to rely on the (incorrect)
definition of those global variables inside the shared library. The
plan is to then remove those definitions from the shared library
(which is an ABI break but I don't think it will have impact), and
finally to make our definition of those variables conforming in all
standard modes.

Differential Revision: https://reviews.llvm.org/D145422
2023-03-19 10:14:32 -04:00
Sirui Mu
c9d475c937 [libc++abi] Improve performance of __dynamic_cast
The original `__dynamic_cast` implementation does not use the ABI-provided `src2dst_offset` parameter which helps improve performance on the hot paths. This patch improves the performance on the hot paths in `__dynamic_cast` by leveraging hints provided by the `src2dst_offset` parameter. This patch also includes a performance benchmark suite for the `__dynamic_cast` implementation.

Reviewed By: philnik, ldionne, #libc, #libc_abi, avogelsgesang

Spies: mikhail.ramalho, avogelsgesang, xingxue, libcxx-commits

Differential Revision: https://reviews.llvm.org/D138005
2023-03-19 10:04:34 +01:00
Zhangyin
9d8b60d08a [libcxx] Add status paper for Parallelism-TS
Reviewed By: #libc, philnik, Mordante

Differential Revision: https://reviews.llvm.org/D145652
2023-03-17 12:31:32 +08:00
Hristo Hristov
bc47a195cc [libc++][spaceship] Implement operator<=> for map and multimap
Implements parts of P1614R2: `operator<=>` for `map` and `multimap`

Reviewed By: #libc, philnik

Spies: philnik, libcxx-commits, yaxunl

Differential Revision: https://reviews.llvm.org/D145976
2023-03-15 15:24:43 +01:00
Mark de Wever
ec5f7004c0 [libc++][format] Addresses LWG3825.
LWG3825 Missing compile-time argument id check in
  basic_format_parse_context::next_arg_id

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D144327
2023-03-14 18:32:40 +01:00
Louis Dionne
c73c3a078a [libc++] Clean up old macOS back-deployment workarounds
This patch bumps the minimum macOS version for building the dylib
or back-deploying a statically-linked libc++ from macOS 10.11 to
macOS 10.13. AFAICT, Chrome was the last one to require macOS 10.11,
but since then they have bumped their minimal supported version to
macOS 10.13.

Differential Revision: https://reviews.llvm.org/D145012
2023-03-10 09:08:07 -05:00
Nikolas Klauser
70617a1a23 [libc++] Granularize <atomic> includes
Reviewed By: ldionne, Mordante, #libc

Spies: arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D144255
2023-03-10 13:28:29 +01:00
Igor Zhukov
882fba9ff2 [libc++][ranges] Implement LWG-3865 Sorting a range of pairs
Reviewed By: Mordante, philnik, ldionne, #libc

Differential Revision: https://reviews.llvm.org/D144262
2023-03-10 09:01:52 +07:00
Mark de Wever
508b4510de [libc++] Addresses LWG3358
LWG3358 §[span.cons] is mistaken that to_address can throw

Since last - first has to throw tests are added to make sure this always
happens.

Depends on D142808

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D142843
2023-03-07 19:36:34 +01:00
Mark de Wever
f68a536a67 [libc++][format] Addresses LWG3839.
LWG3839 range_formatter's set_separator, set_brackets, and
  underlying functions should be noexcept

Adds tests for:

  template<ranges::input_range R, class charT>
     struct range-default-formatter<range_format::sequence, R, charT>

These were missing, the format functions tests for the sequences
are already present.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D144286
2023-03-07 19:20:19 +01:00
Mark de Wever
24c251d94d [libc++][format] Addresses LWG3881.
LWG3881 Incorrect formatting of container adapters backed by std::string

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D144277
2023-03-07 19:10:26 +01:00
Nilay Vaish
1edc72385a Checked that complexity of std::sort_heap is 2N log(N) comparisons
https://wg21.link/LWG2444 updated the comparison complexity of
std:sort_heap to be at most 2N log (N) where N == last - first.  In the
current implementation, we invoke __pop_heap exactly N-1 times.  In each
call to __pop_heap, we first go down the heap from first to possibly
last in the function __floyd_sift_down.  Then, we possibly go back up in
the function __sift_up.

In the function __floyd_sift_down, there is loop in which one comparison
is made in each iteration.  The loop runs till __child becomes greater
than (__len - 2) / 2.  __child starts at 0 and it is at least set to 2 *
__child + 1 on each iteration.  Thus, after k iterations, __child will
be at least 2^k - 1.  After log(N) iterations,  __child >= 2^(log(N)) -
1 = N - 1 > (__len - 2) / 2.  This means that the while loop in the
function __floyd_sift_down would perform at most log(N) comparisons on
each invocation.

In the function __sift_up, there is one comparison made that will almost
always occur.  After that there is a do-while loop.  The comparison
function is invoked once in each iteration.  In the worst case, the loop
will run till __len goes down to zero.  It can start from (N-3)/2.  In
each iteration, __len goes down to (__len-1) / 2.  After k iterations,
__len will be at most (N - 2^(k+1) -1) / 2^(k+1).  Thus, __len will
become  when (N-2^(k+1)-1) < 2^(k+1)  i.e. N  < 2^(k+2) + 1.  This means
at most log(N) - 1 iterations for the loop.  So in total at most log(N)
  comparison will be performed in __sift_up.

So overall for each iteration of the loop in __pop_heap, there will at
most 2 log(N) comparisons.  So, the total number of comparisons is
at most 2 N log(N).

We also updated the test sort.heap/complexity.pass.cpp to test for the
number of operations.

Differential Revision: https://reviews.llvm.org/D144538
2023-03-06 08:42:25 -08:00
Hristo Hristov
cc6de9f6a5 [libc++][spaceship][NFC] Marked operator<=> for move_iterator and counted_iterator as implemented
Apprarently implemented as part of:

- `move_iterator` - https://reviews.llvm.org/D117656
- `counted_iterator` - https://reviews.llvm.org/D106205

Reviewed By: #libc, philnik

Spies: libcxx-commits, yaxunl

Differential Revision: https://reviews.llvm.org/D145243
2023-03-06 01:05:41 +01:00
Nikolas Klauser
f5e9c1ae83 [libc++] Update supported system versions
Reviewed By: ldionne, #libc, emaste, daltenty

Spies: fsb4000, daltenty, alvinhochun, goncharov, phosek, MaskRay, dalias, q66, thesamesam, emaste, libcxx-commits, arphaman, mstorsjo, #libc_vendors

Differential Revision: https://reviews.llvm.org/D140343
2023-03-05 22:29:42 +01:00
Mark de Wever
faacf8bca3 [libc++][format] Addresses LWG3833.
LWG3833 Remove specialization template<size_t N> struct formatter<const charT[N], charT>

Depends on D143845

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D143850
2023-03-04 13:53:38 +01:00
Mark de Wever
20b538fc64 [libc++] Addresses LWG3103.
LWG3103 Errors in taking subview of span should be ill-formed where possible

Note that the real work was already done before, including tests.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D143432
2023-03-04 13:24:44 +01:00
Hristo Hristov
3bc76339ea [libc++][spaceship] Implement operator<=> for forward_list
Implemented `operator<=>` for `forward_list`

Reviewed By: #libc, philnik

Spies: philnik, libcxx-commits, yaxunl

Differential Revision: https://reviews.llvm.org/D145172
2023-03-03 13:43:03 +01:00
Hristo Hristov
2ff646f554 [libc++][spaceship] Implement operator<=> for deque
Based on https://reviews.llvm.org/D132312
Dependes on https://reviews.llvm.org/D132312

Reviewed By: #libc, Mordante, philnik

Spies: philnik, Mordante, yaxunl, libcxx-commits

Differential Revision: https://reviews.llvm.org/D144821
2023-03-03 13:36:01 +01:00
Louis Dionne
2765fe8a61 [libc++][NFC] Fix typo in documentation 2023-03-02 12:42:15 -05:00
Shivam kunwar
9266edfcfd [libcxx][NFC] Added a note about the P2520R0
Differential Revision: https://reviews.llvm.org/D145087
2023-03-02 07:58:23 +05:30
Shivam kunwar
813e1da974 [libc++] implement move_iterator<T*> should be a random access iterator \n Differntial Revision- https://reviews.llvm.org/D135248 2023-03-01 23:47:00 +05:30
Mark de Wever
853059a150 [libc++] Addresses LWG3782.
3782. Should <math.h> declare ::lerp?

Libc++ doesn't declare ::lerp, adds tests to validate the requirement.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D142817
2023-02-28 18:31:17 +01:00
Adrian Vogelsgesang
b5a84ae09a [libc++][spaceship] Implement operator<=> for list
Implements part of P1614R2 "The Mothership has Landed"

Differential Revision: https://reviews.llvm.org/D132312
2023-02-28 06:11:31 -08:00
Igor Zhukov
a8ead9194c [libc++][ranges] Implement LWG-3860 range_common_reference_t is missing 2023-02-27 20:49:12 +07:00
Nikolas Klauser
3d4b7a6fa8 [libc++] Add FTM for views::as_rvalue
`views::as_rvalue` was implemented in D137637, but we forgot to set the feature test macro.
Fixes #60986.

Reviewed By: Mordante, #libc

Spies: libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D144781
2023-02-25 18:26:57 +01:00
Igor Zhukov
9d53c8684f [libc++] Implement LWG-3204: sub_match::swap only swaps the base class
Reviewed By: Mordante, JMazurkiewicz, #libc

Differential Revision: https://reviews.llvm.org/D144629
2023-02-25 21:43:37 +07:00
Nikolas Klauser
6e93bf5f66 [libc++] Remove <experimental/{algorithm,functional}>
The contents of these files have been implemented for at least two releases, so let's remove them according to our policy (https://libcxx.llvm.org/DesignDocs/ExperimentalFeatures.html#id4).

Reviewed By: Mordante, #libc

Spies: arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D144475
2023-02-24 14:18:12 +01:00
Nikolas Klauser
b4ecfd3c46 [libc++] Forward to std::memcmp for trivially comparable types in equal
Reviewed By: #libc, ldionne

Spies: ldionne, Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D139554
2023-02-21 17:11:21 +01:00
Nikolas Klauser
e8cb3559ee [libc++] Move constexpr <cstring> functions into their own headers and remove unused <cstring> includes
Reviewed By: ldionne, Mordante, #libc, #libc_abi

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D143329
2023-02-21 16:56:29 +01:00
Mark de Wever
c1877e6465 [NFC][libc++][doc] Fixes formatting. 2023-02-18 18:30:56 +01:00
Mark de Wever
8caa8d95af [libc++][format] Addresses LWG3810.
LWG3810 CTAD for std::basic_format_args

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D144275
2023-02-17 21:08:24 +01:00
Mark de Wever
3476b56f0c [libc++][test] Adds more generic test macros.
These macros are intended to replace the macros in rapid-cxx-test.h.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D142808
2023-02-17 17:01:58 +01:00
Nikolas Klauser
40a20ae6ab [libc++] Granularize <bit> includes
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D141228
2023-02-17 11:36:19 +01:00
Joe Loser
83014d8770 [libc++] LWG 3857: allow string_view conversion when only traits vary
The `basic_string_view` constructor accepting a contiguous range rejects
converting between `basic_string_view` even when only the trait types vary.
This prevents conversions for converting from `basic_string_view<C, T1>` and
`basic_string<C, T1, A>` to `basic_string_view<C, T2>`.  Recently, this
constructor was made `explicit`, so there's no reason to really forbid this
conversion anymore.

Relax the restriction that the trait types need to match in this constructor.

Differential Revision: https://reviews.llvm.org/D143972
2023-02-16 06:00:01 -07:00
Hui
c510c38763 [libc++][NFC] update Range Status for the completion of C++20 ranges
Differential Revision: https://reviews.llvm.org/D142494
2023-02-14 21:27:30 +00:00
Mark de Wever
5c1b8de77d [libc++][doc] Sets the proper plenary date. 2023-02-14 21:03:34 +01:00
Mark de Wever
7f5d130a42 [libc++][chrono] Add hh_mm_ss formatter.
Partially implements:
- P1361 Integration of chrono with text formatting
- P2372 Fixing locale handling in chrono formatters
- P1466 Miscellaneous minor fixes for chrono

Depends on D137022

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D139771
2023-02-14 19:12:19 +01:00
Mark de Wever
f8877d86a8 [libc++][doc] Adds Issaquah papers and issues.
Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D143845
2023-02-14 19:04:53 +01:00
Adrian Vogelsgesang
855b67799b [libc++][NFC] Remove duplicated line from Cxx20Issues.csv 2023-02-13 16:33:21 -08:00
Mark de Wever
31c42f8f35 [libc++][doc] Updates format status page.
This adds the papers voted in during the Issaquah plenary.
2023-02-13 18:32:04 +01:00
Louis Dionne
5801090258 [libc++] Fix bug in allocate_shared_for_overwrite
Instead of destroying the object with allocator::destroy, we must
call its destructor directly. As a fly-by also mark LWG3008 as
fixed since it is handled by our implementation.

This was pointed out by Tim Song in https://reviews.llvm.org/D140913.

Differential Revision: https://reviews.llvm.org/D143791
2023-02-13 08:50:54 -05:00
Louis Dionne
87cc95a904 [libc++] Implement P2136R3 std::invoke_r
Differential Revision: https://reviews.llvm.org/D143610
2023-02-13 08:46:57 -05:00
Nikolas Klauser
e698c59504 [libc++] Granularize <type_traits> includes in <algorithm>
Reviewed By: Mordante, #libc

Spies: libcxx-commits, wenlei

Differential Revision: https://reviews.llvm.org/D140673
2023-02-13 13:21:25 +01:00
Adrian Vogelsgesang
2a06757a20 [libc++][spaceship] Implement lexicographical_compare_three_way
The implementation makes use of the freedom added by LWG 3410. We have
two variants of this algorithm:
* a fast path for random access iterators: This fast path computes the
  maximum number of loop iterations up-front and does not compare the
  iterators against their limits on every loop iteration.
* A basic implementation for all other iterators: This implementation
  compares the iterators against their limits in every loop iteration.
  However, it still takes advantage of the freedom added by LWG 3410 to
  avoid unnecessary additional iterator comparisons, as originally
  specified by P1614R2.

https://godbolt.org/z/7xbMEen5e shows the benefit of the fast path:
The hot loop generated of `lexicographical_compare_three_way3` is
more tight than for `lexicographical_compare_three_way1`. The added
benchmark illustrates how this leads to a 30% - 50% performance
improvement on integer vectors.

Implements part of P1614R2 "The Mothership has Landed"

Fixes LWG 3410 and LWG 3350

Differential Revision: https://reviews.llvm.org/D131395
2023-02-12 14:51:08 -08:00
Adrian Vogelsgesang
bb00fb66ba [libc++][NFC] Fix formatting in ranges status page 2023-02-12 12:06:17 -08:00
Louis Dionne
1cf344d946 [libc++] Implement LWG3657 std::hash<filesystem::path>
This is implemented as a DR on top of C++17.

Differential Revision: https://reviews.llvm.org/D143452
2023-02-07 22:06:17 -08:00
Louis Dionne
16a1c85171 [libc++] Implement P1328R1 constexpr std::type_info::operator==
Differential Revision: https://reviews.llvm.org/D143447
2023-02-07 17:03:45 -08:00