Commit Graph

8945 Commits

Author SHA1 Message Date
Mark de Wever 5599e2c44e [libc++][doc] Update format implementation status. 2022-03-27 17:14:27 +02:00
Mark de Wever 555214cbcc [libc++][format][2/6] Adds a __output_iterator.
Instead of using a temporary `string` in `__vformat_to_wrapped` use a new
generic iterator. This aids to reduce the number of template instantions
and avoids using a `string` to buffer the entire formatted output.

This changes the type of `format_context` and `wformat_context`, this can
still be done since the code isn't ABI stable yet.

Several approaches have been evaluated:
- Using a __output_buffer base class with:
  - a put function to store the buffer in its internal buffer
  - a virtual flush function to copy the internal buffer to the output
- Using a `function` to forward the output operation to the output buffer,
  much like the next method.
- Using a type erased function point to store the data in the buffer.
The last version resulted in the best performance. For some cases there's
still a loss of speed over the original method. This loss many becomes
apparent when large strings are copied to a pointer like iterator, before
the compiler optimized this using `memcpy`.

Reviewed By: ldionne, vitaut, #libc

Differential Revision: https://reviews.llvm.org/D110495
2022-03-26 16:48:01 +01:00
Louis Dionne f900f7025c [libc++] Remove the _LIBCPP_BOOL_CONSTANT macro
I suspect this is a remnant of the times when we were not comfortable
using Clang's C++11/14 extensions everywhere, but now we do, so we can
use _BoolConstant instead and get rid of the macro.

Differential Revision: https://reviews.llvm.org/D122351
2022-03-25 08:46:14 -04:00
Nikolas Klauser 3c6bd176fb [libc++] Rename __identity to __type_identity
In C++20 the type trait `type_identity` was introduced. For the same purpose there is `__identity` for pre-C++20 code. The name is confusing, because since C++20 there is also `identity`, which isn't a type trait.

Reviewed By: ldionne, Mordante, #libc

Spies: EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D122017
2022-03-25 01:01:28 +01:00
Louis Dionne c87c8917e3 [libc++] Audit all uses of _LIBCPP_ASSERT and _LIBCPP_DEBUG_ASSERT
I audited all uses of _LIBCPP_ASSERT to make sure that we only used it
for "basic assertions", i.e. assertions with constant-time conditions.
I also audited all uses of _LIBCPP_DEBUG_ASSERT to make sure we used it
only for debug-mode assertions, and in one case had to change for
_LIBCPP_ASSERT instead.

As a fly-by, I also changed a couple of tests against nullptr or 0 to
be more explicit.

After this patch, all uses of _LIBCPP_ASSERT should be with constant-time
conditions, and all uses of _LIBCPP_DEBUG_ASSERT should be with conditions
that we only want to check when the debug mode is enabled.

Differential Revision: https://reviews.llvm.org/D122395
2022-03-24 13:13:21 -04:00
Louis Dionne fea3ca5dc8 [libc++][NFC] Refactor the ABI changelog
Add missing commit SHAs in a few cases, and use "All Platforms" when
the change affected all platforms instead of explicitly listing the
platforms, since there's too many to list exhaustively.
2022-03-24 10:24:43 -04:00
Louis Dionne 5c458f3e57 [libc++][NFC] Update ABI changelog to account for new assertion handler 2022-03-24 09:57:41 -04:00
Louis Dionne b0fd9497af [libc++] Add a lightweight overridable assertion handler
This patch adds a lightweight assertion handler mechanism that can be
overriden at link-time in a fashion similar to `operator new`.

This is a third take on https://llvm.org/D121123 (which allowed customizing
the assertion handler at compile-time), and https://llvm.org/D119969
(which allowed customizing the assertion handler at runtime only).

This approach is, I think, the best of all three explored approaches.
Indeed, replacing the assertion handler in user code is ergonomic,
yet we retain the ability to provide a custom assertion handler when
deploying to older platforms that don't have a default handler in
the dylib.

As-is, this patch provides a pretty good amount of backwards compatibility
with the previous debug mode:

