Commit Graph

9639 Commits

Author SHA1 Message Date
Louis Dionne 6b03a4fea0 Revert "[llvm] Remove libcxx, libcxxabi and libunwind from supported LLVM_ENABLE_PROJECTS"
This reverts commit 887b8bd733 while we
work on resolving issues brought up in https://reviews.llvm.org/D132480.
2022-09-21 08:38:00 -04:00
Mark de Wever 8b3a907fb8 [libc++] Use Clang-16 for c++17.
Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D132788
2022-09-21 07:48:06 +02:00
Mark de Wever 088c7f7e3c [libc++] Applies P0602R4 retro-actively.
While testing a test failure of C++17 with Clang ToT it was noticed the
paper
  P0602R4 variant and optional should propagate copy/move triviality
was not applied as a DR in libc++.

This was discovered while investigating the issue "caused by" D131479.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D133326
2022-09-20 19:01:34 +02:00
Mark de Wever 7c932cdb10 [NFC][libc++][format] Uses ranges algorithm.
Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D134060
2022-09-20 18:59:50 +02:00
Mark de Wever d23f609d9c [libc++][test] Adds format string helper.
Update the formatter day tests to the new style.
Other test will be done separately.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D134031
2022-09-20 18:58:37 +02:00
Mark de Wever f2a263512c [libc++][chrono] Removes format include.
Switch to the new granular format_functions header. Since the chrono's
format dependency in C++20 hasn't been in a release it's save to remove
it.

Depends on D133665

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D133796
2022-09-20 18:58:13 +02:00
Mark de Wever 00798e5006 [libc++][format] Granularizes the format header.
Moves the last pieces of code to its own header.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D133665
2022-09-20 18:57:10 +02:00
Louis Dionne 887b8bd733 [llvm] Remove libcxx, libcxxabi and libunwind from supported LLVM_ENABLE_PROJECTS
This is a breaking change. If you were passing one of those three runtimes
in LLVM_ENABLE_PROJECTS, you need to start passing them in LLVM_ENABLE_RUNTIMES
instead. The runtimes in LLVM_ENABLE_RUNTIMES will start being built using
the "bootstrapping build" instead, which means that they will be built
using the just-built Clang. This is usually what you wanted anyway.

If you were using LLVM_ENABLE_PROJECTS=all with the explicit goal of
building these three runtimes, you can now use LLVM_ENABLE_RUNTIMES=all
and these runtimes will be built using the bootstrapping build.

Differential Revision: https://reviews.llvm.org/D132480
2022-09-20 11:12:51 -04:00
Nikolas Klauser 55158efe10 [libc++] Remove MSVC code
It's been one and a half months now and nobody said anything, so I guess this code can be removed.

Reviewed By: ldionne, #libc

Spies: Mordante, libcxx-commits, mgorny, mstorsjo

Differential Revision: https://reviews.llvm.org/D132943
2022-09-20 10:11:42 +02:00
Nikolas Klauser 54150e8257 [libc++][NFC] Refactor enable_ifs in vector
Using the `enable_if_t<..., int> = 0` style has the benefit that it works in all cases and makes function declarations easier to read because the function arguments and return type and SFINAE are separated. Unifying the style also makes it easier for people not super familiar with SFINAE to make sense of the code.

Reviewed By: Mordante, var-const, #libc, huixie90

Spies: huixie90, libcxx-commits

Differential Revision: https://reviews.llvm.org/D131868
2022-09-20 10:06:34 +02:00
Louis Dionne ad0dfb4f5e [libc++] Document the format of _LIBCPP_VERSION
Differential Revision: https://reviews.llvm.org/D134187
2022-09-19 15:31:02 -04:00
Louis Dionne f1a601fe88 [libc++] Always query the compiler to find whether a type is always lockfree
In https://llvm.org/D56913, we added an emulation for the __atomic_always_lock_free
compiler builtin when compiling in Freestanding mode. However, the emulation
did (and could not) give exactly the same answer as the compiler builtin,
which led to a potential ABI break for e.g. enum classes.

