Commit Graph

9028 Commits

Author SHA1 Message Date
Martin Storsjö 586182ae4e [libcxx] [test] Remove UNSUPPORTED markings for mingw issues that no longer are present in CI
Differential Revision: https://reviews.llvm.org/D123146
2022-04-06 10:03:10 +03:00
Louis Dionne 6720bc202a [libc++] Remove error about _LIBCPP_ALTERNATE_STRING_LAYOUT not being supported anymore
It's been over two years since I added the temporary error, so I think
it's reasonable to remove it now.
2022-04-05 19:45:21 -04:00
Louis Dionne fd92ca00b4 [libc++][NFC] Remove stray whitespace in comment 2022-04-05 19:45:20 -04:00
Martin Storsjö 6efda5e6d6 [libcxx] [test] Fix the locale ctype widen tests on Windows
On Windows, like on macOS and FreeBSD, widening char(-5) in the
"C" locale succeeds and produces L'\u00fb'.

Switch widen_many to test \xfb instead of \x85; the mingw
version of btowc widens \x85 in the "C" locale into
\u2026 (which is the corresponding character according to the
Windows-1252 codepage), while Microsoft CRT's btowc widens it
into \u0085 (just like macOS and FreeBSD). Switch this to test \xfb
which is the character tested by the widen_1 test (as `char(-5)`),
which gets handled the same by all Windows implementations of btowc.

Differential Revision: https://reviews.llvm.org/D121003
2022-04-05 20:06:44 +03:00
Hui Xie c00df57b86 [libc++] add global variable template std::views::empty
[libc++] add global variable template std::views::empty
Note it is neither a range adaptor, nor a CPO. It is simplify a global variable template.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D122996
2022-04-05 18:18:16 +02:00
Mark de Wever 83de107382 [libc++][test] Adds an cpp20_output_iterator.
This iterator is used to test code that only needs to satisfy the
output_iterator concept. Follow-up changes will use this iterator in
older language Standards.

Reviewed By: ldionne, #libc, philnik, var-const

Differential Revision: https://reviews.llvm.org/D122072
2022-04-05 17:31:42 +02:00
Louis Dionne 8ec4999766 [libc++] Tidy up tests for deduction guides and other compile-time failing properties in std::string
Instead of using `.fail.cpp` tests, use `.verify.cpp` to check for the
exact reason of the failure. In the case of deduction guides, use SFINAE
based tests instead since that is our preferred way of testing those.

Finally, ensure that we actually run the test in `iter_alloc_deduction.pass.cpp`,
since we were not running anything before.

Differential Revision: https://reviews.llvm.org/D123055
2022-04-05 10:52:52 -04:00
Louis Dionne 45ce3f3252 [libc++] Silence new deprecation warnings for C functions in tests 2022-04-05 10:26:32 -04:00
Nikolas Klauser 3ba8548c8e [libc++][ranges] Implement ranges::transform
Reviewed By: ldionne, var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D122173
2022-04-05 11:06:28 +02:00
Louis Dionne 9a44ed43cf [libc++] Implement tests for private headers using the new generator
Differential Revision: https://reviews.llvm.org/D123028
2022-04-04 17:44:47 -04:00
Martin Storsjö dba90d74be [libcxx] Stop recommending setting LIBCXX_HAS_WIN32_THREAD_API in the MinGW builds
Since a8d15a9266 / D110975, this is
the default, even if winpthread headers are available, so we don't
need to cargo cult setting this option in all builds.

Differential Revision: https://reviews.llvm.org/D122717
2022-04-04 23:07:40 +03:00
Louis Dionne 13796495ec [libc++] Fix std::is_array<T[0]> and add tests
Differential Revision: https://reviews.llvm.org/D122810
2022-04-04 13:55:18 -04:00
Louis Dionne a4f73b9b14 [libc++][NFC] Rename generate_assertion_tests.py to generate_header_tests.py 2022-04-04 09:10:52 -04:00
Louis Dionne be1294de9d [libc++] Implement all public header tests using the new generator
Note that `generate_assertion_tests.py` will be renamed to
`generate_header_tests.py` separately to facilitate change tracking.

