Commit Graph

42 Commits

Author SHA1 Message Date
Kamlesh Kumar 36c3918ec5 [libc++] [C++20] [P0586] Implement safe integral comparisons
* https://wg21.link/P0586

Reviewed By: #libc, curdeius, Quuxplusone

Differential Revision: https://reviews.llvm.org/D94511
2021-04-20 04:52:59 +05:30
Christopher Di Bella 920c0f7e09 [libcxx] adds __cpp_lib_concepts feature-test macro
Also adjusts C++20 status paper to indicate full concepts support.

Depends on D96477, D99817.

Differential Revision: https://reviews.llvm.org/D99805
2021-04-07 16:14:45 +00:00
Marek Kurdej 0324b46cd8 [libc++] [C++2b] [P2162] Allow inheritance from std::variant.
This patch changes the variant even in pre-C++2b.
It should not break anything, only allow use cases that didn't work previously.

Notes:
 `__as_variant` is used in `__visitation::__variant::__visit_alt`, but I haven't used it in `__visitation::__variant::__visit_alt_at`.
That's because it is used only in `__visit_value_at`, which in turn is always used on variant specializations (that's in comparison operators).

* https://wg21.link/P2162

Reviewed By: ldionne, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D97394
2021-03-25 18:20:50 +01:00
Arthur O'Dwyer 06e2b737aa [libc++] [P1032] Misc constexpr bits in <iterator>, <string_view>, <tuple>, <utility>.
This completes the implementation of P1032's changes to <iterator>,
<string_view>, <tuple>, and <utility> in C++20.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1032r1.html

Drive-by fix a couple of unintended rvalues in "*iterators*/*.fail.cpp".

Differential Revision: https://reviews.llvm.org/D96385
2021-03-25 10:34:35 -04:00
Marek Kurdej 43e4214173 [libc++] [C++2b] [P1682] Add to_underlying.
* https://wg21.link/P1682

Reviewed By: ldionne, Mordante, #libc

Differential Revision: https://reviews.llvm.org/D97365
2021-03-05 10:31:21 +01:00
zoecarver 84a50f5911 [libc++] Add bind_front function (P0356R5).
Implementes [[ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0356r5.html | P0356R5 ]]. Adds `bind_front` to `functional`.

Reviewed By: ldionne, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D60368
2021-03-02 16:18:06 -08:00
Louis Dionne 5d0d465ad4 [libc++] Mark __cpp_lib_constexpr_memory as being implemented 2021-02-15 15:26:53 -05:00
Arthur O'Dwyer 493f140792 [libc++] [P0879] constexpr std::sort
This completes libc++'s implementation of
P0879 "Constexpr for swap and swap related functions."
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0879r0.html

For the feature-macro adjustment, see
https://cplusplus.github.io/LWG/issue3256

Differential Revision: https://reviews.llvm.org/D93661
2021-02-03 18:57:05 -05:00
Mark de Wever 081c1db02d [libc++] Implement format_error.
This is the first step at implementing <format>. It adds the <format> header
and implements the `format_error`. class.

Implemnts parts of:
-P0645 Text Formatting

Reviewed By: ldionne, #libc, miscco, curdeius

Differential Revision: https://reviews.llvm.org/D92214
2021-01-28 18:02:53 +01:00
Arthur O'Dwyer 3fbd3eaf28 [libc++] Implement [P0769] "Add shift to algorithm" (shift_left, shift_right)
I believe this is a complete implementation of std::shift_left and std::shift_right from
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0769r2.pdf

Some test cases copied-with-modification from D60027.

Differential Revision: https://reviews.llvm.org/D93819
2021-01-25 12:57:04 -05:00
Wim Leflere 6ac9cb2a7c [libc++][P1679] add string contains
C++23 string contains implementation and tests

Paper: https://wg21.link/P1679R3
Standard (string): https://eel.is/c++draft/string.contains
Standard (string_view): https://eel.is/c++draft/string.view.ops#lib:contains,basic_string_view