- Code that used to set _LIBCPP_DEBUG=0 in order to get basic assertions
  in their code will still get basic assertions out of the box, but
  those assertions will be using the new assertion handler support.
- Code that was previously compiled with references to __libcpp_debug_function
  and friends will work out-of-the-box, no changes required. This is
  because we provide the same symbols in the dylib as we used to.
- Code that used to set a custom __libcpp_debug_function will stop
  compiling, because we don't provide that declaration anymore. Users
  will have to migrate to the new way of setting a custom assertion
  handler, which is extremely easy. I suspect that pool of users is
  very limited, so breaking them at compile-time is probably acceptable.

The main downside of this approach is that code being compiled with
assertions enabled but deploying to an older platform where the assertion
handler didn't exist yet will fail to compile. However users can easily
fix the problem by providing a custom assertion handler and defining
the _LIBCPP_AVAILABILITY_CUSTOM_ASSERTION_HANDLER_PROVIDED macro to
let the library know about the custom handler. In a way, this is
actually a feature because it avoids a load-time error that one would
otherwise get when trying to run the code on the older target.

Differential Revision: https://reviews.llvm.org/D121478
2022-03-23 15:35:46 -04:00
Louis Dionne cb1598cf6e [libc++] Correct outdated documentation about __config_site
The way we handle __config_site changed 1-2 years ago, and the
documentation was never updated -- this commit does that.
2022-03-23 13:42:04 -04:00
Louis Dionne 215f5fd135 [libc++][NFC] Change availability macro from macosx to macos
The Clang documentation mentions that macosx is supported for backwards
compatibility, but it's deprecated.
2022-03-23 13:14:19 -04:00
Louis Dionne cc82a1b02a [libc++][NFC] Fix include guards and add a missing license header 2022-03-23 13:14:19 -04:00
Danny Mösch a749e3295d Replace links to archived mailing lists by links to Discourse forums 2022-03-23 10:10:20 -04:00
Louis Dionne 59fae7b2c0 [libc++][NFC] Slight improvement to __availability documentation 2022-03-22 16:48:35 -04:00
Louis Dionne 129504014a [libc++][NFC] Use struct instead of class for ranges::end
This is consistent with what we do elsewhere.
2022-03-22 15:36:47 -04:00
Petr Hosek e4e281eae9 Revert "[bootstrap] Allow passing options to sub-builds for all targets"
This reverts commit 240e06dfe7.
2022-03-21 22:21:30 -07:00
Louis Dionne 6a7f055117 [libc++] Re-enable workaround for pre-ranges CTAD in std::span
See https://reviews.llvm.org/D121626 for details -- this re-enables the
CTAD we removed, since it does break some stuff as well (even though it's
not nearly as bad as the removed constructors fixed by D121626).

Differential Revision: https://reviews.llvm.org/D122184
2022-03-21 21:56:42 -04:00
Louis Dionne 240e06dfe7 [bootstrap] Allow passing options to sub-builds for all targets
This patch makes it possible to pass a CMake option to one of the runtimes
for all targets being built. Basically, any option that starts with the
name of a runtime project being built will be forwarded as-is to the
sub-build. This is useful for customizing a sub-build for all targets.

Differential Revision: https://reviews.llvm.org/D121822
2022-03-21 15:38:14 -04:00
Zarko Todorovski 0f0520003a [libc++][AIX] AIX allows for changing permissions of symlinks
The test fails on AIX due to it expecting an error as on Linux. However, as on
other non-Linux systems symlinks permissions are supported so expect an empty
error code.

Reviewed By: daltenty, #libc, ldionne

Differential Revision: https://reviews.llvm.org/D121140
2022-03-21 14:39:37 -04:00
Louis Dionne d6f00f8839 [libc++] Trigger CI when cmake/ is modified 2022-03-21 13:51:01 -04:00
Louis Dionne 5082b94285 [libunwind] Add libunwind to the bootstrapping build CI
Differential Revision: https://reviews.llvm.org/D122006
2022-03-21 10:11:05 -04:00
Louis Dionne f2b376f06b [libc++] Disable modules with the bootstrapping build
It turns out that we had never been enabling it anyways, since the
LIBCXX_TEST_PARAMS parameter was not being passed from the bootstrapping
build to the libc++ and libc++abi builds. Furthermore, it looks like the
per-target include directories used by the bootstrapping build by default
are incompatible with our current modulemap, since __config_site doesn't
live in the directory that our modulemap claims.