Differential Revision: https://reviews.llvm.org/D123000
2022-04-04 09:09:37 -04:00
Louis Dionne e70533ae6c [libc++] Remove unused <iosfwd> include from <__debug>
Differential Revision: https://reviews.llvm.org/D122999
2022-04-03 16:15:48 -04:00
Louis Dionne 896770c9a9 [libc++][NFC] Fix weird indentation in test 2022-04-03 12:47:28 -04:00
Nikolas Klauser e476df5629 [libc++][ranges] Implement ranges::max
Reviewed By: Mordante, var-const, #libc

Spies: sstefan1, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D122002
2022-04-03 17:04:56 +02:00
Nikolas Klauser e06ca31239 [libc++] Canonicalize the ranges results and their tests
Reviewed By: var-const, Mordante, #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D121435
2022-04-02 08:26:31 +02:00
Martin Storsjö b048397db8 [libcxx] [test] Avoid spurious test breakage in clang-cl-dll configs with newer CMake
The pointer.volatile.pass.cpp test was already marked as XFAIL for
mingw-dll (for reasons explained in the comment above it).

The same issue also appears in clang-cl-dll when built with newer
CMake versions. (It didn't appear with older versions of CMake, as
CMake built the library with the clang-cl flag `-std:c++latest` when
we've requested C++ 20 - which practically built it in c++2b mode with
current clang versions. With current versions of CMake, it passes
`-std:c++20` instead.)

As it succeeds/fails dependent on factors we don't
directly control, mark it as UNSUPPORTED instead of XFAIL.

Differential Revision: https://reviews.llvm.org/D122718
2022-04-01 10:14:17 +03:00
Martin Storsjö 64d7f778e6 [libcxx] [ci] Enable -Werror for libcxxabi and libunwind too
Differential Revision: https://reviews.llvm.org/D122800
2022-04-01 10:12:52 +03:00
Mark de Wever 9c54a0c97a [libc++] Fixes calendar function visibility.
Note of the functions was marked as _LIBCPP_HIDE_FROM_ABI.

Did some minor formatting fixes to keep consistency. To keep it easy to
review not all odd formatting has been fixed.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122834
2022-03-31 20:48:24 +02:00
Mark de Wever 11c14bca58 [libc++][ci] Installs Japanese locale in Docker.
The alternative outputs of std::put_time and std::strftime are the
easiest to test with the Japanese locale. This is a preparation for the
tests of the chrono formatters.

Note since it takes a while before the Docker file changes propagate to
the build nodes the verification of the locale is done in a separate
patch.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122736
2022-03-31 17:41:06 +02:00
Mark de Wever e3ad15d7ff [libc++][doc] Update formatting status.
Reduced the details of the non-chrono formatting information. This has
been shipped and these details part of P0645 which is still documented.
Removing this information keeps the information up-to-date.

Adds the formatters required for the types chrono namespace.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122735
2022-03-31 17:37:51 +02:00
Louis Dionne 0a460416e6 [libc++] Install psutil on the macOS nodes 2022-03-31 10:52:58 -04:00
Louis Dionne 19246b0779 [libc++] Remove the __libcpp_version file
It seems to have been added back in 761e42fa3d for Clang to use it,
however it seems to have never been used for that purpose, so it is
probably fine to remove it.

Differential Revision: https://reviews.llvm.org/D122330
2022-03-31 09:34:41 -04:00
Louis Dionne cb055e51f9 [libc++] Add a CI job running MSAN
For some reason, we've been going without a MSAN CI job, even though
even run-buildbot defined a generic-msan job. This must have been an
oversight that went unnoticed. Thanks to @EricWF for the catch.

Differential Revision: https://reviews.llvm.org/D120851
2022-03-31 09:31:22 -04:00
Martin Storsjö 5fbce8b7ac [libcxx] [doc] Update Windows build instructions after deprecating the legacy standalone builds
Differential Revision: https://reviews.llvm.org/D122715
2022-03-31 00:10:28 +03:00
Louis Dionne 385cc25a53 [libc++] Ensure that all public C++ headers include <__assert>
This patch changes the requirement for getting the declaration of the
assertion handler from including <__assert> to including any public
C++ header of the library. Note that C compatibility headers are
excluded because we don't implement all the C headers ourselves --
some of them are taken straight from the C library, like assert.h.

