Commit Graph

102 Commits

Author SHA1 Message Date
Louis Dionne ee44dd8062 [libc++] Implement the underlying mechanism for range adaptors
This patch implements the underlying mechanism for range adaptors. It
does so based on http://wg21.link/p2387, even though that paper hasn't
been adopted yet. In the future, if p2387 is adopted, it would suffice
to rename `__bind_back` to `std::bind_back` and `__range_adaptor_closure`
to `std::range_adaptor_closure` to implement that paper by the spec.

Differential Revision: https://reviews.llvm.org/D107098
2021-08-26 14:07:21 -04:00
Arthur O'Dwyer 38812f4ac1 [libc++] [P1614] Implement std::compare_three_way_result.
Differential Revision: https://reviews.llvm.org/D103581
2021-08-18 10:01:24 -04:00
zoecarver df324bba5c [libcxx][ranges] Add `ranges::join_view`.
Differential Revision: https://reviews.llvm.org/D107671
2021-08-13 11:31:08 -07:00
zoecarver 7b20e05c71 [libcxx][ranges] Add `ranges::iota_view`.
Differential Revision: https://reviews.llvm.org/D107396
2021-08-13 11:31:08 -07:00
zoecarver 4ac87e3378 [libcxx][ranges] Add `unreachable_sentinel`.
Differential Revision: https://reviews.llvm.org/D107920
2021-08-12 10:11:27 -07: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
Arthur O'Dwyer 58915667d0 [libc++][modularisation] Split up <concepts> into granular headers.
This is the complete split of <concepts>, with nothing left in the main header.

Differential Revision: https://reviews.llvm.org/D107584
2021-08-10 22:02:41 -04:00
zoecarver f9e58f35e9 [libcxx][ranges] Add `views::counted` CPO.
Differential Revision: https://reviews.llvm.org/D106923
2021-08-10 16:42:28 -07:00
zoecarver 9d982c67ba [libcxx][ranges] Add `ranges::reverse_view`.
Differential Revision: https://reviews.llvm.org/D107096
2021-08-09 15:09:59 -07:00
zoecarver 481ad59b9f [libcxx][ranges] Add `std::ranges::single_view`.
Differential Revision: https://reviews.llvm.org/D106840
2021-07-30 10:53:20 -07:00
Ruslan Arutyunyan 61c35fb0c2 [libc++][modularisation] Split <compare> into internal headers.
Differential Revision: https://reviews.llvm.org/D106107
2021-07-28 22:28:26 -04:00
zoecarver 0f4b41e038 [libcxx][ranges] Add ranges::take_view.
Differential Revision: https://reviews.llvm.org/D106507
2021-07-28 12:14:21 -07:00
zoecarver 8a48e6dda9 [libcxx][ranges] Add `counted_iterator`.
Differential Revision: https://reviews.llvm.org/D106205
2021-07-27 15:50:11 -07:00
zoecarver e5d8b93e5a [libcxx][ranges] Add `ranges::common_view`.
Differential Revision: https://reviews.llvm.org/D105753
2021-07-23 09:08:49 -07:00
Christopher Di Bella 0cf65382ad [libcxx][modularisation] properly modularises advance, next, and prev
`__function_like` wasn't being exported, so certain properties of the
`ranges` functions weren't being propagated in modules land.

Differential Revision: https://reviews.llvm.org/D105078
2021-07-22 23:30:02 +00:00
Louis Dionne 3959c95deb [libc++] Add helper type non-propagating-cache
Differential Revision: https://reviews.llvm.org/D102121
2021-07-22 14:30:16 -04:00
Christopher Di Bella 74fd3cb8cd [libcxx][ranges] implements dangling, borrowed_iterator_t, borrowed_subrange_t
* Implements part of P0896 'The One Ranges Proposal'
* Implements http://wg21.link/range.dangling

Reviewed By: zoecarver

