Commit Graph

191 Commits

Author SHA1 Message Date
varconst
b5270ba20d [libc++] Remove the legacy debug mode.
See https://discourse.llvm.org/t/rfc-removing-the-legacy-debug-mode-from-libc/71026

Reviewed By: #libc, Mordante, ldionne

Differential Revision: https://reviews.llvm.org/D153672
2023-06-29 14:49:51 -07: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
Mark de Wever
b7932803de [libc++] Moves unwrap_reference to type_traits.
This was discovered while working on modules.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D149351
2023-05-14 20:03:55 +02:00
Nikolas Klauser
75196f8e72 [libc++] Remove <cstdlib> includes
We changed the `abort` calls when trying to throw exceptions in `-fno-exceptions` mode to `__verbose_abort` calls, which removes the dependency in most files.

Reviewed By: ldionne, #libc

Spies: dim, emaste, mikhail.ramalho, smeenai, libcxx-commits

Differential Revision: https://reviews.llvm.org/D146076
2023-04-09 02:52:33 +02:00
Nikolas Klauser
c9d36bd807 [libc++] Granularize <exception> includes
Reviewed By: ldionne, #libc

Spies: mikhail.ramalho, smeenai, libcxx-commits

Differential Revision: https://reviews.llvm.org/D146097
2023-03-19 10:28:32 +01: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
Nikolas Klauser
0a4aa8a122 [libc++] Granularize <type_traits> includes
Reviewed By: ldionne, #libc, #libc_abi

Spies: #libc_vendors, smeenai, libcxx-commits

Differential Revision: https://reviews.llvm.org/D145320
2023-03-08 22:05:04 +01:00
Mark de Wever
de6827b530 [libc++] Improves clang-format settings.
Add a new test based .clang-format file which inherits from the generic
one. This moves some test specific formatting rules to the test
directory.

The main benefit is that headers are sorted, which makes it more likely
to catch these errors before creating a review instead of spotting the
error in the CI clang-tidy step.

Reviewed By: ldionne, philnik, #libc

Differential Revision: https://reviews.llvm.org/D144755
2023-02-27 19:24:06 +01:00
Nikolas Klauser
b1e09b5fa6 [libc++][NFC] Remove TODOs that are already done 2023-02-17 22:17:54 +01: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
Mark de Wever
76804e89b3 [libc++] Addresses LWG3764.
LWG3764 reference_wrapper::operator() should propagate noexcept

As drive-by adds constexpr to the synopsis, since it has already been
implemented.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D142814
2023-01-31 19:59:16 +01:00
Nikolas Klauser
89b356f05a [libc++] Granularize <concept> includes
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D137283
2022-11-05 20:59:29 +01:00
Nikolas Klauser
7afa1598a3 [libc++] Avoid including <tuple> in compressed_pair.h
compressed_pair is widely used in the library, but most of the uses don't use the tuple parts. To avoid including <tuple> everywhere, use the forward declaration instead in compressed_pair.h

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D133331
2022-09-18 10:49:35 +02:00
Nikolas Klauser
d5e26775d0 [libc++] Granularize the rest of memory
Reviewed By: ldionne, #libc

Spies: vitalybuka, paulkirth, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D132790
2022-09-05 12:36:41 +02:00
Mark de Wever
e31c2a1b1a [NFC][libc++] Moves transitive includes location.
As discussed in D132284 they will be moved to the end.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D133212
2022-09-03 10:06:16 +02:00
Vitaly Buka
bc8fd9c633 Revert "[libc++] Granularize the rest of memory"
Breaks buildbots.

This reverts commit 30adaa730c.
2022-09-02 19:42:49 -07:00
Nikolas Klauser
30adaa730c [libc++] Granularize the rest of memory
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D132790
2022-09-02 21:42:41 +02:00
Mark de Wever
8ff2d6af69 [libc++] Reduces the number of transitive includes.
This defines a new policy for removal of transitive includes.
The goal of the policy it to make it relatively easy to remove
headers when needed, but avoid breaking developers using and
vendors shipping libc++.

The method used is to guard transitive includes based on the
C++ language version. For the upcoming C++23 we can remove
headers when we want, but for other language versions we try
to keep it to a minimum.

In this code the transitive include of `<chrono>` is removed
since D128577 introduces a header cycle between `<format>`
and `<chrono>`. This cycle is indirectly required by the
Standard. Our cycle dependency tool basically is a grep based
tool, so it needs some hints to ignore cycles. With the input
of our transitive include tests we can create a better tool.
However that's out of the scope of this patch.