It also adds a generated test to check it. Furthermore, this new
generated test is designed in a way that will make it possible to
replace almost all the existing test-generation scripts with this
system in upcoming patches.

Differential Revision: https://reviews.llvm.org/D122506
2022-03-30 15:05:31 -04:00
Louis Dionne f29002a4b7 [libunwind] Add a _LIBUNWIND_VERSION macro
This allows us to detect whether we're being compiled with LLVM's libunwind
more easily, without CMake having to set explicit variables.

As discussed in https://llvm.org/D119538.

Differential Revision: https://reviews.llvm.org/D121015
2022-03-30 11:23:36 -04:00
Louis Dionne f0799465b2 [libc++] Use __builtin_expect and __builtin_assume in _LIBCPP_ASSERT
Since we expect the condition to be true most of the time, we might
as well tell the compiler. And when assertions are disabled, we
might as well tell the compiler that it's allowed to assume that
the condition holds.

Differential Revision: https://reviews.llvm.org/D122397
2022-03-29 11:46:47 -04:00
Louis Dionne 95a2527261 [libc++][NFC] Fix typo in comment 2022-03-29 11:45:56 -04:00
Louis Dionne 65b1b3b961 [libc++][libc++abi] Serialize the enable_assertions Lit parameter in the generated config
This means that re-running with llvm-lit in that configuration will
work as expected. This also enables assertions in libc++abi in the
Generic-assertions CI job, which was disabled previously.

Differential Revision: https://reviews.llvm.org/D122597
2022-03-29 08:17:25 -04:00
Brad Smith 6e2c6c9def [libcxx] random_device, specify optimal entropy properties for all OS's using arc4random()
Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D122522
2022-03-28 22:43:11 -04:00
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
Mark de Wever ec1a7647ee [libc++][NFC] Use TEST_HAS_NO_EXCEPTIONS.
The test should use the already available test macro.
2022-03-12 12:22:25 +01:00
Mark de Wever 5f016f5b7a [libc++] Add a missing test case. 2022-03-12 12:22:15 +01:00
Nikolas Klauser ee0f8c4010 [libc++][ranges] Implement ranges::find{, _if, _if_not}
Reviewed By: var-const, #libc, ldionne

Spies: ldionne, tcanens, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D121248
2022-03-12 01:46:02 +01:00
Louis Dionne a805a15b28 [libc++] Remove workaround for missing declarations on Windows store apps
We don't need preprocessor logic to exclude those declarations when compiling for
the Windows App Store, because that is handled by using_if_exists now.

Differential Revision: https://reviews.llvm.org/D108632
2022-03-11 09:08:30 -05:00
Louis Dionne 21f73d5826 [libc++] Remove workaround for C11 features on compilers that don't support using_if_exists
Instead of carrying around #ifdefs to determine whether those functions
are available on the platform, unconditionally use the using_if_exists
attribute to import it into namespace std only when available. That was
the purpose of this attribute from the start.

This change means that trying to use libc++ with an old SDK (or on an
old platform for platforms that ship system headers in /usr/include)
will require a recent Clang that supports the using_if_exists attribute.
When using an older Clang or GCC, the underlying platform has to support
a C11 standard library.

Differential Revision: https://reviews.llvm.org/D108203
2022-03-11 09:06:43 -05:00
Louis Dionne 611469c5c5 [libc++] Remove raw call to debug handler from __char_traits_length_checked
As a fly-by fix, also move it closer to where it is needed, and add a
comment explaining the existence of this weird function.

Differential Revision: https://reviews.llvm.org/D121231
2022-03-11 09:05:29 -05:00
Louis Dionne 071762199f [libc++] Add tests for the content of <cstddef>
As discussed in D114786.

Differential Revision: https://reviews.llvm.org/D121110
2022-03-10 15:54:15 -05:00
Louis Dionne 553ab7a090 [libc++] Remove operator-> from iterator archetypes that don't need it
operator-> is not a requirement for most iterators, so remove it. To
account for this change, the `common_iterator.operator->` test needs to
be refactored quite a bit -- improve test coverage while we're at it.

