Commit Graph

21 Commits

Author SHA1 Message Date
Louis Dionne
9783f28cbb
[libc++] Format the code base (#74334)
This patch runs clang-format on all of libcxx/include and libcxx/src, in
accordance with the RFC discussed at [1]. Follow-up patches will format
the benchmarks, the test suite and remaining parts of the code. I'm
splitting this one into its own patch so the diff is a bit easier to
review.

This patch was generated with:

   find libcxx/include libcxx/src -type f \
      | grep -v 'module.modulemap.in' \
      | grep -v 'CMakeLists.txt' \
      | grep -v 'README.txt' \
      | grep -v 'libcxx.imp' \
      | grep -v '__config_site.in' \
      | xargs clang-format -i

A Git merge driver is available in libcxx/utils/clang-format-merge-driver.sh
to help resolve merge and rebase issues across these formatting changes.

[1]: https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
2023-12-18 14:01:33 -05:00
Louis Dionne
77a00c0d54
[libc++] Replace uses of _VSTD:: by std:: (#74331)
As part of the upcoming clang-formatting of libc++, this patch performs
the long desired removal of the _VSTD macro.

See https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
for the clang-format proposal.
2023-12-05 11:19:15 -05:00
Louis Dionne
4c19854222
[libc++] Rename _LIBCPP_INLINE_VISIBILITY to _LIBCPP_HIDE_FROM_ABI (#74095)
In preparation for running clang-format on the whole code base, we are
also removing mentions of the legacy _LIBCPP_INLINE_VISIBILITY macro in
favor of the newer _LIBCPP_HIDE_FROM_ABI.

We're still leaving the definition of _LIBCPP_INLINE_VISIBILITY to avoid
creating needless breakage in case some older patches are checked-in
with mentions of the old macro. After we branch for LLVM 18, we can do
another pass to clean up remaining uses of the macro that might have
gotten introduced by mistake (if any) and remove the macro itself at the
same time. This is just a minor convenience to smooth out the transition
as much as possible.

See
https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
for the clang-format proposal.
2023-12-04 10:25:14 -05:00
Nikolas Klauser
e698c59504 [libc++] Granularize <type_traits> includes in <algorithm>
Reviewed By: Mordante, #libc

Spies: libcxx-commits, wenlei

Differential Revision: https://reviews.llvm.org/D140673
2023-02-13 13:21:25 +01:00
varconst
5629d492df Reapply "[libc++][ranges]Refactor copy{,_backward} and move{,_backward}"
This reverts commit a6e1080b87.

Fix the conditions when the `memmove` optimization can be applied and refactor them out into a reusable type trait, fix and significantly expand the tests.

Differential Revision: https://reviews.llvm.org/D139235
2023-01-13 16:57:13 -08:00
Vitaly Buka
a6e1080b87 Revert "[libc++][ranges]Refactor copy{,_backward} and move{,_backward}"
Breaks msan, asan

https://lab.llvm.org/buildbot/#/builders/5/builds/27904

This reverts commit 005916de58.
2022-10-02 16:23:35 -07:00
Konstantin Varlamov
005916de58 [libc++][ranges]Refactor copy{,_backward} and move{,_backward}
Instead of using `reverse_iterator`, share the optimization between the 4 algorithms. The key observation here that `memmove` applies to both `copy` and `move` identically, and to their `_backward` versions very similarly. All algorithms now follow the same pattern along the lines of:
```
if constexpr (can_memmove<InIter, OutIter>) {
  memmove(first, last, out);
} else {
  naive_implementation(first, last, out);
}
```
A follow-up will delete `unconstrained_reverse_iterator`.

This patch removes duplication and divergence between `std::copy`, `std::move` and `std::move_backward`. It also improves testing:
- the test for whether the optimization is used only applied to `std::copy` and, more importantly, was essentially a no-op because it would still pass if the optimization was not used;
- there were no tests to make sure the optimization is not used when the effect would be visible.

Differential Revision: https://reviews.llvm.org/D130695
2022-10-01 17:35:12 -07:00
Nikolas Klauser
5146b57b40 [libc++][NFC] Rename the constexpr macros
This was discussed on Discord with the consensus that we should rename the macros.

Reviewed By: ldionne, Mordante, var-const, avogelsgesang, jloser, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D131498
2022-08-19 15:35:02 +02:00
Nikolas Klauser
80c7e93a2a [libc++] Add a bunch of missing _LIBCPP_HIDE_FROM_ABI
Reviewed By: ldionne, Mordante, var-const, huixie90, #libc

Spies: jloser, libcxx-commits, arichardson, miyuki

Differential Revision: https://reviews.llvm.org/D129968
2022-08-13 22:41:22 +02:00
Konstantin Varlamov
36c746ca2d [libc++][ranges] Implement ranges::rotate.
Also fix `ranges::stable_sort` and `ranges::inplace_merge` to support
proxy iterators now that their internal implementations can correctly
dispatch `rotate`.

Differential Revision: https://reviews.llvm.org/D130758
2022-08-03 16:04:24 -07:00
Konstantin Varlamov
8ed702b83f [libc++][ranges] Implement ranges::{,stable_}partition.
Differential Revision: https://reviews.llvm.org/D129624
2022-07-18 21:06:17 -07:00
Nikolas Klauser
3cd4531b9b [libc++] Granularize <iterator> includes
Reviewed By: ldionne, #libc

Spies: libcxx-commits, wenlei

Differential Revision: https://reviews.llvm.org/D127445
2022-06-10 22:43:57 +02: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
Louis Dionne
368faacac7 [libc++] Revert "Protect users from relying on detail headers" & related changes
This commit reverts 5aaefa51 (and also partly 7f285f48e7 and b6d75682f9,
which were related to the original commit). As landed, 5aaefa51 had
unintended consequences on some downstream bots and didn't have proper
coverage upstream due to a few subtle things. Implementing this is
something we should do in libc++, however we'll first need to address
a few issues listed in https://reviews.llvm.org/D106124#3349710.

Differential Revision: https://reviews.llvm.org/D120683
2022-03-01 08:20:24 -05:00
Christopher Di Bella
5aaefa510e [libcxx][modules] protects users from relying on detail headers
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 <__ranges/access.h> instead of
<ranges>, 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.

Differential Revision: https://reviews.llvm.org/D106124
2022-02-26 09:00:25 +00: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
Louis Dionne
64184b4af0 [libc++][NFC] Remove useless _LIBCPP_PUSH_MACROS
Only files that actually use min/max are required to do this dance.

Differential Revision: https://reviews.llvm.org/D108778
2021-08-27 12:41:55 -04: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
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
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