After speaking to the original author of D56913, we agree that the correct
behavior is to instead always use the compiler builtin, since that provides
a more accurate answer, and __atomic_always_lock_free is a purely front-end
builtin which doesn't require any runtime support. Furthermore, it is
available regardless of the Standard mode (see https://godbolt.org/z/cazf3ssYY).

However, this patch does constitute an ABI break. As shown by https://godbolt.org/z/1eoex6zdK:
- In LLVM <= 11.0.1, an atomic<enum class with 1 byte> would not contain a lock byte.
- In LLVM >= 12.0.0, an atomic<enum class with 1 byte> would contain a lock byte.

This patch breaks the ABI again to bring it back to 1 byte, which seems
like the correct thing to do.

Fixes #57440

Differential Revision: https://reviews.llvm.org/D133377
2022-09-19 11:10:02 -04:00
Nikolas Klauser 7afa1598a3 [libc++] Avoid including <tuple> in compressed_pair.h
compressed_pair is widely used in the library, but most of the uses don't use the tuple parts. To avoid including <tuple> everywhere, use the forward declaration instead in compressed_pair.h

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D133331
2022-09-18 10:49:35 +02:00
Nikolas Klauser 87abc5013a [libc++][NFC] Inline the string constructors
This removes a lot of boilerplate code.

Reviewed By: ldionne, #libc

Spies: EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D128081
2022-09-17 18:00:11 +02:00
Nikolas Klauser d3a0ac92e9 [libc++] Add test to ensure that type trait aliases in dependent return types can be mangled
Reviewed By: ldionne, #libc

Spies: libcxx-commits, jeroen.dobbelaere

Differential Revision: https://reviews.llvm.org/D133196
2022-09-17 14:25:09 +02:00
Xing Xue 8ace9ea258 [libc++][lit][AIX] Enable test case last_write_time.pass.cpp for AIX
Summary:
This patch enables libc++ LIT test case last_write_time.pass.cpp for AIX. Because system call utimensat() of AIX which is used in the libc++ implementation of last_write_time() does not accept the times parameter with a negative tv_sec or tv_nsec field, testing of setting file time to before epoch time is excluded for AIX.

Reviewed by: ldionne, libc++

Differential Revision: https://reviews.llvm.org/D133124
2022-09-16 16:08:40 -04:00
Muiez Ahmed 1b445cada5 [SystemZ][z/OS] define REMOVE_ALL_USE_DIRECTORY_ITERATOR (libc++)
This patch fixes the z/OS build by using the first implementation of __remove_all since we don't have access to the openat() family of POSIX functions.

Differential Revision: https://reviews.llvm.org/D132948
2022-09-16 10:22:21 -04:00
Mark de Wever c632ee1c5d [libc++] Shows the detailed compiler version info.
The libc++ pre-commit CI uses Clang nightly builds. Currently it's not
possible to determine the exact version used since CMake doesn't show
this information by default. Instead use the --version flag to get this
information.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D133122
2022-09-16 16:15:36 +02:00
Mark de Wever c0ac3c1142 [NFC][libc++][test] Uses public functions.
Replaces std::__format_context_create with the public wrapper
test_format_context_create.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D133781
2022-09-16 14:57:21 +02:00
Matheus Izvekov 55e6078d21
NFC: remove accidental inclusion of libcxx test changes
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
2022-09-16 11:39:49 +02:00
Matheus Izvekov 989f76ce90
[clang] template / auto deduction deduces common sugar
After upgrading the type deduction machinery to retain type sugar in
D110216, we were left with a situation where there is no general
well behaved mechanism in Clang to unify the type sugar of multiple
deductions of the same type parameter.

So we ended up making an arbitrary choice: keep the sugar of the first
deduction, ignore subsequent ones.

In general, we already had this problem, but in a smaller scale.
The result of the conditional operator and many other binary ops
could benefit from such a mechanism.

This patch implements such a type sugar unification mechanism.

The basics:

This patch introduces a `getCommonSugaredType(QualType X, QualType Y)`
method to ASTContext which implements this functionality, and uses it
for unifying the results of type deduction and return type deduction.
This will return the most derived type sugar which occurs in both X and
Y.

Example:

Suppose we have these types:
```
using Animal = int;
using Cat = Animal;
using Dog = Animal;

using Tom = Cat;
using Spike = Dog;
using Tyke = Dog;
```
For `X = Tom, Y = Spike`, this will result in `Animal`.
For `X = Spike, Y = Tyke`, this will result in `Dog`.

How it works:

We take two types, X and Y, which we wish to unify as input.
These types must have the same (qualified or unqualified) canonical
type.

We dive down fast through top-level type sugar nodes, to the
underlying canonical node. If these canonical nodes differ, we
build a common one out of the two, unifying any sugar they had.
Note that this might involve a recursive call to unify any children
of those. We then return that canonical node, handling any qualifiers.

If they don't differ, we walk up the list of sugar type nodes we dived
through, finding the last identical pair, and returning that as the
result, again handling qualifiers.

Note that this patch will not unify sugar nodes if they are not
identical already. We will simply strip off top-level sugar nodes that
differ between X and Y. This sugar node unification will instead be
implemented in a subsequent patch.

This patch also implements a few users of this mechanism:
* Template argument deduction.
* Auto deduction, for functions returning auto / decltype(auto), with
  special handling for initializer_list as well.

Further users will be implemented in a subsequent patch.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D111283
2022-09-16 11:20:10 +02:00
Nikita Popov 57c7bb3ec8 [libcxx] Use interface library for libcxx-abi-shared
The libc++.so linker script generation uses the IMPORTED_LIBNAME
target property on libcxx-abi-shared. However, libcxx-abi-shared
is not an interface library and as such cannot have an
IMPORTED_LIBNAME target property.

Convert libcxx-abi-shared into an imported interface library
and use IMPORTED_LIBNAME in place of IMPORTED_LOCATION. This makes
linker script generation work correctly with system-libcxxabi.

I believe this fixes the issue that D131037 was intended to fix.

Differential Revision: https://reviews.llvm.org/D133566
2022-09-16 10:13:39 +02:00
Colin Cross 13c6828bed Fix std::fpos pretty printer on musl
The mbstate_t field in std::fpos is an opaque type provied by libc,
and musl's implementation does not match the one used by glibc.
Change StdFposPrinter to verify its assumptions about the layout
of mbstate_t, and leave out the state printing if it doesn't match.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D132983
2022-09-15 21:58:24 +00:00
Joe Loser f97cc6b712 [libc++] Clean up `_LIBCPP_HAS_NO_PLATFORM_WAIT` macro
As the comment suggests, `_LIBCPP_HAS_NO_PLATFORM_WAIT` is not documented or
defined anywhere internally in the build system. It's a direct define in terms
of `_LIBCPP_HAS_NO_THREADS`. So, remove `_LIBCPP_HAS_NO_PLATFORM_WAIT` and use
`_LIBCPP_HAS_NO_THREADS` instead to control the desired behavior.

Differential Revision: https://reviews.llvm.org/D132715
2022-09-15 09:45:21 -06:00
Louis Dionne 7ecd4d2b7c [libc++] Add LLDB data formatters dependencies to the CI image
This will be required in order to add a CI job running the LLDB
data formatters.
2022-09-12 10:56:54 -04:00
Tom Honermann 946849f6d0 [libc++] Workaround the absence of the __GLIBC_USE macro in glibc versions prior to 2.25.
This change correct a configuration check that relies on the glibc __GLIBC_USE
macro being defined. Previously, the function-like macro was expanded without
ensuring it was actually defined. This resulted in compilation failures for
glibc versions prior to 2.25 (the glibc version in which the macro was added).

Differential Revision: https://reviews.llvm.org/D130946
2022-09-11 16:39:37 -04:00
Mark de Wever 24e1736d84 [libc++][random] Removes transitive includes.
It seems these includes are still provided by the sub headers, so it only
removes the duplicates.

There is no change in the list of includes, but the change affects the
modular build. By not having the includes in the top-level header the
module map has changed. This uncovers missing includes in the tests
and missing exports in the module map. This causes the huge amount of
changes in the patch.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D133252
2022-09-11 17:39:27 +02:00
Mark de Wever 52a374e938 [libc++][doc] Updates format status page. 2022-09-11 12:12:22 +02:00
Tom Honermann 7e7013c5d4 [libc++][cuchar] Declare std::c8rtomb and std::mbrtoc8 in <cuchar> if available.
This change implements the C library dependent portions of P0482R6
(char8_t: A type for UTF-8 characters and strings (Revision 6)) by
declaring std::c8rtomb() and std::mbrtoc8() in the <cuchar> header
when implementations are provided by the C library as specified by
WG14 N2653 (char8_t: A type for UTF-8 characters and strings
(Revision 1)) as adopted for C23.

A _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8 macro is defined by the libc++ __config
header unless it is known that the C library provides these functions
in the current compilation mode. This macro is used for testing purposes
and may be of use to libc++ users. At present, the only C library known
to implement these functions is GNU libc as of its 2.36 release.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D130946
2022-09-10 21:10:33 -04:00
Nikolas Klauser 860753934c [libc++] Bump _LIBCPP_STD_VER to the next expected C++ version
We've decided to use `_LIBCPP_STD_VER >= xy` while discussing to change the constexpr macros, so let's finally bump the version macro to match that.

Reviewed By: ldionne, Mordante, huixie90, #libc, avogelsgesang

Spies: avogelsgesang, libcxx-commits

Differential Revision: https://reviews.llvm.org/D133323
2022-09-10 09:53:20 +02:00
Louis Dionne d529e8110b [libc++] Fix compilation error on platforms that don't implement std::tm
Instead of mentioning tm directly in the definition of __convert_to_tm,
take it as a template argument. As a fly-by also fix incorrect Lit feature
(should have been no-localization instead of libcpp-has-no-localization).

Differential Revision: https://reviews.llvm.org/D133490
2022-09-08 18:10:53 -04:00
Mark de Wever 3695cf2065 [libc++] Removes Clang 13 support.
Reviewed By: #libc, ldionne, jloser

Differential Revision: https://reviews.llvm.org/D133435
2022-09-08 17:51:52 +02:00
Mark de Wever de4a2b7381 [libc++] Fixes CI.
It seems merging the changes in transitive macros and recent commits
conflicted.
2022-09-07 19:58:21 +02:00
Mark de Wever ab7b776cf9 [libc++][locale] Removes an transitive include.
Removes <cstdarg> transitive include from <locale> in C++23.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D133254
2022-09-07 18:54:26 +02:00
Mark de Wever e5d2d3eafb [libc++][chrono] Implements formatter day.
This implements the enabled specializaton
template<class charT> struct formatter<chrono::day, charT>;

and
template<class charT, class traits>
    basic_ostream<charT, traits>&
      operator<<(basic_ostream<charT, traits>& os, const day& d);

Implements:
- LWG 3241 chrono-spec grammar ambiguity in §[time.format]

Partially implements:
- P1361 Integration of chrono with text formatting

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D128577
2022-09-07 18:44:04 +02:00
Mark de Wever b490c8a662 [libc++][format] Updates feature-test macros.
During the discussion on the SG-10 mailinglist regarding the format
feature-test macros voted in during the last plenary it turns out libc++
can't mark the format feature-test macro as implemented.

According to
  https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#__cpp_lib_format
the not yet implemented paper
  P1361R2 Integration of chrono with text formatting
affects the feature test macro.

Note that P1361R2 doesn't mention the feature-test macro nor is there an
LWG-issue to address the issue. The reporter of the issue didn't recall
where this requirement exactly has been decided.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D133271
2022-09-07 18:39:39 +02:00
Vitaly Buka beb413acce [test][libcxx] Mark ubsan test as UNSUPPORTED
It inconsistently fails on bots.
2022-09-06 13:44:28 -07:00
Matheus Izvekov 94c6dfbaeb
[clang] Implement setting crash_diagnostics_dir through env variable
This implements setting the equivalent of `-fcrash-diagnostics-dir`
through the environment variable `CLANG_CRASH_DIAGNOSTICS_DIR`.
If present, the flag still takes precedence.

This helps integration with test frameworks and pipelines.

With this feature, we change the libcxx bootstrapping build
pipeline to produce clang crash reproducers as artifacts.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D133082
2022-09-06 19:27:37 +02:00
Nikolas Klauser 5fab33af7f [libc++] Avoid instantiating type_trait classes
Use `using` aliases to avoid instantiating lots of types

Reviewed By: ldionne, #libc

Spies: libcxx-commits, miyuki

Differential Revision: https://reviews.llvm.org/D132785
2022-09-06 19:09:42 +02:00
Nikolas Klauser 2d52c6bfae [libc++] Granularize __tuple
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D133081
2022-09-05 16:36:24 +02:00
Nikolas Klauser e0b3356e67 [libc++] Enable rvalue overloads for pair in C++03
We require rvalue support anyways, so let's use it.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D133013
2022-09-05 14:40:17 +02:00
Nikolas Klauser d5e26775d0 [libc++] Granularize the rest of memory
Reviewed By: ldionne, #libc

Spies: vitalybuka, paulkirth, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D132790
2022-09-05 12:36:41 +02:00
Igor Zhukov 30dadaa2eb [libc++] Implement P2273R3 (`constexpr` `unique_ptr`)
Reviewed By: mordante, #libc

Differential Revision: https://reviews.llvm.org/D131315
2022-09-03 18:49:50 +07:00
Mark de Wever 4004fb6453 [NFC][libc++] Uses the new way to mark Standard includes. 2022-09-03 13:35:48 +02:00
Mark de Wever 49c3c40cc0 [NFC][libc++][format] Removes unused code.
The code was for backwards compatibility with code no longer present in
format.
2022-09-03 13:34:14 +02:00
Mark de Wever 56065c4c8e [NFC][libc++] Removes GCC-11 support.
GCC-11 isn't supported in libc++ so remove UNSUPPORTED directives.
2022-09-03 13:20:10 +02:00
Mark de Wever ba6ad62081 [libc++] Fixes generated output CI job.
It seems there was another file with the same issue, which didn't show
up initially.
2022-09-03 10:19:35 +02:00
Mark de Wever e31c2a1b1a [NFC][libc++] Moves transitive includes location.
As discussed in D132284 they will be moved to the end.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D133212
2022-09-03 10:06:16 +02:00
Mark de Wever ff06c2ded3 [libc++] Fixes generated output CI job. 2022-09-03 10:04:44 +02:00
Vitaly Buka bc8fd9c633 Revert "[libc++] Granularize the rest of memory"
Breaks buildbots.

This reverts commit 30adaa730c.
2022-09-02 19:42:49 -07:00