621 Commits

Author SHA1 Message Date
Mark de Wever
a1d73ace13
[libc++][TZDB] Finishes zoned_time constructors. (#95010)
Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept
zoned_time<Duration2, TimeZonePtr2>

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
2024-07-09 20:15:49 +02:00
Mark de Wever
dda4184808
[libc++][TZDB] Adds basics of zoned_time class. (#94999)
This implements the class, its non-templated constructors and its
getters to verify the construction.

Completes
- LWG3224 zoned_time constructor from TimeZonePtr does not specify
initialization of tp_

Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
2024-07-09 20:14:40 +02:00
A. Jiang
ca055bbec7
[libc++][format] LWG4061: Should std::basic_format_context be default-constructible/copyable/movable? (#97251)
See [LWG4061](https://cplusplus.github.io/LWG/issue4061) and
[P3341R0](https://wg21.link/p3341r0). Effectively reverts commit
36ce0c3b1e581ca310ae7d0cbc6af002cc5d0251.


`libcxx/test/std/utilities/format/format.functions/bug_81590.compile.pass.cpp`
has a `format` function that unexpectedly takes the
`basic_format_context` by value, which is made ill-formed by LWG4061.
This PR changes the function to take the context by reference.
2024-07-09 12:23:50 +02:00
A. Jiang
96c9913332
[libc++][format] LWG4106: basic_format_args should not be default-constructible (#97250)
See [LWG4106](https://cplusplus.github.io/LWG/issue4106) and
[P3341R0](https://wg21.link/p3341r0).

The test coverage for the empty state of `basic_format_args` in
`get.pass.cpp` is to be completely removed, because the
non-default-constructibility is covered in `ctor.pass.cpp`.
2024-07-09 12:21:30 +02:00
Mark de Wever
2dadf8d7f5
[libc++] Update status after the St. Louis meeting. (#97951)
This updates:
- The status tables
- Feature test macros
- New headers for modules
2024-07-08 19:35:31 +02:00
Mark de Wever
093ddac68c
[libc++][chrono] Fixes leap seconds. (#90070)
While implementing the UTC clock it turns out that the implementation of
the leap seconds was not correct, it should store the individual value,
not the sum.

It also looks like LWG3359 has not been fully implemented.

Implements parts of:
- LWG3359 <chrono> leap second support should allow for negative leap
seconds
2024-07-04 20:45:15 +02:00
Hui
eaae63d8e1
"[libc++] Try again LWG3233 Broken requirements for shared_ptr converting constructors" (#96103)
Try it again. Use the approach suggested by Tim in the LWG thread :
using function default argument SFINAE

- Revert "[libc++] Revert LWG3233 Broken requirements for shared_ptr
converting constructors (#93071)"
- Revert "[libc++] Revert temporary attempt to implement LWG 4110
(#95263)"
- test for default_delete
- Revert "Revert "[libc++] Revert temporary attempt to implement LWG
4110 (#95263)""
- test for NULL
2024-06-26 07:47:39 +01:00
ZhangYin
6ec1ddfd72
[libc++] <experimental/simd> Add swap functions of simd reference (#86478) 2024-06-23 12:51:02 +08:00
Louis Dionne
e7d563501f [libc++] Revert LWG3223 Broken requirements for shared_ptr converting constructors (#93071)
This reverts commit d868f0970, which was shown to break some code and we
don't know yet whether the code should be valid or not. Reverting until
we've had time to figure it out next week.
2024-06-14 14:41:47 -04:00
Louis Dionne
a66e2a1988
[libc++] Revert temporary attempt to implement LWG 4110 (#95263)
When I filed LWG4110 after the discussion in #93071, I thought it was
going to be a straightforward fix. It turns out that it isn't, so we
should stay in the state where libc++ is Standards conforming even if
that state leads to some reasonable code being rejected by the library.
Once WG21 figures out what to do with this issue and votes on it, we'll
implement it through our normal means.

This reverts f638f7b6a7c2 and 16f2aa1a2ddf.
2024-06-14 14:34:56 -04:00
Mark de Wever
759fb590da
[libc++][modules] Mark as implemented. (#90091)
The feature has been implemented in LLVM 18 as an experimental feature.
This marks the paper as complete and sets the feature-test macro.

Implements
- P2465R3 Standard Library Modules std and std.compat

Fixes: https://github.com/llvm/llvm-project/issues/89579
2024-06-12 19:01:27 +02:00
Mark de Wever
c36961bd96
[libc++] Adds __cpp_lib_three_way_comparison FTM. (#91515)
The paper
  P0768R1 Library Support for the Spaceship (Comparison) Operator
did not add a feature-test macro. This omission has been corrected in
  P1353R0 Missing Feature Test Macros

This enables the FTM for P0768R1

Fixes: https://github.com/llvm/llvm-project/issues/73953

---------

Co-authored-by: S. B. Tam <cpplearner@outlook.com>
2024-06-12 18:59:21 +02:00
Louis Dionne
f638f7b6a7 [libc++] Update with LWG issue number for shared-ptr constructor 2024-06-11 16:48:35 -04:00
Nico Weber
716ed5fccd
[libc++] Undeprecate shared_ptr atomic access APIs (#92920)
This patch reverts 9b832b72 (#87111):
- [libc++] Deprecated `shared_ptr` Atomic Access APIs as per P0718R2
- [libc++] Implemented P2869R3: Remove Deprecated `shared_ptr` Atomic Access APIs from C++26

As explained in [1], the suggested replacement in P2869R3 is `__cpp_lib_atomic_shared_ptr`,
which libc++ does not yet implement. Let's not deprecate the old way of doing things before
the new way of doing things exists.

[1]: https://github.com/llvm/llvm-project/pull/87111#issuecomment-2112740039
2024-06-07 11:31:17 -04:00
Hui
9595eb10ae
[libc++][test] Close LWG3018 and add tests (#93047) 2024-05-29 18:46:39 +01:00
yronglin
f9672cb775
[NFC][libc++] Mark LWG3951 as implemented (#93191)
Since we have already addressed the LWG issue, this PR marks LWG3951 as
implemented.

Signed-off-by: yronglin <yronglin777@gmail.com>
Co-authored-by: A. Jiang <de34@live.cn>
2024-05-28 18:09:36 -07:00
Hui
2ae3f7c29c
[libc++][test] Close LWG3238 and add tests (#93043) 2024-05-29 01:34:29 +01:00
Hui
d868f09705
[libc++] LWG3223 Broken requirements for shared_ptr converting constructors (#93071) 2024-05-29 01:32:44 +01:00
Hui
44d4b3b2ee
[libc++][test] Close LWG3382 and add tests (#93039) 2024-05-29 01:30:30 +01:00
Hui
96af54b960
[libc++][test] Close LWG3045 (#93053) 2024-05-24 12:17:34 -04:00
ZhangYin
058e4454e8
[libc++] <experimental/simd> Add copy functions for class simd/simd_mask (#78935) 2024-05-22 10:15:35 +02:00
Damien L-G
42ba740aff
[libc++] Implement C++20 atomic_ref (#76647)
Implement the std::atomic_ref class template by reusing atomic_base_impl.
Based on the work from https://reviews.llvm.org/D72240
2024-05-21 15:54:08 -07:00
A. Jiang
3e15c97fa3
[libc++] LWG2381: Inconsistency in parsing floating point numbers (#77948)
This PR implements [LWG2381](https://cplusplus.github.io/LWG/issue2381)
by rejecting `'i'`, `'I'`, `'n'`, `'N'` in FP parsing, as inf and NaN
are intendedly rejected by that LWG issue.

The source character array used for parsing is
`"0123456789abcdefABCDEFxX+-pPiInN"`, whose first 26 or 28 characters
are used for parsing integers or floating-point values respectively.
Previously, libc++ used 32 characters, including `'i'`, `'I'`, `'n'`,
`'N'`, for FP parsing, which was inconsistent with LWG2381. This PR also
replaces magic numbers 26 and 28 (formerly 32) with named constants.

Drive-by change: when the first character (possibly after the leading
`'+'` or `'-'`) is not a decimal digit but an acceptable character
(e.g., `'p'` or `'e'`), the character is not accumulated now (per Stage
2 in [facet.num.get.virtuals]/3).

#65168 may be rendered invalid, see
https://github.com/llvm/llvm-project/pull/65168#issuecomment-1868533342.

Apple back-deployment targets remain broken, likely due to dylib. XFAIL
is marked in related tests.

---------

Co-authored-by: Mark de Wever <koraq@xs4all.nl>
2024-05-21 19:05:51 +02:00
Xiaoyang Liu
f03430f5e3
[libc++] LWG3672: common_iterator::operator->() should return by value (#87899)
## Abstract

This pull request implements LWG3672: `common_iterator::operator->()`
should return by value. The current implementation specifies that this
function should return the underlying pointer by reference (`T*
const&`), but it would be more intuitive to return it by value (`T*`).

## Reference

- [Draft C++ Standard:
[common.iter.access]](https://eel.is/c++draft/common.iter.access)
- [LWG3672](https://cplusplus.github.io/LWG/issue3672)
2024-05-16 19:25:04 +02:00
Hui
52271a5c11
[libc++] Make constexpr std::variant. Implement P2231R1 (#83335)
Fixes #86686
2024-05-10 15:13:00 +01:00
Mark de Wever
bce3132cd2 [libc++][doc] Updates Spaceship status page.
The completed chrono parts no longer need an implementation.
2024-05-09 19:44:18 +02:00
Hristo Hristov
8afa6cf510
[libc++][functional] P2944R3 (partial): Comparisons for reference_wrapper (reference_wrapper operators only) (#88384)
Implements https://wg21.link/P2944R3 (partially)
Implements https://wg21.link/LWG4071 /
https://cplusplus.github.io/LWG/issue4071 (fixes build failures in the
test suite)
- https://eel.is/c++draft/refwrap.comparisons
2024-05-09 12:48:37 +03:00
yronglin
0ecc1646cb
[libc++][ranges] Implement LWG4053 and LWG4054 (#88612)
Implement
- LWG4053 Unary call to `std::views::repeat` does not decay the argument
- LWG4054 Repeating a `repeat_view` should repeat the view

Signed-off-by: yronglin <yronglin777@gmail.com>
2024-04-30 12:32:01 -06:00
Hristo Hristov
9af7f4061b
[libc++][NFC] Fixes a status page note and a minor copy & paste error in a test (#90399)
- Adds a status page note for P3142R0
- Fixes a copy & paste error in tuple protocol for `complex`
2024-04-30 11:31:11 -06:00
Xiaoyang Liu
e74be35c1a
[libc++][ranges] LWG3984: ranges::to's recursion branch may be ill-formed (#87964)
This pull request implements LWG3984: ranges::to's recursion branch
may be ill-formed.

In the current implementation, ranges::to's recursion branch pipes the
range into a `views::transform(/* lambda */)`, which is a __range_adaptor_closure
object. In libc++, the pipe operator of __range_adaptor_closure requires a
viewable_range, so the following code won't compile, as the type of lvalue
`r` doesn't model viewable_range:

  #include <ranges>
  #include <vector>
  #include <list>

  int main() {
    std::vector<std::vector<int>> v;
    auto r = std::views::all(std::move(v));
    auto l = std::ranges::to<std::list<std::list<int>>>(r);
  }

Co-authored-by: A. Jiang <de34@live.cn>
2024-04-26 11:00:47 -04:00
Mark de Wever
ad76a85954
[libc++][format] Improves escaping. (#88283)
The change increments the size of the lookup table considerably. The
table has an "upper boundary" check. The removal of the code units with
the property Grapheme_Extend=Yes removes the range E0100..E01EF. This
breaks the trailing large continuous section in two parts. This will be
improved in a followup patch.

Implements:
- P2713R1 Escaping improvements in std::format
- LWG3965 Incorrect example in [format.string.escaped] p3 for formatting
of combining characters

```
---------------------------------------------------------
Benchmark                           Before          After    
---------------------------------------------------------
BM_ascii_escaped<char>            95696 ns      110704 ns
BM_unicode_escaped<char>          89311 ns      101371 ns
BM_cyrillic_escaped<char>         58633 ns       63329 ns
BM_japanese_escaped<char>         44500 ns       41223 ns
BM_emoji_escaped<char>            99156 ns      111022 ns
BM_ascii_escaped<wchar_t>         92245 ns      112441 ns
BM_unicode_escaped<wchar_t>       80970 ns      102776 ns
BM_cyrillic_escaped<wchar_t>      51253 ns       58977 ns
BM_japanese_escaped<wchar_t>      37252 ns       36885 ns
BM_emoji_escaped<wchar_t>         96226 ns      115885 ns
```
2024-04-25 17:16:41 +02:00
Louis Dionne
ed962a66c5
[libc++] Implement LWG4023 (#87513)
This patch implements LWG4023 by adding explicit assertions for the
added preconditions and also fixes a few tests that were violating these
preconditions.
2024-04-25 09:32:35 -04:00
Xiaoyang Liu
c1086532d4
[libc++][ranges] P2387R3: Pipe support for user-defined range adaptors (#89148)
This patch finalizes the std::ranges::range_adaptor_closure
class template from https://wg21.link/P2387R3.

  // [range.adaptor.object], range adaptor objects
  template<class D>
    requires is_class_v<D> && same_as<D, remove_cv_t<D>>
  class range_adaptor_closure { };

The current implementation of __range_adaptor_closure was introduced
in ee44dd8062a26541808fc0d3fd5c6703e19f6016 and has served as the
foundation for the range adaptors in libc++ for a while. This patch
keeps its implementation, with the exception of the following changes:

- __range_adaptor_closure now includes the missing constraints
  `is_class_v<D> && same_as<D, remove_cv_t<D>>` to restrict the 
  type of class that can inherit from it. (https://eel.is/c++draft/ranges.syn)
- The operator| of __range_adaptor_closure no longer requires its
  first argument to model viewable_range. (https://eel.is/c++draft/range.adaptor.object#1)
- The _RangeAdaptorClosure concept is refined to exclude cases where
  T models range or where T has base classes of type range_adaptor_closure<U>
  for another type U. (https://eel.is/c++draft/range.adaptor.object#2)
2024-04-23 10:58:14 -04:00
Mark de Wever
8a21d59f29
[libc++][TZDB] Adds local_info formatter. (#86256)
This adds the local_info type and its formatting options.
The usage of the local_info object will be done in separate patches.

Implements parts of:
- P0355 Extending to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
2024-04-18 17:23:07 +02:00
Mark de Wever
6f7976c883
[libc++][TZDB] Adds sys_info formatter. (#85896)
Implements parts of:
- P0355 Extending <chrono> to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
2024-04-17 20:55:51 +02:00
Hristo Hristov
9b832b726c
[libc++] Deprecated shared_ptr Atomic Access APIs as per P0718R2 & Implemented P2869R3: Remove Deprecated shared_ptr Atomic Access APIs from C++26 (#87111)
Implements https://wg21.link/P2869R4
Implements deprecations as per https://wg21.link/P0718R2
2024-04-14 14:37:51 +03:00
Hristo Hristov
9931e7efc6
[libc++][spaceship][NFC] P0905R1: Symmetry for spaceship - mark as implemented (#87871)
Implemented: https://wg21.link/P0905R1 in
0913ca197855626c93fdae4184ae80ff5a26503a
- https://eel.is/c++draft/cmp.weakeq (Removed in
https://wg21.link/P1959R0)
- https://eel.is/c++draft/cmp.strongeq (Removed in
https://wg21.link/P1959R0)
- https://eel.is/c++draft/cmp.partialord
-
4abb722ffa/libcxx/include/__compare/ordering.h (L101)
- https://eel.is/c++draft/cmp.weakord
-
4abb722ffa/libcxx/include/__compare/ordering.h (L173)
- https://eel.is/c++draft/cmp.strongord
-
4abb722ffa/libcxx/include/__compare/ordering.h (L250)

References:
- https://wg21.link/P1959R0 - Remove `std::weak_equality` and
`std::strong_equality`
2024-04-13 11:39:38 +03:00
Xiaoyang Liu
7cafe04e0d
[libc++] P3029R1: Better mdspan's CTAD (#87873)
## Abstract

This pull request implements [P3029R1](https://wg21.link/P3029R1). The
paper discusses the current behavior of `mdspan`'s most common
pointer-indices CTAD, where the `Extents` template parameter is deduced
as `dextents` (dynamic extents), even when passing compile-time constant
values. The author believes this behavior is suboptimal, as it doesn't
take advantage of the compile-time information. The proposed change
suggests deducing static extents if `integral_constant`-like constants
are passed, resulting in more intuitive syntax and less error-prone
code.

## Reference

- [P3029R1](https://wg21.link/P3029R1)
- [Draft C++ Standard: [span.syn]](https://eel.is/c++draft/span.syn)
- [Draft C++ Standard: [mdspan.syn]](https://eel.is/c++draft/mdspan.syn)
2024-04-12 19:25:22 +02:00
Xiaoyang Liu
f4e3226a6c
[libc++][ranges] LWG3736: move_iterator missing disable_sized_sentinel_for specialization (#85611)
This pull request implements LWG3736: move_iterator missing
disable_sized_sentinel_for specialization.
2024-04-12 10:09:05 -04:00
Xiaoyang Liu
2a5ba4fb89
[libc++] LWG3643: Missing constexpr in std::counted_iterator (#87901)
This pull request implements LWG3643: Missing constexpr in
std::counted_iterator. Specifically, one overload of
std::counted_operator::operator++ was not marked as constexpr,
despite being eligible for it after the introduction of try-block
support in constexpr functions in C++20.
2024-04-12 10:04:21 -04:00
Mark de Wever
1fda1776e3
[libc++][chrono] Adds the sys_info class. (#85619)
Adds the sys_info class and time_zone::get_info(). The code still has a
few quirks and has not been optimized for performance yet.

The returned sys_info is compared against the output of the zdump tool
in the test giving confidence the implementation is correct.

Implements parts of:
- P0355 Extending <chrono> to Calendars and Time Zones

Implements:
- LWGXXXX The sys_info range should be affected by save
2024-04-10 07:50:17 +02:00
Louis Dionne
e280407a48
[libc++] Add test coverage for our implementation of LWG4031 (#87508)
This was actually already implemented in the initial version of
std::expected, but this patch adds test coverage and makes it more
explicit that we intend to make these functions noexcept.
2024-04-09 11:27:40 -04:00
Jakub Mazurkiewicz
c8917048e3
[libc++] Implement bind_back (#81055)
Implement `std::bind_back` function from P2387R3 "Pipe support for
user-defined range adaptors".
2024-04-09 11:10:20 -04:00
Mark de Wever
8f01d3ff44 [libc++][doc] Updates format status page. 2024-04-07 13:08:02 +02:00
Hristo Hristov
7f9f82e3de
[libc++][format] P3142R0: Printing Blank Lines with println (#87277)
Implements https://wg21.link/P3142R0

Applied retroactively as DR, same as stdlibc++ and MS STL:

https://github.com/orgs/microsoft/projects/1143?pane=issue&itemId=57457187
2024-04-06 21:52:52 +03:00
yronglin
4761e74a27
[libc++] Implement LWG3430 disallow implicit conversion of the source arguments to std::filesystem::path when constructing std::basic_*fstream (#85079)
Implement [LWG3430](https://wg21.link/LWG3430).

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
2024-04-06 20:33:41 +08:00
Hristo Hristov
a834436099
[libc++] P2872R3: Remove `wstring_convert` From C++26 (#87100)
Implements: https://wg21.link/P2872R3
2024-04-05 22:04:07 +03:00
Hristo Hristov
fb635be0b8
[libc++] P2867R1: Remove Deprecated strstreams From C++26 (#87107)
Implements: https://wg21.link/P2867R2

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
2024-04-04 06:03:00 +03:00
Louis Dionne
d83233f597
[libc++] Mark some recent LWG issues and papers as done (#87502)
Justifications:
- LWG3950: Done in #66206
- LWG3975: Wording changes only
- LWG4011: Wording changes only
- LWG4030: Wording changes only
- LWG4043: Wording changes only
- LWG3036 and P2875R4: We implemented neither, but the latter reverts
the former, so now we implement both without doing anything!
2024-04-03 13:50:55 -04:00
Mark de Wever
6f2d8cc061
[libc++][chrono] Loads leap-seconds.list in tzdb. (#82113)
This implements the loading of the leap-seconds.list file and store its
contents in the tzdb struct.

This adds the required `leap_seconds` member.

The class leap_seconds is fully implemented including its non-member
functions.

Implements parts of:
- P0355 Extending <chrono> to Calendars and Time Zones
- P1614 The Mothership has Landed

Implements:
- P1981 Rename leap to leap_second
- LWG3359 <chrono> leap second support should allow for negative leap
seconds
- LWG3383 §[time.zone.leap.nonmembers] sys_seconds should be replaced
with seconds
2024-04-03 18:15:24 +02:00