Note the flag `_LIBCPP_REMOVE_TRANSITIVE_INCLUDES` remains
unchanged. So users can still opt-out of transitives includes
entirely.

Reviewed By: #libc, ldionne, philnik

Differential Revision: https://reviews.llvm.org/D132284
2022-08-31 19:50:03 +02:00
Konstantin Varlamov
79a2b4ba98 [libc++][ranges] Finish LWG issues directly related to the One Ranges Proposal.
- P1252 ("Ranges Design Cleanup") -- deprecate
  `move_iterator::operator->` starting from C++20; add range comparisons
  to the `<functional>` synopsis. This restores
  `move_iterator::operator->` that was incorrectly deleted in D117656;
  it's still defined in the latest draft, see
  http://eel.is/c++draft/depr.move.iter.elem. Note that changes to
  `*_result` types from 6.1 in the paper are no longer relevant now that
  these types are aliases;
- P2106 ("Alternative wording for GB315 and GB316") -- add a few
  `*_result` types to the synopsis in `<algorithm>` (some algorithms are
  not implemented yet and thus some of the proposal still cannot be
  marked as done);

Also mark already done issues as done (or as nothing to do):
- P2091 ("Fixing Issues With Range Access CPOs") was already implemented
  (this patch adds tests for some ill-formed cases);