Differential Revision: https://reviews.llvm.org/D118400
2022-03-10 15:52:34 -05:00
Louis Dionne 28e82982fe [libc++] Bump minimum compiler requirements
Now that we've branched for the LLVM 14 release, our support window
moves to clang-13 and clang-14. Similarly, AppleClang 13 has been
released for some time now, so that should be the oldest compiler
we support, per our policy.

A possible follow-up would be to remove _LIBCPP_HAS_NO_CONCEPTS, since
I don't think we support any compiler that doesn't support concepts
anymore.

Differential Revision: https://reviews.llvm.org/D118831
2022-03-10 08:59:19 -05:00
Louis Dionne 6b9e0af8db [libc++] Add test coverage for std::shared_ptr<const T>
Those tests were extracted from D120996.

Differential Revision: https://reviews.llvm.org/D121340
2022-03-10 08:49:31 -05:00
Louis Dionne a54d028895 Revert "[libc++] Remove extension to support allocator<const T>"
This reverts commit 276ca873. That commit has quite a history at this
point. It was first landed in dbc647643577, which broke std::shared_ptr<T const>
and was reverted in 9138666f5. It was then re-applied in 276ca873, with
the std::shared_ptr issue fixed, but it caused widespread breakage at
Google (which suggests it would cause similar breakage in the wild too),
so now I'm reverting again.

Instead, I will add a escape hatch that vendors can turn on to enable
the extension and perform a phased transition over one or two releases
like we sometimes do when things become non-trivial.
2022-03-09 17:04:18 -05:00
Louis Dionne 54c4c01553 [libc++] Enable format_to and vformat_to tests even outside of Debug mode
These tests don't seem specific to the debug mode, so it makes sense to
run them even when the debug mode is disabled. When we run with the debug
mode enabled, we'll get the out-of-bounds checking that this test seems
to be concerned with.

Differential Revision: https://reviews.llvm.org/D121241
2022-03-09 12:38:30 -05:00
Mark de Wever 3925f98de4 [libc++][NFC] Cleanups in <charconv>.
Based on review comments in D97705 applied some code cleanups in
<charconv>. The header now uses a more recent libc++ style.

Reviewed By: Quuxplusone, #libc, philnik

Differential Revision: https://reviews.llvm.org/D121223
2022-03-09 17:52:02 +01:00
Louis Dionne 0f622bd281 [libc++] Don't manually override NDEBUG in the dylib build
LIBCXX_ENABLE_ASSERTIONS does not have any relationship to the `assert`
macro -- it only controls assertions that are internal to the library.
Playing around with `NDEBUG` only muddies the picture further than it
already is.

Also, remove a failing assertion in the benchmarks. That assertion had
never been exercised because we defined `NDEBUG` manually, and it was
failing since we introduced the ability to generate a benchmark vector
with the Quicksort adversary ordering (which is obviously not sorted).

This was split off of https://llvm.org/D121123.

Differential Revision: https://reviews.llvm.org/D121244
2022-03-09 10:05:38 -05:00
David Spickett 406d418c0c [libcxx][CI] Use temporary clang-13 bots for Arm/AArch64
This is a stop gap until I am able to update the usual bots
to clang-13.

Differential Revision: https://reviews.llvm.org/D121224
2022-03-09 09:16:41 +00:00
Martin Storsjö 9286a8238b [libcxx] [test] XFAIL the get/put long_double_ru_RU tests on Glibc < 2.27
Those older versions used a different monetary decimal separator.
To avoid unnecessary churn to support that, just XFAIL the test
on those older versions. (Up until
df1e43c496, the whole test was XFAILed
on all versions of glibc.)

Differential Revision: https://reviews.llvm.org/D120979
2022-03-09 10:17:20 +02:00
Martin Storsjö abe46776f3 [libcxx] [test] Fix the classic_table test on Windows
On Windows, constants like F::alpha and F::print are bitmasks
consisting of multiple bits (e.g. F::alpha consisting of both the
bits F::upper and F::lower). In such a case, we can't check that
all the bits from all the expected constants are set. Instead,
check that (p[i] & mask) != 0 returns the expected value.

Differential Revision: https://reviews.llvm.org/D120802
2022-03-09 10:12:55 +02:00