10245 Commits

Author SHA1 Message Date
varconst
401e9e4291 [libc++][ranges][NFC] Templatize some of the types in almost_satisfies_types.h 2023-04-12 14:13:55 -07:00
Mark de Wever
943d225713 [NFC][libc++] Use _LIBCPP_HIDE_FROM_ABI.
This updates the new __system_error directory.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D148028
2023-04-12 17:34:58 +02:00
Nikolas Klauser
380b6a13da [libc++][NFC] rename __is_trivially_equality_comparable to __libcpp_is_trivially_equality_comparable
This is required for D147175.

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D147953
2023-04-12 14:31:16 +02:00
Nikolas Klauser
e2b15ec235 [libc++] Rename __tuple_dir back to __tuple
This essentially reverts D139270

Reviewed By: #libc, EricWF

Spies: tahonermann, libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D147519
2023-04-12 14:30:39 +02:00
Martin Storsjö
a6ba74e471 [libcxx] Move the private header __std_stream into the src subdir
This header isn't used by any public header, so there shouldn't
be any need to install it or treat it as a heder.

Once it's part of the src subdirectory, I guess one could consider
giving it a more traditional name too.

Differential Revision: https://reviews.llvm.org/D147855
2023-04-12 10:26:55 +03:00
Martin Storsjö
f24e6489c7 [libcxx] [test] Check for C++ headers before building a test that uses them
When the libcxx test framework is executed within libunwind, there
are no standard C++ headers available (libunwind builds with
-nostdinc++, but doesn't add any libcxx headers to the include path).

Check that a test that includes <iostream> can be compiled before trying
to build and execute a test program that includes it.

Previously, the compile error here would block all libunwind tests from
executing altogether.

Differential Revision: https://reviews.llvm.org/D147630
2023-04-12 10:16:50 +03:00
Mark de Wever
b237354070 [libc++][format] Mark range formaters as complete.
The __cpp_lib_format_ranges feature-test macro only depends on P2286R8
and P2585R0. Note since LWG3750 only affects these two C++23 papers
there is nothing to do for older language versions.

(The __cpp_lib_format feature-test macro depends on the incomplete
formatting for chrono. So this part can't be marked as complete yet.)

This completes
- P2286R8 Formatting ranges
- P2585R0 Improving default container formatting

This partly implements
- LWG3750 Too many papers bump __cpp_lib_format

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D147880
2023-04-11 18:47:11 +02:00
Louis Dionne
2e9058ced9 [libc++][NFC] Update precondition comments when testing subspan assertions 2023-04-11 17:45:12 +01:00
Mark de Wever
3acf9b9c2b [libc++][format] Improves tests.
This is based on the last open review comment in D144331 and is applied
to all occurrences.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D147885
2023-04-11 18:44:03 +02:00
Mark de Wever
a9ddb77245 [libc++][CI] Prepares building C++ modules.
D144994 adds modules to libc++. In order to test them some newer and
additional tools are required.

CMake 3.26
This is in combination with Clang 16 or newer makes it possible to
conveniently build modules with CMake. Unfortunately CMake 3.26 in our
setup has an issue with unused linker flags. This causes libunwind not
to compile at all. D145596 contains a quick-fix which is in the module
patch. The patch D142957 and followups will contain a proper fix.
Therefore install CMake 3.26 in a separate location, allowing to test
the module patch in the CI.

Ninja 1.11
Building modules requires dynamic rules, which requires this version.
This is a CMake 3.26 requirement to use modules. Note that without using
modules CMake still accepts older Ninja versions.

clang-scan-deps (in the tools package)
This tool is used by CMake to get the module dependencies. Note
strictly this currently will only be used for Clang 16 and Clang 17.
Clang 15 and Clang 14 are not needed. They are installed to keep
updating to Clang 18 and later easier.
(In the future we might not test modular build with all Clang versions,
however at the moment the feature is still in development in both Clang
and libc++ so it would be good to detect regressions.)

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D146822
2023-04-11 18:42:53 +02:00
Mark de Wever
51f0b809ca [libc++] Formats the sytem_error headers.
Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D147886
2023-04-11 18:40:29 +02:00
Nikolas Klauser
eb65912e41 [libc++] Move __errc to __system_error/errc.h
This file was added before we started granularizing the headers, but is essentially just a granularized header. This moves the header to the correct place.

Reviewed By: #libc, EricWF

Spies: libcxx-commits, arichardson, mikhail.ramalho

Differential Revision: https://reviews.llvm.org/D146395
2023-04-10 19:23:42 +02:00
Mark de Wever
e8cfbfd05a [libc++] Granularize system_error.
Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D147853
2023-04-09 17:57:14 +02:00
Mark de Wever
0bc0edb847 [libc++] Implements isblank.
This omission seems to be there for a long time, it's in the initial
libc++ import. This was discovered while working on the std modules.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D147850
2023-04-09 13:11:59 +02:00
Mark de Wever
d851651843 [libc++][format] Addresses LWG3720.
LWG3720 Restrict the valid types of arg-id for width and precision in
  std-format-spec

Depends on D144325

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D144326
2023-04-09 12:50:17 +02:00
Mark de Wever
ed8ea2bbf8 [libc++][format] range-default-formatter for strings.
Implements the range-default-formatter specialization range_format::string
and range_format::debug_string.

Implements parts of
- P2286R8 Formatting Ranges
- P2585R0 Improving default container formatting

Depends on D145847

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D145853
2023-04-09 12:48:15 +02:00
Hristo Hristov
d94a770f7b [libc++][spaceship] Implement operator<=> for time_point
Depends on D145881

Implements parts of **P1614R2**: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html
Implements `operator<=>` for `time_point`

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D146250
2023-04-09 08:47:20 +03:00
Nikolas Klauser
75196f8e72 [libc++] Remove <cstdlib> includes
We changed the `abort` calls when trying to throw exceptions in `-fno-exceptions` mode to `__verbose_abort` calls, which removes the dependency in most files.

Reviewed By: ldionne, #libc

Spies: dim, emaste, mikhail.ramalho, smeenai, libcxx-commits

Differential Revision: https://reviews.llvm.org/D146076
2023-04-09 02:52:33 +02:00
Nikolas Klauser
72e049c51d [libc++][NFC] Only run the preprocessor in transitive_includes.sh.cpp
This cuts the time it takes to run the test in half.

Reviewed By: Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D147320
2023-04-08 20:40:17 +02:00
Mark de Wever
88622aabf1 [libc++][format] Implements formatter thread::id.
Since stacktrace header is WIP and it's not sure that will be done
before LLVM17 update the documentation. When the header is implemented
implementing the formatter is trivial, so that can be done quickly
afterwards.

Implements parts of:
 - P2693R1 Formatting thread::id and stacktrace

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D144331
2023-04-08 16:39:34 +02:00
Mark de Wever
2c1d79596f [libc++][chrono] Add sys_time formatter.
Partially implements:
- P1361 Integration of chrono with text formatting
- P2372 Fixing locale handling in chrono formatters

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D144739
2023-04-08 15:22:50 +02:00
Mark de Wever
9b43aedeb3 [libc++][format] Implements LWG3892.
This LWG issue is based on the discussion regarding

  P2733R3 Fix handling of empty specifiers in std::format

This paper was disussed and changed a few times in LEWG during the
Issaquah meeting. The paper was not voted in, instead LEWG asked for
a DR against C++26.

This LWG issue contains the direction voted by LEWG. This issue has not
been voted in yet. However it fixes some of the defencies on the
container based formatting. Without this fix the range-default-formatter
for strings looks bad when used in containers.

The changes of this issue match the intended changes of P27333.

type                      fmt     before     after (if changed)
---------------------------------------------------------------
char                      {}      a
char                      {:?}    'a'
array<char, 1>            {}      ['a']
array<char, 1>            {::}    [a]
array<char, 1>            {::c}   [a]
array<char, 1>            {::?}   ['a']
map<char, char>           {}      {a: a}     -> {'a': 'a'}
map<char, char>           {::}    {'a': 'a'}
set<char>                 {}      {'a'}
set<char>                 {::}    {a}
set<char>                 {::c}   {a}
set<char>                 {::?}   {'a'}
tuple<char>               {}      ('a')
stack<char>               {}      ['a']
stack<char>               {::}    [a]
stack<char>               {::c}   [a]
stack<char>               {::?}   ['a']
array<array<char, 1>, 1>  {}      [[a]]      -> {'a': 'a'}
array<array<char, 1>, 1>  {::}    [['a']]
array<array<char, 1>, 1>  {:::}   [[a]]
array<array<char, 1>, 1>  {:::c}  [[a]]
array<array<char, 1>, 1>  {:::?}  [['a']]
array<tuple<char>, 1>     {}      [(a)]      -> [('a')]
tuple<tuple<char>>        {}      ((a))      -> (('a'))
tuple<array<char, 1>>     {}      ([a])      -> (['a'])

Note the optimization text as mentioned in the tuple formatter can't be
done. The call to parse may affect the formatter so its state needs to
be preserved.

Reviewed By: ldionne, #libc, EricWF

Differential Revision: https://reviews.llvm.org/D145847
2023-04-08 14:12:04 +02:00
Nikolas Klauser
c6afeda866 [libc++] Reject standard attributes which are extensions in libcpp-uglify-attributes
This adds a list of attributes which can be pretty to be able to reject attributes which were introduced in a later C++ standard.
Fixes #61196

Reviewed By: Mordante, #libc

Spies: mikhail.ramalho, jdoerfert, libcxx-commits

Differential Revision: https://reviews.llvm.org/D145508
2023-04-07 21:10:55 +02:00
Mark de Wever
9c0efc8a03 [libc++] Module fixes for __synth_three_way.
These changes make it possible to use __synth_three_way in modules. The
change from a lambda to a function is a Clang issue.

The change is list was needed since the compiler couldn't deduce the
comparison template argument.

Adds a few missing includes too.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D146545
2023-04-07 18:54:09 +02:00
Mark de Wever
cf07b882e2 [libc++][format][chrono] Addresses LWG3842.
LWG3842 Unclear wording for precision in chrono-format-spec

Note there is nothing to do, the issue clarifies the wording in the Standard.
The new wording matches my interpretation of the previous wording and this has
already been implemented in libc++.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D144328
2023-04-07 17:53:37 +02:00
Mark de Wever
57e20cab5a [libc++][format] Use granularized charconv.
This reduces the number of transitive includes when using format.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D146240
2023-04-07 17:49:21 +02:00
Mark de Wever
92fc93e112 [libc++] Qualifies intmax_t and uintmax_t.
This has been done using the following command

  find libcxx/test -type f -exec perl -pi -e 's|^([^/]+?)((?<!::)(?<!::u)u?intmax_t)|\1std::\2|' \{} \;

The std module doesn't export declarations in the global namespaace.
This is a preparation for that module.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D146821
2023-04-07 17:45:03 +02:00
Hristo Hristov
466d554dca [libc++][spaceship[NFC] P1614R2 operator<=> moves misplaced tests to correct location
P1614R2:

- Moved misplaced tests from `libcxx/test/libcxx` to `libcxx/test/std`
- Updated status page `SpaceshipProjects.csv`: `operator<=>` implementation status

Related docs:

- https://eel.is/c++draft/
- https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D146902
2023-04-01 10:25:30 +03:00
Nikolas Klauser
173476ea04 [libc++] Add __decay_t and use it instead of decay<>::type
This avoids instantiating lots of types.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D146984
2023-03-31 02:22:48 +02:00
Louis Dionne
bec96f6e95 [libc++] Systematically define a macro to check whether a feature is unavailable
Previously, we inconsistently defined whether a feature was unavailable
on a given deployment target. We would have availability attributes for
all features, but only some features had the equivalent of a _HAS_NO_FOO
macro in the form of the DISABLE_FTM___foo macros. Instead, systematically
define a _HAS_NO_FOO macro, which makes it easier to understand how to
add availability markup for a new platform.

Differential Revision: https://reviews.llvm.org/D147226
2023-03-30 15:17:55 -04:00
Louis Dionne
a8bab42c9a [libc++][NFC] Remove stray tests
Those tests are remnants of patches that were created before we renamed
the FTM tests but merged after we renamed them.
2023-03-30 13:09:17 -04:00
Louis Dionne
af4b2617e3 [libc++] Add minor test for polymorphic_allocator.construct with mixed argument pair
Re-applying the patch after fixing an issue.
2023-03-30 10:35:52 -04:00
Louis Dionne
ed61d6a466 [libc++] Use the stdlib=<LIB> Lit feature instead of use_system_cxx_lib
The use_system_cxx_lib Lit feature was only used for back-deployment
testing. However, one immense hole in that setup was that we didn't
have a proper way to test Apple's own libc++ outside of back-deployment,
which was embodied by the fact that we needed to define _LIBCPP_DISABLE_AVAILABILITY
when testing (see change in libcxx/utils/libcxx/test/params.py).

This led to the apple-system testing configuration not checking for
availability markup, which is obviously quite bad since the library
we ship actually has availability markup.

Using stdlib=<VENDOR>-libc++ instead to encode back-deployment restrictions
on tests is simpler and it makes it possible to naturally support tests
such as availability markup checking even in the tip-of-trunk Apple-libc++
configuration.

Differential Revision: https://reviews.llvm.org/D146366
2023-03-30 06:57:56 -04:00
Haowei Wu
89bcac0f8f Revert "[libc++] Add minor test for polymorphic_allocator.construct with mixed argument pair"
This reverts commit b66a6e4b104b245ed448e3dea944fa7e842a96b2 which
breaks runtime tests.
2023-03-29 17:07:31 -07:00
Louis Dionne
b66a6e4b10 [libc++] Add minor test for polymorphic_allocator.construct with mixed argument pair 2023-03-29 17:02:26 -04:00
Louis Dionne
0b57d47bfa [libc++][NFC] Move __insertion_sort_move to partial_sort.h
The __insertion_sort_move helper function is only used in partial_sort.h,
so it makes sense to define it there.

Differential Revision: https://reviews.llvm.org/D147080
2023-03-29 09:49:35 -04:00
Louis Dionne
177cb1030f [libc++][NFC] Rename helper function for testing spaceship
The helper is mis-named, since it won't work as-is on ordered containers
like set and map, because they rely on being able to store keys that are
partial_ordering::unordered, and that's UB for an ordered container.

This was most likely a typo or an unintended naming mistake, since
the function is only used with sequence containers anyway.

Differential Revision: https://reviews.llvm.org/D146991
2023-03-28 09:58:37 -04:00
Louis Dionne
c2a42381c1 [libc++] Don't try to provide source_location on AppleClang 1403
AppleClang 1403 has some bugs that prevent std::source_location from
working properly on it. Consequently, we XFAILed the unit test for
source_location with that compiler. However, we should also avoid
advertising that the feature is supported on that compiler, otherwise
our feature-test macros lie. This was noticed to break Boost.Asio
when building with a recent libc++ and AppleClang 14.0.3.

rdar://106863087

Differential Revision: https://reviews.llvm.org/D146837
2023-03-28 09:53:07 -04:00
Louis Dionne
1fa6fc3e0f [libc++] Also support target triples that end with .0 in backdeployment tests
Sometimes, a target can look like `<arch>-apple-macosx10.15.0` instead
of `<arch>-apple-macosx10.15`. This ensures that the test suite handles
those target triples properly as well.

Differential Revision: https://reviews.llvm.org/D146365
2023-03-28 09:09:54 -04:00
Louis Dionne
f0fc8c4878 [libc++] Use named Lit features to flag back-deployment XFAILs
Instead of writing something like `XFAIL: use_system_cxx_lib && target=...`
to XFAIL back-deployment tests, introduce named Lit features like
`availability-shared_mutex-missing` to represent those. This makes the
XFAIL annotations leaner, and solves the problem of XFAIL comments
potentially getting out of sync. This would also make it easier for
another vendor to add their own annotations to the test suite by simply
changing how the feature is defined for their OS releases, instead
of having to modify hundreds of tests to add repetitive annotations.

This doesn't touch *all* annotations -- only annotations that were widely
duplicated are given named features (e.g. when filesystem or shared_mutex
were introduced). I still think it probably doesn't make sense to have a
named feature for every single fix we make to the dylib.

This is in essence a revert of 2659663, but since then the test suite
has changed significantly. Back when I did 2659663, the configuration
files we have for the test suite right now were being bootstrapped and
it wasn't clear how to provide these features for back-deployment in
that context. Since then, we have a streamlined way of defining these
features in `features.py` and that doesn't impact the ability for a
configuration file to stay minimal.

The original motivation for this change was that I am about to propose
a change that would touch essentially all XFAIL annotations for back-deployment
in the test suite, and this greatly reduces the number of lines changed
by that upcoming change, in addition to making the test suite generally
better.

Differential Revision: https://reviews.llvm.org/D146359
2023-03-27 12:44:26 -04:00
Louis Dionne
3b00bae9a9 [libc++] Add UNSUPPORTED annotations to more <format> tests on GCC 12
Those seem to have been failing for a while but we might not have noticed
because of the recent CI instability issues. I'm marking them as unsupported
to try to get the CI functional again, especially since the majority of
<format> tests are already not working on GCC 12.
2023-03-25 14:38:22 -04:00
Louis Dionne
2eab58527e [libc++][NFC] Improve documentation for running BuildKite agent locally 2023-03-25 13:55:08 -04:00
Mike Hommey
101cfe18f7 [libcxx] Fix build bustage with threads disabled
Building with -DLIBCXX_ENABLE_THREADS=OFF -DLIBCXXABI_ENABLE_THREADS=OFF
(like e.g. for wasm) fails after D146228 because of a misplaced std
namespace begin/end.

Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D146682
2023-03-23 17:30:34 +00:00
Hristo Hristov
40aaa272f1 [libc++][ranges] P2711R1 Making multi-param constructors of views explicit
Implemented [[ https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2711r1.html | P2711R1 ]] for existing views.
 (`join_with_view` is not yet implemented)

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D144822
2023-03-23 19:30:21 +02:00
Nikolas Klauser
71a5958406 [libc++] Remove __mutex_base header
This header should have been removed in
https://reviews.llvm.org/D146228, but there was a merge conflict.
2023-03-22 22:22:31 +01:00
Mark de Wever
d59a43fe2a [libc++] Qualifies intptr_t and uintptr_t.
This has been done using the following command

  find libcxx/test -type f -exec perl -pi -e 's|^([^/]+?)((?<!::)(?<!::u)u?intptr_t)|\1std::\2|' \{} \;

The std module doesn't export declarations in the global namespaace.
This is a preparation for that module.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D146643
2023-03-22 22:19:02 +01:00
Louis Dionne
3d334df587 [libc++] Remove availability markup for std::format
std::format is currently experimental, so there is technically no
deployment target requirement for it (since the only symbols required
for it are in `libc++experimental.a`).

However, some parts of std::format depend indirectly on the floating
point std::to_chars implementation, which does have deployment target
requirements.

This patch removes all the availability format for std::format and
updates the XFAILs in the tests to properly explain why they fail
on old deployment targets, when they do. It also changes a couple
of tests to avoid depending on floating-point std::to_chars when
it isn't fundamental to the test.

Finally, some tests are marked as XFAIL but I added a comment saying

   TODO FMT This test should not require std::to_chars(floating-point)

These tests do not fundamentally depend on floating-point std::to_chars,
however they end up failing because calling std::format even without a
floating-point argument to format will end up requiring floating-point
std::to_chars. I believe this is an implementation artifact that could
be avoided in all cases where we know the format string at compile-time.
In the tests, I added the TODO comment only to the places where we could
do better and actually avoid relying on floating-point std::to_chars
because we know the format string at compile-time.

Differential Revision: https://reviews.llvm.org/D134598
2023-03-22 16:32:26 -04:00
Nikolas Klauser
e655d8a548 [libc++] Granularize __mutex_base
This also updates the moved code to the current style. (i.e. `_VSTD` -> `std`, `_LIBCPP_INLINE_VISIBILITY` -> `_LIBCPP_HIDE_FROM_ABI`, clang-format).

Reviewed By: Mordante, #libc, EricWF

Spies: arichardson, libcxx-commits, mikhail.ramalho

Differential Revision: https://reviews.llvm.org/D146228
2023-03-22 20:17:26 +01:00
Mark de Wever
d868135691 [libc++] Qualifies ptrdiff_t and max_align_t.
This has been done using the following commands
  find libcxx/test -type f -exec perl -pi -e 's|^([^/]+?)((?<!::)ptrdiff_t)|\1std::\2|' \{} \;
  find libcxx/test -type f -exec perl -pi -e 's|^([^/]+?)((?<!::)max_align_t)|\1std::\2|' \{} \;

The std module doesn't export declarations in the global namespaace.,
This is a preparation for that module.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D146550
2023-03-22 17:27:57 +01:00
Hristo Hristov
83542e4764 [libc++][spaceship] Implement operator<=> for duration
Implements parts of [[ https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html | P1614R2 ]]
Implemented `operator<=>` for `std::chrono::duration`

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D145881
2023-03-21 20:06:42 +02:00