Differential Revision: https://reviews.llvm.org/D93912
2021-01-19 14:35:07 -05:00
Marek Kurdej 1f1250151f [libc++] [C++2b] [P1048] Add is_scoped_enum and is_scoped_enum_v.
* https://wg21.link/p1048

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D94409
2021-01-12 17:08:20 +01:00
Arthur O'Dwyer ca1694b9d0 Re-enable __cpp_lib_constexpr_functional.
I accidentally disabled this feature-test macro in my D93830,
due to a rebasing conflict. It had been enabled by my D93815,
and should have remained enabled.
2021-01-08 17:30:04 -05:00
Marek Kurdej 95729f95d8 [libc++] Add basic support for -std=c++2b.
* Add feature test macros.
* Add buildbot configuration generic-cxx2b that uses clang-tot.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D94227
2021-01-08 19:02:41 +01:00
Arthur O'Dwyer 466df1718e [libc++] Update generate_feature_test_macro_components.py to match SD-6.
It's still a little confusing because in many cases C++17 and C++20
have different values, and libc++ implements the C++17 behavior but
not the C++20 behavior; 'unimplemented' can't represent that scenario.
Ultimately we probably ought to completely redesign the script to be
in terms of paper numbers, rather than language revisions, and make
it generate the CSV files like "Cxx2aStatusPaperStatus.csv" as well.

Most newly added macros are unimplemented. I've marked a few as implemented,
though, based on my reading of the code; for example I was pretty sure
`__cpp_lib_latch` is implemented since we have `<latch>`.

Differential Revision: https://reviews.llvm.org/D93830
2021-01-08 11:44:39 -05:00
Marek Kurdej 044b892c79 [libc++] Use c++20 instead of c++2a consistently.
* The only exception is that the flag -std=c++2a is still used not to break compatibility with older compilers (clang <= 9, gcc <= 9).
* Bump _LIBCPP_STD_VER for C++20 to 20 and use 21 for the future standard (C++2b).

That's a preparation step to add c++2b support to libc++.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93383
2021-01-07 13:11:33 +01:00
Arthur O'Dwyer 7b00e9fae3 [libc++] [P1065] Constexpr invoke, reference_wrapper, mem_fn, not_fn, default_searcher.
This completes the implementation of P1065 "constexpr INVOKE":
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1065r2.html

This doesn't yet complete the implementation of P1032 "Misc constexpr bits,"
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1032r1.html
but it does complete all of the <functional> bits, which means
that we can now set `__cpp_lib_constexpr_functional` for C++20.

This could use more constexpr tests for `std::reference_wrapper<T>`,
but the existing tests are extremely non-constexpr-friendly and
so I don't want to get into that rabbit-hole today.

Differential Revision: https://reviews.llvm.org/D93815
2020-12-28 13:24:07 -05:00
Louis Dionne a65dc08d10 [libc++] Implement missing feature-test macro __cpp_lib_shared_ptr_arrays
This was forgotten when we implemented support for arrays in std::shared_ptr
in https://reviews.llvm.org/D62259.
2020-12-08 15:46:45 -05:00
Mark de Wever 67c88e47bd [libc++] P1645 constexpr for <numeric>
Implements P1645: constexpr for <numeric> algorithms

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D90569
2020-11-28 17:02:54 +01:00
Mark de Wever ecabb39ca1 Revert "[libc++] P1645 constexpr for <numeric>"
This reverts commit eb9b063539.

The commit fails to build on build bots using LLVM 8.
2020-11-25 13:46:08 +01:00
Mark de Wever eb9b063539 [libc++] P1645 constexpr for <numeric>
Implements P1645: constexpr for <numeric> algorithms

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D90569
2020-11-25 13:19:32 +01:00
Mark de Wever 1a036e9cc8 [libcxx] Implement P1956 rename low-level bit functions
Implements P1956: On the names of low-level bit manipulation functions.