This disables modules in our bootstrapping CI job to unblock D121822,
but we should work on fixing the underlying issue once we're able to
pass those configuration options to our bootstrapping build.
2022-03-21 10:09:57 -04:00
Martin Storsjö b37b5e51a1 [libcxx] [ci] Check that Windows static libraries don't contain dllexports
Differential Revision: https://reviews.llvm.org/D121164
2022-03-21 11:22:34 +02:00
Mark de Wever 3b2e605e33 [libc++][test][NFC] Remove libcpp-no-concepts.
This is no longer needed.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D122099
2022-03-20 15:39:26 +01:00
Nikolas Klauser 85e9b2687a [libc++] Prepare string tests for constexpr
These are the last™ changes to the tests for constexpr preparation.

Reviewed By: Quuxplusone, #libc, Mordante

Spies: Mordante, EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D120951
2022-03-19 18:48:14 +01:00
Mark de Wever b927fba16f [libc++][test] Improves handle formatter.
Before it only accepted one output iterator type. Now it accepts all
output iterator types as required by BasicFormatter.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D120916
2022-03-19 13:04:19 +01:00
Nikolas Klauser 01df675191 [libc++] Enable modernize-loop-convert
Reviewed By: ldionne, Mordante, #libc

Spies: var-const, aheejin, libcxx-commits

Differential Revision: https://reviews.llvm.org/D121216
2022-03-18 20:34:19 +01:00
Asher Mancinelli 34538dba9b [libc++] Make shared_ptr move unique_ptr's deleter
Addresses LWG 3548 which mandates that when shared_ptr is being constructed from a unique_ptr, the unique_ptr's deleter should be moved and not copied.

Reviewed By: #libc, philnik, EricWF

Differential Revision: https://reviews.llvm.org/D119159
2022-03-18 11:50:31 -06:00
Nikolas Klauser f83d833e41 [libc++][ranges] Implement ranges::min
Reviewed By: var-const, Mordante, #libc

