812 Commits

Author SHA1 Message Date
Tom Stellard
3bd3e06f3f
Bump version to 21.0.0git (#124870)
Also clear the release notes.
2025-01-28 19:48:43 -08:00
Nikolas Klauser
24e70e3930
[libc++] Switch experimental library macros to 0/1 macros (#124030)
This is a continuation of what's been started in #89178.

As a drive-by, this also changes the PSTL macro to say `EXPERIMENTAL`
instead of `INCOMPLETE`.
2025-01-24 09:34:42 +01:00
Nikolas Klauser
6f684816e2
[libc++] Use [[clang::no_specializations]] to diagnose invalid user specializations (#118167)
Some templates in the standard library are illegal to specialize for users
(even if the specialization contains user-defined types). The [[clang::no_specializations]]
attribute allows marking such base templates so that the compiler will
diagnose if users try adding a specialization.
2025-01-23 13:18:54 +01:00
Nikolas Klauser
c83e5e85a3
[libc++] Enable _LIBCPP_NODEBUG again (#123318)
`_LIBCPP_NODEBUG` has been disabled temporarily, since there were a few
problems when adding a bunch of annotations throughout the code base.
They have been resolved now, so we can enable all the annotations again.

Reverts llvm/llvm-project#122393
2025-01-17 18:17:21 +01:00
Louis Dionne
c664a7f975
[libc++] Remove obsolete bsd_locale_defaults.h (#122276)
Supported platforms who used to need this header now go through the new
locale base API instead, so that header is not required anymore.
2025-01-10 11:03:50 -05:00
Nikolas Klauser
24bf0e4eb6
[libc++] Disable _LIBCPP_NODEBUG temporarily (#122393)
This should be reverted once the crash reported in #118710 has been
analyzed.
2025-01-10 01:37:24 +01:00
Nikolas Klauser
3b8faee6c6
[libc++] Switch _LIBCPP_NODEBUG to [[gnu::nodebug]] (#120720)
This makes the placement of the attribute more consistent. This also
avoids clang dropping the attribute silently (see #120722).
2024-12-22 00:55:35 +01:00
Nico Weber
a94cec5212
Revert "[libc++] Remove workaround which allows setting _LIBCPP_OVERRIDABLE_FUNC_VIS externally (#113139)" (#117779)
This reverts commit 2e686d6d17c4cc7608510a856055e6ca79fcb917.

See https://github.com/llvm/llvm-project/issues/117571
2024-11-26 18:45:03 -05:00
Caslyn Tonelli
bbf2ad026e
[libc++] Amend error message for _LIBCPP_HAS_THREAD_API_EXTERNAL (#115774)
Noticed this while debugging a few things following
https://github.com/llvm/llvm-project/pull/112094. Amended error message
to reflect conditional check.
2024-11-11 22:58:34 +01:00
Nikolas Klauser
c6f3b7bcd0
[libc++] Refactor the configuration macros to being always defined (#112094)
This is a follow-up to #89178. This updates the `<__config_site>`
macros.
2024-11-06 10:39:19 +01:00
Louis Dionne
61498a897d
[libc++] Include language.h inside __config (#114269)
We were getting this include transitively via availability.h, but we
really should be including it explicitly.
2024-10-31 11:35:30 -04:00
Louis Dionne
c9d9dc9c24
[libc++] Remove _LIBCPP_ENABLE_ASSERTIONS, which had been deprecated (#113592) 2024-10-29 10:48:18 -04:00
A. Jiang
08159e6e11
[libc++] __uglify [[clang::noescape]] (#113280)
Identifiers `clang` and `noescape` are not reserved by the C++ standard,
so perhaps we need to use the equivalent reserved forms.

Also changes the occurrences of that attribute to a macro, following the
convention for `[[_Clang::__lifetimebound__]]`.

Addresses
https://github.com/llvm/llvm-project/pull/91651#discussion_r1807852646.
2024-10-25 09:04:42 +08:00
Nikolas Klauser
2e686d6d17
[libc++] Remove workaround which allows setting _LIBCPP_OVERRIDABLE_FUNC_VIS externally (#113139)
`-fvisibility-global-new-delete` has been added in Clang 18, so there is
no more need to specify the visibility of new/delete via libc++-internal
macros.

Some people used a custom new/delete, which requires them to have
default visibility, but didn't want to leak any symbols otherwise. Since
the new/delete visibility can now be controlled by a compiler flag,
there is no reason to set it with out macro.

https://reviews.llvm.org/D128007 originally tried to remove the option
to override the macro, but was partially reverted because people
actually set this specific macro.
2024-10-24 16:11:34 +02:00
Nikolas Klauser
ba87515fea
[libc++][RFC] Always define internal feature test macros (#89178)
Currently, the library-internal feature test macros are only defined if
the feature is not available, and always have the prefix
`_LIBCPP_HAS_NO_`. This patch changes that, so that they are always
defined and have the prefix `_LIBCPP_HAS_` instead. This changes the
canonical use of these macros to `#if _LIBCPP_HAS_FEATURE`, which means
that using an undefined macro (e.g. due to a missing include) is
diagnosed now. While this is rather unlikely currently, a similar change
in `<__configuration/availability.h>` caught a few bugs. This also
improves readability, since it removes the double-negation of `#ifndef
_LIBCPP_HAS_NO_FEATURE`.

The current patch only touches the macros defined in `<__config>`. If
people are happy with this approach, I'll make a follow-up PR to also
change the macros defined in `<__config_site>`.
2024-10-12 09:49:52 +02:00
Un1q32
6389974873
[libc++] Don't use aligned_alloc on iOS versions before 13 (#110315)
There's a check here to not use aligned_alloc on macOS versions before
10.15, this patch adds an equivalent check that tests for iOS 13.
2024-09-27 16:11:47 -04:00
Nikolas Klauser
b177a9b6ef [libc++][NFC] Remove _LIBCPP_HAS_NO_NOEXCEPT
This macro is never used, so we can drop the definition of it too.
2024-09-21 18:39:21 +02: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
17e0686ab1
[libc++][NFC] Use [[__nodiscard__]] unconditionally (#80454)
`__has_cpp_attribute(__nodiscard__)` is always true now, so we might as
well replace `_LIBCPP_NODISCARD`. It's one less macro that can result in
bad diagnostics.
2024-09-12 21:18:43 +02:00
Louis Dionne
99174842ae
[libc++] Make std::jthread supported in non-experimental mode (#107900)
We waited before supporting std::jthread fully because we wanted to
investigate other implementation strategies (in particular one involving
std::mutex). Since then, we did some benchmarking and decided that we
wouldn't be moving forward with std::mutex. Hence, there is no real
reason to punt on making std::jthread & friends non-experimental.
2024-09-12 09:48:59 -04:00
Louis Dionne
118f120eaa
[libc++] Get rid of experimental/__config (#108233)
It doesn't serve much of a purpose since we can easily put its contents
inside __config. Removing it simplifies the modulemap once we are trying
to create a single top-level module.
2024-09-11 14:59:43 -04:00
Nikolas Klauser
748023dc32
[libc++][NFC] Replace _LIBCPP_NORETURN and TEST_NORETURN with [[noreturn]] (#80455)
`[[__noreturn__]]` is now always available, so we can simply use the
attribute directly instead of through a macro.
2024-09-11 08:59:46 +02:00
Nikolas Klauser
42f5277de1
[libc++] Fix __datasizeof_v for Clang17 and 18 in C++03 (#106832)
This also disables the use of `__datasizeof`, since it's currently
broken for empty types.
2024-09-03 19:46:08 +02:00
Joseph Huber
38dbcbdcb4
[libcxx] Use the default rune table when using the LLVM libc (#106632)
Summary:
We currently do not provide a more complicated rune table, so we want
the
default.
2024-08-31 07:07:52 -05:00
A. Jiang
7808541fde
[libc++] P2747R2: constexpr placement new (library part) (#105768)
This patch implements https://wg21.link/P2747R2.

The library changes affect direct `operator new` and `operator new[]`
calls even when the core language changes are absent.

The changes are not available for MS ABI because the `operator new` and
`operator new[]` are from VCRuntime's `<vcruntime_new.h>`. A feature
request was submitted for that [1].

As a drive-by change, the patch reformatted the whole `new.pass.cpp` and
`new_array.pass.cpp` tests.

Closes #105427

[1]: https://developercommunity.visualstudio.com/t/constexpr-for-placement-operator-newope/10730304.
2024-08-28 09:35:57 -04:00
Louis Dionne
bf1666fb0b
[libc++] Drop support for the C++20 Synchronization Library before C++20 (#82008)
When we initially implemented the C++20 synchronization library, we
reluctantly accepted for the implementation to be backported to C++03
upon request from the person who provided the patch. This was when we
were only starting to have experience with the issues this can create,
so we flinched. Nowadays, we have a much stricter stance about not
backporting features to previous standards.

We have recently started fixing several bugs (and near bugs) in our
implementation of the synchronization library. A recurring theme during
these reviews has been how difficult to understand the current code is,
and upon inspection it becomes clear that being able to use a few recent
C++ features (in particular lambdas) would help a great deal. The code
would still be pretty intricate, but it would be a lot easier to reason
about the flow of callbacks through things like
__thread_poll_with_backoff.

As a result, this patch drops support for the synchronization library
before C++20. This makes us more strictly conforming and opens the door
to major simplifications, in particular around atomic_wait which was
supported all the way to C++03.

This change will probably have some impact on downstream users, however
since the C++20 synchronization library was added only in LLVM 10 (~3
years ago) and it's quite a niche feature, the set of people trying to
use this part of the library before C++20 should be reasonably small.
2024-07-31 17:53:09 -04:00
Tobias Hieta
8f701b5df0
Set version to 20.0.0git
LLVM 19 release is starting.
2024-07-23 11:04:06 +02:00
Nikolas Klauser
69fecaa1a4
[libc++] Clean up some now dead code with the upgrade to GCC 14 (#97746) 2024-07-13 09:41:36 +02:00
Louis Dionne
9bd575dd60
[libc++] Deprecate _LIBCPP_ENABLE_ASSERTIONS & friends (#98364)
In LLVM 19, the old xxx_ENABLE_ASSERTIONS settings should be deprecated
with the goal of removing them entirely in LLVM 20.
2024-07-12 16:07:12 -04:00
Louis Dionne
e2c2ffbe7a
[libc++][NFC] Run clang-format on libcxx/include again (#95874)
As time went by, a few files have become mis-formatted w.r.t.
clang-format. This was made worse by the fact that formatting was not
being enforced in extensionless headers. This commit simply brings all
of libcxx/include in-line with clang-format again.

We might have to do this from time to time as we update our clang-format
version, but frankly this is really low effort now that we've formatted
everything once.
2024-06-18 09:13:45 -04:00
Nikolas Klauser
5367b2c862
[libc++] Don't give functions C linkage (#94102)
There is no reason to give any of the functions C linkage. This makes
all of the libc++ functions have C++ linkage, removing the need for
`_LIBCPP_HIDE_FROM_ABI_C`.
2024-06-02 21:05:53 +02:00
Nikolas Klauser
5d31360d71
[libc++] Remove the inline namespace for std::filesystem in ABIv2 (#92971) 2024-06-01 08:37:49 +02:00
Louis Dionne
04f01a2b9c
[libc++] Make the __availability header a sub-header of __config (#93083)
In essence, this header has always been related to configuration of
the library but we didn't want to put it inside <__config> due to
complexity reasons. Now that we have sub-headers in <__config>, we
can move <__availability> to it and stop including it everywhere since
we already obtain the required macros via <__config>.
2024-05-28 18:29:11 -07:00
Louis Dionne
23e1ed65c2
[libc++] Split up ABI and platform configuration to their own headers (#90863)
This is a first step towards splitting up the <__config> header. The
<__config> header is large and rather disorganized at this point,
leading to confusion and subtle mistakes. For example, we never noticed
that the string layout used on arm64 was only enabled for the Clang
compiler, as the setting being in the compiler == clang block was
probably never intentional.

The danger of splitting up the <__config> header is to implicitly use
undefined macros that should have been defined prior to their usage,
however this can be remediated with -Wundef and we've started moving
towards -Wundef enforceable macros.
2024-05-28 07:22:06 -04:00
Louis Dionne
46a5de69c0
[libc++] Remove a few __has_foo defines in __config (#90511)
All the compilers we support implement those macros or builtins, so it's
not useful to have a fallback to 0 when they're not implemented.
2024-05-02 08:37:13 -06:00
Louis Dionne
a00bbcbe7c
[libc++] Remove _LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS (#90512)
I strongly suspect nobody ever used that macro since it wasn't very well
known. Furthermore, it only affects a handful of diagnostics and I think
it makes sense to either provide them unconditionally, or to not
provided them at all.
2024-05-01 10:26:38 -06:00
Nikolas Klauser
83bc7b5771
[libc++] Remove _LIBCPP_DISABLE_NODISCARD_EXTENSIONS and refactor the tests (#87094)
This also adds a few tests that were missing.
2024-04-22 22:13:58 +02:00
Mark de Wever
a4422a5194
[libc++][TZDB] Renames incomplete. (#89250)
The new name uses experimental which better conveys what it means.
2024-04-20 12:09:13 +02:00
Mark de Wever
41a830500a
[libc++] Removes deprecated _LIBCPP_ENABLE_<VERSION>_REMOVED_FEATURES macros (#88548)
We marked those macros as deprecated in the last release with the intent
of
removing them in LLVM 19. This commit performs the removal.
2024-04-16 20:20:37 +02:00
Louis Dionne
9ddedf07ed
[libc++] Deprecate the C++20 synchronization library before C++20 (#86410)
When we initially implemented the C++20 synchronization library, we
reluctantly accepted for the implementation to be backported to C++03
upon request from the person who provided the patch. This was when we
were only starting to have experience with the issues this can create,
so we flinched. Nowadays, we have a much stricter stance about not
backporting features to previous standards.

We have recently started fixing several bugs (and near bugs) in our
implementation of the synchronization library. A recurring theme during
these reviews has been how difficult to understand the current code is,
and upon inspection it becomes clear that being able to use a few recent
C++ features (in particular lambdas) would help a great deal. The code
would still be pretty intricate, but it would be a lot easier to reason
about the flow of callbacks through things like
__thread_poll_with_backoff.

As a result, this patch deprecates support for the synchronization
library before C++20. In the next release, we can remove that support
entirely.
2024-04-16 10:57:48 -04:00
Louis Dionne
22629bb22a
[libc++] Use availability to rely on key functions for bad_expected_access and bad_function_call (#87390)
This patch uses our availability machinery to allow defining a key
function for bad_function_call and bad_expected_access at all times but
only rely on it when we can. This prevents compilers from complaining
about weak vtables and reduces code bloat and the amount of work done by
the dynamic linker.

rdar://111917845
2024-04-16 10:54:28 -04:00
Nikolas Klauser
61f1f13002
[libc++][NFC] Move basic ASan annotation functions into a utility header (#87220) 2024-04-13 18:24:12 +02:00
Mark de Wever
0ad663ead1
[libc++] Removes Clang-16 support. (#87810)
With the release of Clang-18 we no longer officially support Clang-16.
2024-04-10 17:51:02 +02:00
Mark de Wever
d179176f3e
[libc++][format] Adds ABI tags to inline constexpr variables. (#86293)
This uses the macro on record types and inline constexpr variables. The
tagged declarations are very likely to change in future versions of
libc++:
- __fields are internal types used to control the formatter's parse
functions which fields to expect. Newer formatters may add new fields.
For example the filesystem::path formatter accepted in the recent Tokyo
meeting added a new 'g' flag, which differs from the 'g' type.
- The Unicode tables. The number of entries in these table likely differ
between Unicode versions. The tables contain only a part of all Unicode
properties. Typically they are stored in a 32-bit entry where some bits
contain the properties and other bits the size of the range. Changes in
the Unicode or C++ algorithms may require more properties to be
available in C++. This may affect the number of bits available in the
range. If needed, other declarations get the macro. This is mainly a
first time to review this approach.

This was originally https://reviews.llvm.org/D143494 where a new macro
_LIBCPP_HIDE_FROM_ABI_TYPE was defined. Testing revealed the existing
macro _LIBCPP_HIDE_FROM_ABI could be used. The "parts" of the macro that
do not affect records are not harmful. Based on this information the
existing macro was used and additional documentation was written.
2024-03-25 18:33:30 +01:00
Nikolas Klauser
f886dfed3a
[libc++] Don't push and pop extensions diagnostics when using clang modules (#85917)
Clang modules take a significant compile time hit when pushing and
popping diagnostics. Since all the headers are marked as system headers
in the modulemap, we can simply disable this pushing and popping when
building with clang modules.
2024-03-23 13:54:35 +01:00
Ilya Biryukov
4bf8dc1a0f
[libc++] Remove macros for keeping std::allocator members and void specialization after C++20 (#85806)
Fixes #75975.

Remove `_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS` for the LLVM 19
release, it was previously marked as deprecated in LLVM 18.

I believe that
`_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION` was only
used by Google in conjunction with
`_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS`.

Removing both macros together should not cause any issues in practice,
even though we did not announce the removal of
`_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION` before.
2024-03-21 17:48:13 +01:00
Nikolas Klauser
4d323e404d
[libc++] Allow the use of extensions in the implementation (#79532)
We've talked about allowing extensions on
[discourse](https://discourse.llvm.org/t/rfc-use-language-extensions-from-future-standards-in-libc/71898/5)
and in a libc++ monthly meeting and agreed to test it out in the LLVM 18
release. We've done that with the `tuple` constructor overload set
(using conditional `explicit`). Since we haven't heard about any
breakages, it seems safe to do. This patch enables the use of extension
from later C++ standards inside the versioned `std` namespaces. This
should be good enough, since almost all of our code is inside that
namespace. This approach also avoids the use of extensions inside the
test `std` suite. That part of the code base should stay clean, since
it's a test suite that is also used by other vendors to test their
implementations.
2024-03-09 01:09:28 +01:00
Louis Dionne
5174b38025
[libc++] Use __wrap_iter in string_view and array in the unstable ABI (#74482)
std::string_view and std::array iterators don't have to be raw pointers,
and in fact other implementations don't represent them as raw pointers.
Them being raw pointers in libc++ makes it easier for users to write
non-portable code. This is bad in itself, but this is even worse when
considering efforts like hardening where we want an easy ability to
swap for a different iterator type. If users depend on iterators being
raw pointers, this becomes a build break.

Hence, this patch enables the use of __wrap_iter in the unstable ABI,
creating a long term path towards making this the default. This patch
may break code that assumes these iterators are raw pointers for
people compiling with the unstable ABI.

This patch also removes several assumptions that array iterators are
raw pointers in the code base and in the test suite.
2024-03-04 18:23:53 -05:00
Louis Dionne
37dca605c9
[libc++] Clean up includes of <__assert> (#80091)
Originally, we used __libcpp_verbose_abort to handle assertion failures.
That function was declared from all public headers. Since we don't use
that mechanism anymore, we don't need to declare __libcpp_verbose_abort
from all public headers, and we can clean up a lot of unnecessary
includes.

This patch also moves the definition of the various assertion categories
to the <__assert> header, since we now rely on regular IWYU for these
assertion macros.

rdar://105510916
2024-02-29 10:12:22 -05:00
Nikolas Klauser
1530034166
[libc++] Remove unnecessary includes from <atomic> (#82880)
This reduces the include time of `<atomic>` from 135ms to 88ms.
2024-02-28 21:14:35 +01:00