Differential Revision: https://reviews.llvm.org/D105205
2021-07-21 21:34:13 +00:00
zoecarver 1a29403d2f [libcxx][ranges] Add common_iterator.
Differential Revision: https://reviews.llvm.org/D103335
2021-07-20 08:12:44 -07:00
Christopher Di Bella e37bbfe59c [libcxx][modules] protects users from relying on libc++ detail headers (1/n)
libc++ has started splicing standard library headers into much more
fine-grained content for maintainability. It's very likely that outdated
and naive tooling (some of which is outside of LLVM's scope) will
suggest users include things such as `<__algorithm/find.h>` instead of
`<algorithm>`, and Hyrum's law suggests that users will eventually begin
to rely on this without the help of tooling. As such, this commit
intends to protect users from themselves, by making it a hard error for
anyone outside of the standard library to include libc++ detail headers.

This is the first of four patches. Patch #2 will solve the problem for
pre-processor `#include`s; patches #3 and #4 will solve the problem for
`<__tree>` and `<__hash_table>` (since I've never touched the test cases
that are failing for these two, I want to split them out into their own
commits to be extra careful). Patch #5 will concern itself with
`<__threading_support>`, which intersects with libcxxabi (which I know
even less about).

Differential Revision: https://reviews.llvm.org/D105932
2021-07-16 22:39:18 +00:00
Christopher Di Bella 6cb05ca392 [libcxx][modularisation] adds several headers to the module map
* <__algorithm/iter_swap.h>
* <__algorithm/swap_ranges.h>
* <__functional/is_transparent.h>
* <__memory/uses_allocator.h>
* <__ranges/drop_view.h>
* <__ranges/transform_view.h>
* <shared_mutex>
* <span>

Also updates header inclusions that were affected.

**NOTE:** This is a proper subset of D105932. Since the content has
already been LGTM'd, I intend to merge this patch without review,
pending green CI. I decided it would be better to move these changes
into their own commit since the former patch has undergone further
changes and will need yet another light review. In the event any of
that gets rolled back (for whatever reason), the changes in this patch
won't be affected.

Differential Revision: https://reviews.llvm.org/D106040
2021-07-16 16:06:54 +00:00
Mark de Wever 321c2ea91c [libc++][NFC] Move monostate to its own header.
The format library uses `std::monostate`, but not a `std::variant`.
Moving `std::monostate` to its own header allows the format library to
reduce the amount of included code.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D105582
2021-07-08 17:35:26 +02:00
Louis Dionne 6829db727e [libc++] Implement copyable-box from Ranges
Differential Revision: https://reviews.llvm.org/D102135
2021-07-07 06:14:24 -04:00
Louis Dionne 5d2511c389 [libc++] NFC: Sort header lists and remove outdated comments in modulemap 2021-07-06 14:45:52 -04:00
Christopher Di Bella 8517a26d44 [libcxx][modularisation] splices `<iterator>` into individual headers
Differential Revision: https://reviews.llvm.org/D105076
2021-07-06 17:59:21 +00:00
Louis Dionne 681aa574c0 [libc++] NFC: Sort headers in CMakeLists.txt 2021-07-05 09:25:15 -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
Louis Dionne f32f3db9fc [libc++] Split the various iterator types out of <iterator>
Differential Revision: https://reviews.llvm.org/D104669
2021-06-28 12:25:40 -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
Louis Dionne 87dbe6c4ef [libc++] NFC: Add missing all.h to the modulemap 2021-06-22 13:47:41 -04:00
zoecarver 40d6d2c49d [libcxx][ranges] Add `ranges::iter_swap`.
Differential Revision: https://reviews.llvm.org/D102809
2021-06-22 09:52:40 -07: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
Christopher Di Bella d827af03bc [libcxx][module-map] 🎨 updates module map to account for ranges headers
Corresponding module map update for D104414, split out for rollback
reasons.

Differential Revision: https://reviews.llvm.org/D104415
2021-06-17 16:52:35 +00:00
Christopher Di Bella c5076d8371 Revert "Revert "[libcxx][module-map] creates submodules for private headers""
This reverts commit d9633f229c as a
workaround was discovered.

Differential Revision: https://reviews.llvm.org/D104170
2021-06-16 16:36:41 +00: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
Petr Hosek d9633f229c Revert "[libcxx][module-map] creates submodules for private headers"
This reverts commit f1417eb9b1 as it
uncovered a Clang bug PR50592.
2021-06-07 17:10:05 -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
Christopher Di Bella f1417eb9b1 [libcxx][module-map] creates submodules for private headers
Most of our private headers need to be treated as submodules so that
Clang modules can export things correctly. Previous commits that split
monolithic headers into smaller chunks were unaware of this requirement,
and so this is being addressed in one fell swoop. Moving forward, most
new headers will need to have their own submodule (anything that's
conditionally included is exempt from this rule, which means `__support`
headers aren't made into submodules).

This hasn't been marked NFC, since I'm not 100% sure that's the case.

Differential Revision: https://reviews.llvm.org/D103551
2021-06-03 18:18:30 +00:00
Louis Dionne 05d164b25c Revert "[libc++] NFC: Move unwrap_iter to its own header"
This reverts commit 924ea3bb53 *again*, this time because it broke the
LLDB build with modules. We need to figure out what's up with the libc++
modules build once and for all.

Differential Revision: https://reviews.llvm.org/D103369
2021-06-02 15:58:27 -04:00
Louis Dionne 924ea3bb53 [libc++] NFC: Move unwrap_iter to its own header
This re-applies 9968896cd6, which was reverted in b13edf6e90 because
it broke the build.

Differential Revision: https://reviews.llvm.org/D103369
2021-06-01 21:46:59 -04:00
Arthur O'Dwyer c9385297ce [libc++] [modules] Add __threading_support to the modulemap.
It looks to me as if *every* helper header needs to be added to the modulemap,
actually; which is unfortunate since we keep proliferating them at such a
rapid pace.
2021-05-29 19:54:38 -04:00
Arthur O'Dwyer 0b10bb7ddd [libc++] Move <__sso_allocator> out of include/ into src/. NFCI.
This allocator is not intended for libc++'s users to use;
it's strictly an implementation detail of `src/locale.cpp`.
So, move it to the `src/include/` directory.

Drive-by const-qualify its comparison operators.

For consistency with `__hidden_allocator` (defined in `src/thread.cpp`),
do *not* remove it from "libcxx/lib/libc++unexp.exp",
"libcxx/utils/symcheck-blacklists/linux_blacklist.txt", etc.

Differential Revision: https://reviews.llvm.org/D101293
2021-05-05 16:20:52 -04:00
Christopher Di Bella 5a3309f825 [libcxx][ranges] adds `range` access CPOs
* `std::ranges::begin`
* `std::ranges::cbegin`
* `std::ranges::end`
* `std::ranges::cend`
* `std::ranges::iterator` (required for `end`)

Implements parts of:
    * P0896R4 The One Ranges Proposal`

Co-author: @zoecarver

Depends on D90999, D100160.

Differential Revision: https://reviews.llvm.org/D100255
2021-04-30 16:56:42 +00:00
Mark de Wever 01ace074fc [libc++] Implements ranges::enable_borrowed_range
This is the initial patch to implement ranges in libc++.

Implements parts of:
- P0896R4 One Ranges Proposal
- P1870 forwarding-range is too subtle
- LWG3379 in several library names is misleading

Reviewed By: ldionne, #libc, cjdb, zoecarver, Quuxplusone

Differential Revision: https://reviews.llvm.org/D90999
2021-04-18 13:35:08 +02: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
Thorsten Schütt b973e2e2f2 [libc++] Introduce __bits
It has the low-level bit fiddling operations from bit. It eliminates a cyclic dependency between __bit_reference, bits, and vector. I want to exploit this in later patches.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D94908
2021-01-22 21:20:23 +01: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
Eric Fiselier 601f763182 [libcxx] Adds [concept.same]
Patch from Christopher Di Bella (cjdb@google.com)
Reviewed as https://reviews.llvm.org/D74291

Adds `std::same_as` to libc++. Since there aren't clang-format rules for
//requires-expressions//, I'll need to disable the formatter in certain areas.
2020-04-08 18:00:13 -04:00
Raphael Isemann b61e83eb0e [libc++] Give headers that require C++14 a cplusplus14 requires in the modulemap
https://reviews.llvm.org/D68480 added those headers and made the std module
only usable with C++14 or later as the submodules were not marked as requiring
C++14 or later. This just adds the missing requires directives.
2020-02-24 20:20:55 +01:00