Users may use older versions of libc++ or other standard libraries with the old names. In order to keep compatibility the old functions are kept, but marked as deprecated.

The patch also adds a new config macro `_LIBCPP_DEPRECATED_MSG`. Do you prefer a this is a separate patch?

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D90551
2020-11-24 17:37:06 +01:00
Ruslan Arutyunyan e5ec94a1a0 [libc++] Implement P0919R3: heterogenous lookup for unordered containers
Implement heterogenous lookup for unordered containers, including the
refinement from P1690R1.

Differential Revision: https://reviews.llvm.org/D87171
2020-11-11 17:44:42 -05:00
Louis Dionne 0724f8bf47 [libc++] Implement C++20's P0784 (More constexpr containers)
This commit adds std::construct_at, and marks various members of
std::allocator_traits and std::allocator as constexpr. It also adds
tests and turns the existing tests into hybrid constexpr/runtime tests.

Thanks to Richard Smith for initial work on this, and to Michael Park
for D69803, D69132 and D69134, which are superseded by this patch.

Differential Revision: https://reviews.llvm.org/D68364
2020-09-22 11:20:33 -04:00
Louis Dionne 0451ed9619 [libc++] NFC: Remove trailing whitespace from the feature test macro table 2020-09-22 08:45:48 -04:00
Olivier Giroux fc4bff0cd3 Update atomic feature macros, synopsis, signatures to match C++20. Improve test coverage for non-lock-free atomics. 2020-09-09 10:00:09 -07:00
Michael Schellenberger Costa afe8ca8673 [libcxx] Fix whitespace error 2020-09-02 21:44:15 +02:00
Michael Schellenberger Costa 737a4501e8 Add constexpr to pair
Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D80558
2020-09-02 21:21:24 +02:00
Raul Tambre 4f6c4b473c [libc++] Implement <numbers>
Summary: Constants have 33 significant decimal digits for IEEE 754 128-bit floating-point numbers.

Reviewers: ldionne, #libc, EricWF, zoecarver, curdeius

Reviewed By: ldionne, #libc, curdeius

Differential Revision: https://reviews.llvm.org/D77505
2020-06-19 14:25:02 +05:30
Louis Dionne 77b9abfc8e [libc++] Complete overhaul of constexpr support in std::array
This commit adds missing support for constexpr in std::array under all
standard modes up to and including C++20. It also transforms the <array>
tests to check for constexpr-friendliness under the right standard modes.

Fixes https://llvm.org/PR40124
Fixes rdar://57522096
Supersedes https://reviews.llvm.org/D60666

Differential Revision: https://reviews.llvm.org/D80452
2020-05-28 12:31:06 -04:00
Marek Kurdej 174322c273 [libc++] Mark __cpp_lib_hardware_interference_size as unimplemented. This fxes bug PR41423.
Summary:
As described in the bug report:
The commit a8b9f59e8caf378d56e8bfcecdb22184cdabf42d "Implement feature test macros using a script" added test features macros for libc++. Among others, it added `__cpp_lib_hardware_interference_size`. However, there is nothing like std::hardware_constructive_interference_size nor std::hardware_destructive_interference_size, that should be in header <new>.

* https://bugs.llvm.org/show_bug.cgi?id=41423

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D80431
2020-05-23 14:33:50 +02:00
Michael Schellenberger Costa 6d2599e4f7 [libcxx][span] Implement P1976R2
This resolves the NB comment about the construction of a fixed-size span
from a dynamic range.

Differential Revision: https://reviews.llvm.org/D74577
2020-05-13 09:52:47 -04:00
Marek Kurdej 3e895085de [libc++][P1115][C++20] Improving the Return Value of Erase-Like Algorithms II: Free erase/erase if.
Summary:
This patch adds return type to std::erase and std::erase_if functions.

