609 Commits

Author SHA1 Message Date
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
Louis Dionne
b699a9ba11
[libc++] Update status page after the Tokyo meeting (#87395) 2024-04-03 08:21:11 -04:00
yronglin
31a9a4b837
[libc++] Implement LWG3528 (make_from_tuple can perform (the equivalent of) a C-style cast) (#85263)
Implement [LWG3528](https://wg21.link/LWG3528).
Based on LWG3528(https://wg21.link/LWG3528) and
http://eel.is/c++draft/description#structure.requirements-9, the
standard allows to impose requirements, we constraint
`std::make_from_tuple` to make `std::make_from_tuple` SFINAE friendly
and also avoid worse diagnostic messages. We still keep the constraints
of `std::__make_from_tuple_impl` so that `std::__make_from_tuple_impl`
will have the same advantages when used alone.

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
2024-03-22 20:45:17 +08:00
Mark de Wever
8779edb8b3
[libc++] Deprecates std::errc constants. (#80542)
Implements:
- LWG3869 Deprecate std::errc constants related to UNIX STREAMS
2024-03-21 12:14:24 +01:00
Xiaoyang Liu
cf09b7dec4
[libc++][ranges] LWG3715: view_interface::empty is overconstrained (#85004)
## Abstract

This pull request implements LWG3715: `view_interface::empty` is
overconstrained. Here is an example similar to those described in the
report, which compiles with `-stdlib=libstdc++` but failed to compile
with `-stdlib=libc++`:

```cpp
// https://godbolt.org/z/EWEoTzah3
std::istringstream input("1 2 3 4 5");
auto i = std::views::istream<int>(input);
auto r = std::views::counted(i.begin(), 4) | std::views::take(2);
assert(!r.empty());
```

## Reference

- [Draft C++ Standard:
[view.interface.general]](https://eel.is/c++draft/view.interface.general)
- [LWG3715](https://wg21.link/LWG3715)
2024-03-20 09:47:40 +01:00
yronglin
c5818c3abc
[libc++][NFC] Update LWG3477(Simplify constraints for semiregular-box) status (#85399)
Since we implemented `copyable-box` in
(https://reviews.llvm.org/D102135,
6829db727e),
this issue got addressed.

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
2024-03-17 23:03:55 +08:00
Jakub Mazurkiewicz
12978b3e23
[libc++] P2602R2 Poison Pills are Too Toxic (#74534)
Implements [P2602R2 Poison Pills are Too
Toxic](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2602r2.html)
as a DR in C++20 mode.
2024-03-16 12:16:36 +00:00
yronglin
3ed8f19cd0
[libc++][NFC] Mark LWG3772 as implemented (#85108)
[LWG3772](https://wg21.link/LWG3772) already implemented with
https://reviews.llvm.org/D141699 .

Signed-off-by: yronglin <yronglin777@gmail.com>
2024-03-15 07:02:59 +08:00
Mark de Wever
e1da74d916
[libc++][format] Updates LWG3462 status. (#80550)
The specifications of format had a contradiction, libc++ always
implemented the code as-if LWG3462 has been done; the contradiction was
a bit hard to spot.

Marks as nothing to do:
- LWG3462 §[formatter.requirements]: Formatter requirements forbid use
of fc.arg()
2024-03-09 12:35:26 +01:00
Mark de Wever
914f754876
[libc++][format] Update LWG3701 status. (#80545)
The issue has been resolved in https://reviews.llvm.org/D121138 since it
was needed to implement format. This updates the status of the LWG-issue
filed for this review.

Marks as complete:
- LWG3701 Make formatter<remove_cvref_t<const charT[N]>, charT>
requirement explicit
2024-03-09 12:32:57 +01:00
Hristo Hristov
716a23c412
[libc++][NFC] Status page: fix minor formatting issues (#83969)
Fixes several minor formatting issues and omissions I introduced on the
status pages in previous patches.
2024-03-06 14:09:26 +02:00
Hristo Hristov
80f9458cf3
[libc++][sstream] P2495R3: Interfacing stringstreams with string_view (#80552)
Implements P2495R3 <https://wg21.link/P2495R3>
- https://eel.is/c++draft/version.syn#headerref:%3csstream%3e
- https://eel.is/c++draft/stringbuf
- https://eel.is/c++draft/stringbuf.general
- https://eel.is/c++draft/stringbuf.cons
- https://eel.is/c++draft/stringbuf.members
- https://eel.is/c++draft/istringstream
- https://eel.is/c++draft/istringstream.general
- https://eel.is/c++draft/istringstream.cons
- https://eel.is/c++draft/istringstream.members
- https://eel.is/c++draft/ostringstream
- https://eel.is/c++draft/ostringstream.general
- https://eel.is/c++draft/ostringstream.cons
- https://eel.is/c++draft/ostringstream.members
- https://eel.is/c++draft/stringstream
- https://eel.is/c++draft/stringstream.general
- https://eel.is/c++draft/stringstream.cons
- https://eel.is/c++draft/stringstream.members

References:
- https://eel.is/c++draft/string.streams
2024-03-05 08:49:49 +02:00
ZijunZhaoCCK
7d7d4752a8
[libc++] Set feature test macros __cpp_lib_ranges_contains and__cpp_lib_ranges_starts_ends_with (#81816)
ranges::contains: fdd089b50063
ranges::starts_with: 205175578e0d
ranges::ends_with: 0218ea4aaa54

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2024-02-29 16:06:32 -08:00