Spies: jwakely, ldionne, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D119589
2022-03-18 12:52:21 +01:00
Konstantin Varlamov 658957c79a [libc++][ranges] Implement changes to reverse_iterator from One Ranges Proposal.
Changes in [P0896](https://wg21.link/p0896):
- add `disable_sized_sentinel_for`;
- add `iter_move` and `iter_swap`;
- add a `requires` clause to the `operator->`;
- add `iterator_concept`;
- check that the `Iterator` template parameter is a bidirectional
  iterator;
- add constraints to all comparison operators;
- change the definitions of `iterator_category`, `value_type`,
  `difference_type` and `reference` (changes to `iterator_category` were
  already implemented).

Also add a few forgotten things to the `reverse_iterator` synopsis
(notably the spaceship operator).

Differential Revision: https://reviews.llvm.org/D120180
2022-03-17 19:58:03 -07:00
Nikolas Klauser 3e02c8e2fc [libc++] [test] Add ranges_robust_against_copying_*.pass.cpp
This tests the same QoI issue as the existing STL Classic test,
    but for the Ranges algorithms. Also, do the same thing for all
    the algorithms that take projections.

I found a few missing algorithms and added them to the existing test, too. `std::find_first_of` currently fails; I should look at why that is (and in particular, what is it doing weird that //makes// it inconsistent with the entire rest of libc++?).

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D121265
2022-03-17 22:36:18 +01:00
Louis Dionne ce3feebd33 [libc++] Install psutil on CI builders
This will make it possible to add a timeout when running the tests.
2022-03-17 17:33:13 -04:00
Louis Dionne 2c9995c117 [libc++] Add missing <cstddef> include 2022-03-17 17:07:37 -04:00
Louis Dionne d0af4276d6 [libc++] Switch to the new testing configurations by default
We've been meaning to remove support for the legacy testing configuration
for a long time. This patch switches the default from the legacy config
to the appropriate new-style configuration based on a few hints.

We've been running with the new-style configuration for more than a year
in our CI, however it's possible that this will uncover issues with some
users that run the tests on platforms that we don't support yet with the
new-style configs. Unfortunately, there is no way to know about it other
than to land this patch and see whether anything breaks.

Differential Revision: https://reviews.llvm.org/D121632
2022-03-17 14:26:56 -04:00
David Spickett 14452c4958 Revert "[libcxx][CI] Use temporary clang-13 bots for Arm/AArch64"
This reverts commit 406d418c0c.

Our regular bots are now using clang-13. The previous set will remain
online for a while to check reviews that haven't rebased to include
this change yet.

Differential Revision: https://reviews.llvm.org/D121894
2022-03-17 10:49:49 +00: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 14324fa428 [libc++] Add warning pragma macros in the test suite
Reviewed By: ldionne, #libc, EricWF

Spies: EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D121552
2022-03-17 00:11:20 +01:00
Louis Dionne 197737b539 [libc++][NFC] Reindent release notes bullet points 2022-03-16 17:26:32 -04:00
Louis Dionne 4001b82b15 [libc++][NFC] Rename member variables to avoid shadowing conflict in future patch 2022-03-16 15:45:38 -04:00
Mark de Wever e72cedcb01 [libc++][NFC] Add TEST_HAS_NO_INCOMPLETE_RANGES.
This avoids using an libc++ internal macro in our tests.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D121515
2022-03-16 17:42:48 +01:00
Louis Dionne 78669c4185 [libc++][tests] Use CMake provided paths for includes and libdir instead of hardcoding them
In the new-style testing configurations, we were hardcoding paths to the
`include` and `lib` directories, which was incorrect but always went
unnoticed because the hardcoded values always happened to match the
actual value.

When using new-style configs with the bootstrapping build, this falls
appart -- and we never noticed this because the bootstrapping build was
still using old style configs.

This patch removes the %{install} substitution, which makes it too
tempting to hardcode installation paths, and it also switches the
bootstrapping build to actually using new-style configs like we
always intended to do.

Differential Revision: https://reviews.llvm.org/D121700
2022-03-16 12:35:06 -04:00
Louis Dionne 0bc451e7e1 [libc++] Fix incorrect availability markup for bad_optional_access & friends
In 7fb40e1569, I changed the availability for bad_optional_access and
friends from macOS 10.14 to 10.13 after conducting an investigation on
old dylibs. It turns out that macOS 10.13 did have bad_optional_access,
however the dylib on iOS didn't match the dylib on macOS, so those
exception classes were only introduced in iOS 12.

Thanks to Aditya Kumar for noticing this.

Differential Revision: https://reviews.llvm.org/D121735
2022-03-16 09:03:22 -04:00
Louis Dionne 0389462587 [libc++] Do not install the C++ ABI library's headers as part of libc++'s build
It's the role of the C++ ABI library to install its own headers, not libc++.
This fixes an existing issue causing spurious CI failures where both libc++
and libc++abi would try to install <cxxabi.h> & friends in the same location,
leading to failures during the installation step.

Differential Revision: https://reviews.llvm.org/D121706
2022-03-16 08:53:47 -04:00
Louis Dionne e39095a32e [libc++] Define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER whenever we enable warnings in the test suite
This should make CI consistent on all the compilers we support. Most of
this patch is working around various warnings emitted by GCC in our code
base, which are now being shown when we compile the tests.

After this patch, the whole test suite should be warning free on all
compilers we support and test, except for a few warnings on GCC that
we silence explicitly until we figure out the proper fix for them.

Differential Revision: https://reviews.llvm.org/D120684
2022-03-15 17:17:54 -04:00
Louis Dionne d4c39f1ab9 [libc++] Add workaround to avoid breaking users of <span> when <ranges> are disabled
Back in 3a208c6894, we implemented the range-based constructor for <span>.
However, in doing so, we removed a previous non-standard constructor that
we provided before shipping <ranges>. Unfortunately, that breaks code that
was relying on a range-based constructor until we ship all of <ranges>.

This patch reintroduces the old non-conforming constructors and tests
that were removed in 3a208c6894 and uses them whenever <ranges> is
not provided (e.g. in LLVM 14). This is only a temporary workaround
until we enable <ranges> by default in C++20, which should hopefully
happen by LLVM 15.

The goal is to cherry-pick this workaround back to the LLVM 14 release
branch, since I suspect the constructor removal may otherwise cause
breakage out there, like the breakage I saw internally.

We could have avoided this situation by waiting for C++20 to be finalized
before shipping std::span. For example, we could have guarded it with
something like _LIBCPP_HAS_NO_INCOMPLETE_RANGES to prevent users from
accidentally starting to depend on it before it is stable. We did not
have these mechanisms when std::span was first implemented, though.

Differential Revision: https://reviews.llvm.org/D121626
2022-03-15 16:36:33 -04:00
Louis Dionne d4d8f03619 [libc++] Update URL to old libc++ dylibs 2022-03-15 16:18:51 -04:00
Dimitry Andric 7ab1ab0db4 [libc++] Make __dir_stream visibility declaration consistent
The class `__dir_stream` is currently declared in two places: as a
top-level forward declaration in `directory_iterator.h`, and as a friend
declaration in class `directory_entry`, in `directory_entry.h`.

The former has a `_LIBCPP_HIDDEN` attribute, but the latter does not,
causing the Firefox build to complain about the visibility not matching
the previous declaration. This is because Firefox plays games with
pushing and popping visibility.

Work around this by making both `__dir_stream` declarations consistently
use `_LIBCPP_HIDDEN`.

Reviewed By: ldionne, philnik, #libc

Differential Revision: https://reviews.llvm.org/D121639
2022-03-15 19:30:35 +01:00
Louis Dionne f6fd1c1438 [libc++] Overhaul all tests for assertions and debug mode
Prior to this patch, there was no distinction between tests that check
basic assertions and tests that check full-fledged iterator debugging
assertions. Both were disabled when support for the debug mode is not
provided in the dylib, which is stronger than it needs to be.

Furthermore, all of the tests using "debug_macros.h" that contain more
than one assertion in them were broken -- any code after the first
assertion would never be executed.

This patch refactors all of our assertion-related tests to:
1. Be enabled whenever they can, i.e. basic assertions tests are run
   even when the debug mode is disabled.
2. Use the superior `check_assertion.h` (previously `debug_mode_helper.h`)
   instead of `debug_macros.h`, which allows multiple assertions in the
   same program.
3. Coalesce some tests into the same file to make them more readable.
4. Use consistent naming for test files -- no more db{1,2,3,...,10} tests.

This is a large but mostly mechanical patch.

Differential Revision: https://reviews.llvm.org/D121462
2022-03-15 10:56:34 -04:00
Louis Dionne 849e749d7f [libc++][NFC] Remove several redundant #if _LIBCPP_STD_VER > 17 in <span>
It turns out that the whole header is only enabled in C++20 and above,
so these checks were redundant (and always true).

Differential Revision: https://reviews.llvm.org/D121604
2022-03-14 13:53:30 -04:00
Joe Loser d2baefae68
[libc++] Replace _LIBCPP_HAS_NO_CONCEPTS with _LIBCPP_STD_VER > 17. NFCI.
All supported compilers that support C++20 now support concepts. So, remove
`_LIB_LIBCPP_HAS_NO_CONCEPTS` in favor of `_LIBCPP_STD_VER > 17`. Similarly in
the tests, remove `// UNSUPPORTED: libcpp-no-concepts`.

Differential Revision: https://reviews.llvm.org/D121528
2022-03-13 12:32:06 -04:00
Mark de Wever 5ac257da35 [libc++] Remove unneeded tests.
As suggested in D120742.
2022-03-12 12:22:38 +01:00