142 Commits

Author SHA1 Message Date
Nikolas Klauser
5bdad0555e
[libc++][NFC] Remove a few aliases in __tree (#134392)
These aliases aren't required anymore, since we've taken an ABI break
unconditionally which these were used to avoid.
2025-04-12 22:39:01 +02:00
Nikolas Klauser
af9c04fa68
[libc++] Remove _LIBCPP_TEMPLATE_VIS (#134885)
The need for `_LIBCPP_TEMPLATE_VIS` has been removed in #133233.
2025-04-09 23:47:57 +02:00
MisakaVan
ff5b649a84
[libc++] Fix a comment typo in __tree (#134831)
"Returns true **is** __root is a proper red black tree"
->
"Returns true **if** __root is a proper red black tree"
2025-04-08 12:17:43 +02:00
Nikolas Klauser
c8246f69f4
[libc++] Remove friend declarations from __tree (#133237)
Instead, make the few functions `map` relies on public. This makes it
more clear what is private to `__tree` and what is part of the
library-internal interface.
2025-03-28 20:50:23 +01:00
Mark de Wever
73cd84a90e
[NFC][libc++] Adds (multi|)(map|set) forward declarations. (#131541)
This removes duplicated forward declarations of these classes.

closes: #131518
2025-03-20 18:00:01 +01:00
Nikolas Klauser
fcc4ceb331
[libc++] Implement N4258(Cleaning-up noexcept in the Library) (#120312)
Fixes #99937
2025-01-30 21:10:56 +01:00
Nikolas Klauser
0fa05456a8
[libc++] Define an internal API for std::invoke and friends (#116637)
Currently we're using quite different internal names for the
`std::invoke` family of type traits. This adds a layer around the
current implementation to make it easier to understand when it is used
and makes it easier to define multiple implementations of it.
2025-01-20 18:00:15 +01:00
Nikolas Klauser
b905bcc509
[libc++] Remove some unused includes (#120219) 2024-12-18 21:10:27 +01:00
Louis Dionne
09e3a36058
[libc++][modules] Fix missing and incorrect includes (#108850)
This patch adds a large number of missing includes in the libc++ headers
and the test suite. Those were found as part of the effort to move
towards a mostly monolithic top-level std module.
2024-09-16 15:06:20 -04:00
Nikolas Klauser
01df775dc4
[libc++] Take the ABI break for std::list's pointer UB unconditionally (#100585)
This ABI break only affects fancy pointer which have a different value
representation when pointing to a base of T instead of T itself. This
seems like a rather small set of fancy pointers, which themselves
already represent a very small niche. This patch swaps a pointer to T
with a pointer to base of T in a few library-internal types.
2024-09-16 11:55:33 -04:00
Nikolas Klauser
27c83382d8
[libc++] Replace __compressed_pair with [[no_unique_address]] (#76756)
This significantly simplifies the code, improves compile times and
improves the object layout of types using `__compressed_pair` in the
unstable ABI. The only downside is that this is extremely ABI sensitive
and pedantically breaks the ABI for empty final types, since the address
of the subobject may change. The ABI of the whole object should not be
affected.

Fixes #91266
Fixes #93069
2024-09-16 11:08:57 +02:00
Nikolas Klauser
cb41740187
[libc++] Refactor<__type_traits/is_swappable.h> (#86822)
This changes the `is_swappable` implementation to use variable templates
first and basing the class templates on that. This avoids instantiating
them when the `_v` versions are used, which are generally less resource
intensive.
2024-06-18 11:01:43 +02:00
Nikolas Klauser
bbe4a80605
[libc++] Enable modernize-use-equals-delete (#93293)
Differential Revision: https://reviews.llvm.org/D121213
2024-06-18 10:51:57 +02:00
Nikolas Klauser
6b4b29f859
[libc++][NFC] Remove unnecessary parens in static_asserts (#95605)
These were required a long time ago due to `static_assert` not actually
being available in C++03. Now `static_assert` is simply mapped to
`_Static_assert` in C++03, making the additional parens unnecessary.
2024-06-18 10:45:30 +02:00
Nikolas Klauser
580f60484e
[libc++][NFC] Merge is{,_nothrow,_trivially}{,_copy,_move,_default}{_assignable,_constructible} (#85308)
These headers have become very small by using compiler builtins, often
containing only two declarations. This merges these headers, since
there doesn't seem to be much of a benefit keeping them separate.

Specifically, `is_{,_nothrow,_trivially}{assignable,constructible}` are
kept and the `copy`, `move` and `default` versions of these type traits
are moved in to the respective headers.
2024-03-18 08:29:44 +01:00
Nikolas Klauser
76a2472715
[libc++] Refactor more __enable_ifs to the canonical style (#81457)
This brings the code base closer to having only a single style of
`enable_if`s.
2024-02-20 01:47:38 +01:00
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
philnik777
a65070a76a
[libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
Louis Dionne
ba79fb2e1f [libc++] Re-apply "Remove UB in list, forward_list and __hash_table"
This patch removes undefined behavior in list and forward_list and __hash_table
caused by improperly beginning and ending the lifetime of the various node
classes. It allows removing the _LIBCPP_STANDALONE_DEBUG macro from
these node types since we now properly begin and end their lifetime,
meaning that we won't trip up constructor homing.

See https://reviews.llvm.org/D98750 for more information on what prompted
this patch.

This commit re-applies 0687e4d9f310, which had been reverted in b935882bdce7
because it broke the LLDB build. LLDB folks tell me I can go ahead and
re-commit this now.

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

Co-authored-by: Amy Kwan <amy.kwan1@ibm.com>
2023-10-13 08:03:22 -07:00
Krasimir Georgiev
b935882bdc Revert "[libc++] Remove UB in list, forward_list and __hash_table"
This reverts commit 0687e4d9f310249a45c3799ec66aeeeb0efda9f7.
Causes LLDB failures: https://reviews.llvm.org/D101206#4653253
2023-10-06 10:09:36 +00:00
Louis Dionne
0687e4d9f3 [libc++] Remove UB in list, forward_list and __hash_table
This patch removes undefined behavior in list and forward_list and __hash_table
caused by improperly beginning and ending the lifetime of the various node
classes. It allows removing the _LIBCPP_STANDALONE_DEBUG macro from
these node types since we now properly begin and end their lifetime,
meaning that we won't trip up constructor homing.

See https://reviews.llvm.org/D98750 for more information on what prompted
this patch.

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

Co-authored-by: Amy Kwan <amy.kwan1@ibm.com>
2023-10-05 13:02:00 -04:00
Nikolas Klauser
9f3e3efd98 [libc++][NFC] Refactor __enable_if return types to defaulted template parameters
This brings most of the enable_ifs in libc++ to the same style. It also has the nice side-effect of reducing the size of names of these symbols, since the depedent return type is shorter.

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D157787
2023-09-01 17:52:31 -07:00
varconst
4a652e4a99 [libc++][hardening] Categorize more assertions.
Differential Revision: https://reviews.llvm.org/D155873
2023-07-24 14:57:01 -07:00
varconst
4122db1fbd [libc++][hardening] Categorize most assertions inside the container classes.
This introduces:
- `_LIBCPP_ASSERT_VALID_INPUT_RANGE`;
- `_LIBCPP_ASSERT_VALID_CONTAINER_ACCESS`;
- `_LIBCPP_ASSERT_VALID_ITERATOR_ACCESS`;
- `_LIBCPP_ASSERT_VALID_ALLOCATOR`;
- `_LIBCPP_ASSERT_INTERNAL`.

Differential Revision: https://reviews.llvm.org/D155349
2023-07-20 10:14:43 -07:00
varconst
d1367ca46e [libc++][hardening][NFC] Add macros to enable hardened mode.
This patch only adds new configuration knobs -- the actual assertions
will be added in follow-up patches.

Differential Revision: https://reviews.llvm.org/D153902
2023-07-12 10:12:58 -07:00
Hans Wennborg
1e35e93e30 [libc++] Disable tree invariant check in asserts mode
This is a follow-up to D153672 which removed the old debug mode and
moved many of those checks to the regular asserts mode.

The tree invariant check is too expensive for the regular asserts mode,
making element removal O(n) instead of O(log n), so disable it until
there is a new debug assert category it can be put in.

Differential revision: https://reviews.llvm.org/D154417
2023-07-04 15:36:15 +02:00
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
varconst
cd0ad4216c [libc++][hardening][NFC] Introduce _LIBCPP_ASSERT_UNCATEGORIZED.
Replace most uses of `_LIBCPP_ASSERT` with
`_LIBCPP_ASSERT_UNCATEGORIZED`.

This is done as a prerequisite to introducing hardened mode to libc++.
The idea is to make enabling assertions an opt-in with (somewhat)
fine-grained controls over which categories of assertions are enabled.
The vast majority of assertions are currently uncategorized; the new
macro will allow turning on `_LIBCPP_ASSERT` (the underlying mechanism
for all kinds of assertions) without enabling all the uncategorized
assertions (in the future; this patch preserves the current behavior).

Differential Revision: https://reviews.llvm.org/D153816
2023-06-28 15:10:31 -07:00
Nikolas Klauser
80643d9366 [libc++][NFC] Rename iterator category checks to make it obvious that they check //only// the iterator category
We plan to add concepts for checking that iterators actually provide what they claim to. This is to avoid people thinking that these type traits actually check the iterator requirements in more detail.

Reviewed By: ldionne, #libc

Spies: Mordante, libcxx-commits, wenlei

Differential Revision: https://reviews.llvm.org/D150801
2023-05-18 15:37:28 -07:00
Ian Anderson
79702f7f59 [libc++][Modules] Add missing includes and exports
Several headers are missing includes for things they use.

type_traits.is_enum needs to export type_traits.integral_constant so that clients can access its `value` member without explicitly including __type_traits/integral_constant.h themselves.

Make `subrange_fwd` a peer submodule to `subrange` rather than a submodule of it, and have `subrange` export `subrange_fwd`. That will make it easier to programmatically generate modules for the private detail headers, and it will accomplish the same effect that __ranges/subrange.h will make subrange_kind visible.

Reviewed By: Mordante, #libc

Differential Revision: https://reviews.llvm.org/D150055
2023-05-07 19:54:49 -05:00
Nikolas Klauser
83ce139721 [libc++] Add hide_from_abi check for classes
We already have a clang-tidy check for making sure that `_LIBCPP_HIDE_FROM_ABI` is on free functions. This patch extends this to class members. The places where we don't check for `_LIBCPP_HIDE_FROM_ABI` are classes for which we have an instantiation in the library.

Reviewed By: ldionne, Mordante, #libc

Spies: jplehr, mikhail.ramalho, sstefan1, libcxx-commits, krytarowski, miyuki, smeenai

Differential Revision: https://reviews.llvm.org/D142332
2023-04-16 15:23:23 +02:00
Nikolas Klauser
43562287a8 [libc++] Granularize <exception>
This patch also updates the moved code to the new style (i.e. formatted, replaced marcos and typedefs)

Reviewed By: ldionne, #libc

Spies: arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D145095
2023-03-12 22:19:41 +01:00
Nikolas Klauser
4668dd8c4a [libc++] Run clang-tidy in all configurations that are run in the Docker container
Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D143333
2023-02-28 19:14:58 +01:00
Nikolas Klauser
4f15267d3d [libc++][NFC] Replace _LIBCPP_STD_VER > x with _LIBCPP_STD_VER >= x
This change is almost fully mechanical. The only interesting change is in `generate_feature_test_macro_components.py` to generate `_LIBCPP_STD_VER >=` instead. To avoid churn in the git-blame this commit should be added to the `.git-blame-ignore-revs` once committed.

Reviewed By: ldionne, var-const, #libc

Spies: jloser, libcxx-commits, arichardson, arphaman, wenlei

Differential Revision: https://reviews.llvm.org/D143962
2023-02-15 16:52:25 +01:00
Nikolas Klauser
430b397f67 [libc++] Granularize <type_traits> includes in <iterator>
Reviewed By: Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D140621
2022-12-27 02:32:16 +01:00
Nikolas Klauser
d7d586e5a7 [libc++] static_assert that rebinding the allocator works as expected
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D133638
2022-10-11 16:47:42 +02:00
Nikolas Klauser
ed2d3644ab [libc++][NFC] Prefer type aliases over structs
Reviewed By: ldionne, #libc

Spies: sstefan1, libcxx-commits, jeroen.dobbelaere

Differential Revision: https://reviews.llvm.org/D134901
2022-10-01 22:49:36 +02:00
Nikolas Klauser
5fab33af7f [libc++] Avoid instantiating type_trait classes
Use `using` aliases to avoid instantiating lots of types

Reviewed By: ldionne, #libc

Spies: libcxx-commits, miyuki

Differential Revision: https://reviews.llvm.org/D132785
2022-09-06 19:09:42 +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
Vitaly Buka
bc8fd9c633 Revert "[libc++] Granularize the rest of memory"
Breaks buildbots.

This reverts commit 30adaa730c4768b5eb06719c808b2884fcf53cf3.
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
Nikolas Klauser
7ae66e5e95 [libc++] Granularize the rest of type_traits
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D130471
2022-08-14 10:30:48 +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
Nikolas Klauser
f4fb72e6d4 [libc++] Use uninitialized algorithms for vector
Reviewed By: ldionne, #libc

Spies: huixie90, eaeltsin, joanahalili, bgraur, alexfh, hans, avogelsgesang, augusto2112, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D128146
2022-07-26 17:44:31 +02:00
Augusto Noronha
1d057a6d43 Revert "[libc++] Use uninitialized algorithms for vector"
This reverts commit 23cf42e706fbc2a939ce1470da16599b42258aea.
2022-07-21 14:19:20 -07:00
Nikolas Klauser
23cf42e706 [libc++] Use uninitialized algorithms for vector
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D128146
2022-07-20 22:02:14 +02:00
Nikolas Klauser
4887d047a3 [libc++][NFC] Replace enable_if with __enable_if_t in a few places
Reviewed By: ldionne, #libc

Spies: jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D128400
2022-07-04 11:09:34 +02:00
Mark de Wever
26465c8337 [libc++] Removes a GCC bug work-around.
Based on the comments in [1] this should be fixed in GCC-11.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37804

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D127590
2022-06-13 17:55:43 +02:00