- LWG 3247 ("`ranges::iter_move` should perform ADL-only lookup of
  `iter_move`") was already implemented;
- LWG 3300 ("Non-array ssize overload is underconstrained") doesn't
  affect the implementation;
- LWG 3335 ("Resolve C++20 NB comments US 273 and GB 274") was already
  implemented;
- LWG 3355 ("The memory algorithms should support move-only input
  iterators introduced by P1207") was already implemented (except for
  testing).

Differential Revision: https://reviews.llvm.org/D126053
2022-06-28 12:00:15 -07:00
Louis Dionne
de4a57cb21 [libc++] Re-add transitive includes that had been removed since LLVM 14
This commit re-adds transitive includes that had been removed by
4cd04d1687, c36870c8e7, a83f4b9cda, 1458458b55, 2e2f3158c6,
and 489637e66d. This should cover almost all the includes that had
been removed since LLVM 14 and that would contribute to breaking user
code when releasing LLVM 15.

It is possible to disable the inclusion of these headers by defining
_LIBCPP_REMOVE_TRANSITIVE_INCLUDES. The intent is that vendors will
enable that macro and start fixing downstream issues immediately. We
can then remove the macro (and the transitive includes) by default in
a future release. That way, we will break users only once by removing
transitive includes in bulk instead of doing it bit by bit a every
release, which is more disruptive for users.

Note 1: The set of headers to re-add was found by re-generating the
        transitive include test on a checkout of release/14.x, which
        provided the list of all transitive includes we used to provide.

Note 2: Several includes of <vector>, <optional>, <array> and <unordered_map>
        have been added in this commit. These transitive inclusions were
        added when we implemented boyer_moore_searcher in <functional>.

Note 3: This is a best effort patch to try and resolve downstream breakage
        caused since branching LLVM 14. I wasn't able to perfectly mirror
        transitive includes in LLVM 14 for a few headers, so I added a
        release note explaining it. To summarize, adding boyer_moore_searcher
        created a bunch of circular dependencies, so we have to break
        backwards compatibility in a few cases.

Differential Revision: https://reviews.llvm.org/D128661
2022-06-27 22:18:19 -04:00
Nikolas Klauser
971e9c80e9 [libc++] Implement std::boyer_moore{, _horspool}_searcher
This mostly copys the `<experimental/functional>` stuff and updates the code to current libc++ style.

Reviewed By: ldionne, #libc

Spies: nlopes, adamdebreceni, arichardson, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D121074
2022-06-17 19:09:40 +02:00
Louis Dionne
385cc25a53 [libc++] Ensure that all public C++ headers include <__assert>
This patch changes the requirement for getting the declaration of the
assertion handler from including <__assert> to including any public
C++ header of the library. Note that C compatibility headers are
excluded because we don't implement all the C headers ourselves --
some of them are taken straight from the C library, like assert.h.

It also adds a generated test to check it. Furthermore, this new
generated test is designed in a way that will make it possible to
replace almost all the existing test-generation scripts with this
system in upcoming patches.

Differential Revision: https://reviews.llvm.org/D122506
2022-03-30 15:05:31 -04:00
Nikolas Klauser
1458458b55 [libc++] Remove <utility> includes
Reviewed By: ldionne, Quuxplusone, #libc

Spies: libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D121054
2022-03-17 00:12:33 +01:00
Nikolas Klauser
52915d78f4 [libc++] Granularize <utility> includes
Reviewed By: ldionne, #libc

Spies: EricWF, libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D120466
2022-03-05 19:31:46 +01:00
Arthur O'Dwyer
fa6b9e4010 [libc++] Normalize all our '#pragma GCC system_header', and regression-test.
Now we'll notice if a header forgets to include this magic phrase.

Differential Revision: https://reviews.llvm.org/D118800
2022-02-04 12:27:19 -05:00
Arthur O'Dwyer
4d81a46f7f [libc++] Alphabetize header #includes. NFCI.
The NFC part of D116809. We still want to enforce this in CI,
but the mechanism for that is still to-be-determined.

Differential Revision: https://reviews.llvm.org/D116809
2022-01-10 16:30:38 -05:00
Arthur O'Dwyer
3df094d31e [libc++] [P1614] Implement std::compare_three_way.
Differential Revision: https://reviews.llvm.org/D110735
2021-10-10 21:57:10 -04:00
Louis Dionne
89a7bdb1f3 [libc++] Add the __bind_back and __compose helpers
Those are going to be used to implement range adaptors,
see D107098 for details.

Differential Revision: https://reviews.llvm.org/D107785
2021-08-11 10:08:20 -04:00
Christopher Di Bella
050b064f15 [libcxx][functional][modular] splices <functional> into modular headers
Differential Revision: https://reviews.llvm.org/D104942
2021-07-01 14:01:49 -04:00
Louis Dionne
d03aa7d6b6 [libc++] NFCI: Remove __functional/search.h
The __search helper function was once split into __functional for circular
dependency reasons, however this is not an issue anymore now that we have
finer grained headers.
2021-06-29 11:40:47 -04:00
Christopher Di Bella
69d5a66621 [libcxx][modularisation] splits <utility> into self-contained headers
* moves `std::hash` and `std::unary_function` into `__functional`
* Everything else goes into `__utility/${NAME}.h`

Differential Revision: https://reviews.llvm.org/D104002
2021-06-25 00:29:01 +00:00
Christopher Di Bella
6adbc83ee9 [libcxx][modularisation] moves <utility> content out of <type_traits>
Moves:

* `std::move`, `std::forward`, `std::declval`, and `std::swap` into
  `__utility/${FUNCTION_NAME}`.
* `std::swap_ranges` and `std::iter_swap` into
  `__algorithm/${FUNCTION_NAME}`

Differential Revision: https://reviews.llvm.org/D103734
2021-06-24 17:57:29 +00:00
Arthur O'Dwyer
317e92a3e8 [libc++] Enable explicit conversion operators, even in C++03 mode.
C++03 didn't support `explicit` conversion operators;
but Clang's C++03 mode does, as an extension, so we can use it.
This lets us make the conversion explicit in `std::function` (even in '03),
and remove some silly metaprogramming in `std::basic_ios`.

Drive-by improvements to the tests for these operators, in addition
to making sure all these tests also run in `c++03` mode.

Differential Revision: https://reviews.llvm.org/D104682
2021-06-22 13:35:59 -04:00
Louis Dionne
134723edd5 [libcxx] Move all algorithms into their own headers
This is a fairly mechanical change, it just moves each algorithm into
its own header. This is intended to be a NFC.

This commit re-applies 7ed7d4ccb8, which was reverted in 692d7166f7
because the Modules build got broken. The modules build has now been
fixed, so we're re-committing this.

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

Attribution note
----------------
I'm only committing this. This commit is a mix of D103583, D103330 and
D104171 authored by:

Co-authored-by: Christopher Di Bella <cjdb@google.com>
Co-authored-by: zoecarver <z.zoelec2@gmail.com>
2021-06-19 07:49:06 -04:00
Arthur O'Dwyer
dc066888bd [libc++] [P0619] Add _LIBCPP_ABI_NO_BINDER_BASES and remove binder typedefs in C++20.
Differential Revision: https://reviews.llvm.org/D103753
2021-06-15 15:05:44 -04:00
Petr Hosek
692d7166f7 Revert "[libcxx][gardening] Move all algorithms into their own headers."
This reverts commit 7ed7d4ccb8 as it
uncovered a Clang bug PR50592.
2021-06-07 17:15:20 -07:00
zoecarver
7ed7d4ccb8 [libcxx][gardening] Move all algorithms into their own headers.
This is a fairly mechanical change, it just moves each algorithm into its own header. This is a NFC.

Note: during this change, I burned down all the includes, so this follows "include only and exactly what you use."

Differential Revision: https://reviews.llvm.org/D103583
2021-06-04 09:37:12 -07:00
Arthur O'Dwyer
d39f5c3cb9 [libc++] Avoid result_type and unary/binary_function in <valarray>.
Give each of the relevant functional operators a `__result_type`
instead, so that we can keep using those typedefs in <valarray>
even when the public binder typedefs are removed in C++20.

Differential Revision: https://reviews.llvm.org/D103371
2021-05-31 11:29:16 -04:00
Arthur O'Dwyer
bfbd73f87d [libc++] Alphabetize and include-what-you-use. NFCI.
Differential Revision: https://reviews.llvm.org/D102781
2021-05-29 19:54:48 -04:00
Arthur O'Dwyer
d42d9e10b6 [libc++] [P0619] Hide not1 and not2 under _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS.
This also provides some of the scaffolding needed by D102992 and D101729, and mops up after D101730 etc.

Differential Revision: https://reviews.llvm.org/D103055
2021-05-25 16:57:16 -04:00
Arthur O'Dwyer
06b40e80ae [libc++] Alphabetize header inclusions and include-what-you-use <__debug>. NFCI. 2021-05-18 19:56:30 -04:00
Arthur O'Dwyer
6491d99e33 [libc++] Remove more unnecessary _VSTD:: from type names. NFCI.
Differential Revision: https://reviews.llvm.org/D102181
2021-05-11 12:23:55 -04:00
Mark de Wever
cfef7c918b [libc++][NFC] Remove _VSTD:: when not needed.
Reviewed By: #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D102133
2021-05-10 18:15:50 +02:00
zoecarver
879cbac08b [libc++][ranges] Add range.cmp: equal_to, not_equal_to, less, etc.
Adds the six new concept constrained comparisons.

Differential Revision: https://reviews.llvm.org/D100429
2021-04-22 17:33:04 -07:00
Louis Dionne
4cd6ca102a [libc++] NFC: Normalize #endif // comment indentation 2021-04-20 12:03:32 -04:00
Arthur O'Dwyer
4b7bad9eae [libc++] Implement D2351R0 "Mark all library static cast wrappers as [[nodiscard]]"
These [[nodiscard]] annotations are added as a conforming extension;
it's unclear whether the paper will actually be adopted and make them
mandatory, but they do seem like good ideas regardless.

https://isocpp.org/files/papers/D2351R0.pdf

This patch implements the paper's effect on:
- std::to_integer, std::to_underlying
- std::forward, std::move, std::move_if_noexcept
- std::as_const
- std::identity

The paper also affects (but libc++ does not yet have an implementation of):
- std::bit_cast

Differential Revision: https://reviews.llvm.org/D99895
2021-04-12 12:29:15 -04:00
Martin Storsjö
948dd664c3 [libcxx] Fix the type attribute for a couple templates
Use `_LIBCPP_TEMPLATE_VIS` instead of `_LIBCPP_TYPE_VIS` for a template
class.

This fixes the nodiscard_extensions.pass.cpp and a couple
func.search.default test cases when built in MSVC/DLL configurations.

Differential Revision: https://reviews.llvm.org/D99932
2021-04-06 19:54:34 +03:00
Christopher Di Bella
c25c22d5f9 [libcxx] moves std::invoke into __functional_base
Including `<concepts>` in other standard library headers (such as
`<iterator>`) creates circular dependencies due to `<functional>`.
Since `<concepts>` only needs `std::invoke` from `<functional>`, the
easiest, fastest, and cleanest way to eliminate the circular dep is to
move `std::invoke` into `__functional_base`.

This has the added advantage of `<concepts>` not transitively importing
`<functional>`.

Differential Revision: https://reviews.llvm.org/D99041
2021-04-06 01:25:15 +00:00
Christopher Di Bella
24c44c379f [libcxx] adds std::identity to <functional>
Implements parts of:
    - P0898R3 Standard Library Concepts

Differential Revision: https://reviews.llvm.org/D98151
2021-03-29 16:16:05 +00:00
Arthur O'Dwyer
2ac6babcc0 [libc++] Move __libcpp_erase_if_container into <iterator>, and ADL-proof it.
The container headers don't need to include <functional> for any other reason
(or at least, they wouldn't if we moved `less` and `equal_to` out of <functional>),
so let's put `__libcpp_erase_if_container` somewhere that's common to the
containers but outside of <functional>.

Also, calling `std::erase_if(c, pred)` should not trigger ADL.

Differential Revision: https://reviews.llvm.org/D99043
2021-03-22 11:13:33 -04:00