Also:
* Update __cpp_lib_erase_if to 202002L.
* Fix synopsis in unordered_map.
* Fix generate_feature_test_macro_components.py script.

Reviewers: EricWF, mclow.lists, ldionne, #libc

Reviewed By: ldionne, #libc

Subscribers: broadwaylamb, zoecarver, dexonsmith, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D75905
2020-05-02 14:04:50 +02:00
Marek Kurdej 05343588e3 [libc++] [P0646] Add feature-test macro for __cpp_lib_list_remove_return_type.
Summary: The return type modification has already been implemented in rL364840 and rL365290.

Reviewers: ldionne, mclow.lists, EricWF, #libc!

Reviewed By: ldionne

Subscribers: christof, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D70275
2020-03-12 11:06:49 +01:00
Marek Kurdej e93e58c6c4 Reland [libc++] [P0325] Implement to_array from LFTS with updates.
Fixed expected errors and notes.

Summary:
This patch implements https://wg21.link/P0325.

Reviewers: EricWF, mclow.lists, ldionne, lichray

Reviewed By: ldionne, lichray

Subscribers: lichray, dexonsmith, zoecarver, christof, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D69882
2020-01-31 11:47:18 +01:00
Marek Kurdej 5e7017273f Revert "[libc++] [P0325] Implement to_array from LFTS with updates."
This reverts commit 86aae78268.

A test is failing on "Release" build without assertions enabled (Fedora 31 on x86_64).
2020-01-31 09:45:50 +01:00
Marek Kurdej 86aae78268 [libc++] [P0325] Implement to_array from LFTS with updates.
Summary:
This patch implements https://wg21.link/P0325.
Please mind that at it is my first contribution to libc++, so I may have forgotten to abide to some conventions.

Reviewers: EricWF, mclow.lists, ldionne, lichray

Reviewed By: ldionne, lichray

Subscribers: lichray, dexonsmith, zoecarver, christof, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D69882
2020-01-30 13:38:37 +01:00
Louis Dionne 8b77a3a0f4 [libc++] [P1612] Add missing feature-test macro __cpp_lib_endian.
Thanks to Marek Kurdej for the patch.

Differential Revision: https://reviews.llvm.org/D70221
2019-11-14 08:55:19 -05:00
Eric Fiselier ae02e89448 P0722R3: Implement library support for destroying delete
Summary:
This provides the `std::destroying_delete_t` declaration in C++2a and after. (Even when the compiler doesn't support the language feature).

However, the feature test macro `__cpp_lib_destroying_delete` is only defined when we have both language support and  C++2a.


Reviewers: ldionne, ckennelly, serge-sans-paille, EricWF

Reviewed By: EricWF

Subscribers: dexonsmith, riccibruno, christof, jwakely, jdoerfert, mclow.lists, ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D55840

llvm-svn: 361572
2019-05-23 23:46:44 +00:00
Marshall Clow d3d0ecbfd5 Implement midpoint for floating point types. Reviewed as https://reviews.llvm.org/D61014.
llvm-svn: 359184
2019-04-25 12:11:43 +00:00
Eric Fiselier 2fc5a786be Add std::is_constant_evaluated.
Clang recently added __builtin_is_constant_evaluated() and GCC 9.0
has it as well.

This patch adds support for it in libc++.

llvm-svn: 359119
2019-04-24 17:54:25 +00:00
Eric Fiselier 32784a740a Implement feature test macros using a script.
Summary:
This patch implements all the feature test macros libc++ currently supports, as specified by the standard or cppreference prior to C++2a.

The tests and `<version>` header are generated using a script. The script contains a table of each feature test macro, the headers it should be accessible from, and its values of each dialect of C++.
When a new feature test macro is added or needed, the table should be updated and the script re-run.



Reviewers: mclow.lists, jfb, serge-sans-paille

Reviewed By: mclow.lists

Subscribers: arphaman, jfb, ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D56750

llvm-svn: 351286
2019-01-16 01:37:43 +00:00