110 Commits

Author SHA1 Message Date
Louis Dionne
99174842ae
[libc++] Make std::jthread supported in non-experimental mode (#107900)
We waited before supporting std::jthread fully because we wanted to
investigate other implementation strategies (in particular one involving
std::mutex). Since then, we did some benchmarking and decided that we
wouldn't be moving forward with std::mutex. Hence, there is no real
reason to punt on making std::jthread & friends non-experimental.
2024-09-12 09:48:59 -04:00
Louis Dionne
695cb55ccb
[libc++] Remove obsolete header restrictions for _LIBCPP_HAS_NO_THREADS (#107437)
The _LIBCPP_HAS_NO_THREADS carve-out does not result in hard errors
anymore, but the patch that changed that forgot to update the header
restrictions we use to auto-generate several files.

We can also remove the restrictions for the no-localization build and
no-wide-characters, but doing it is less straightforward so I'm leaving
it out of this patch.
2024-09-11 17:47:33 -04:00
Hristo Hristov
4640736616
[libc++] Add missing std::is_virtual_base_of to type_traits.inc (#107009)
std::is_virtual_base_of was implemented in https://github.com/llvm/llvm-project/pull/105847
2024-09-03 13:28:36 -04:00
Louis Dionne
348e74139a [libc++][NFC] Run clang-format on libcxx/include
This re-formats a few headers that had become out-of-sync with respect
to formatting since we ran clang-format on the whole codebase. There's
surprisingly few instances of it.
2024-08-30 12:09:36 -04:00
Louis Dionne
0e8208eca1
[libc++] Run the Lit test suite against an installed version of the library (#96910)
We always strive to test libc++ as close as possible to the way we are
actually shipping it. This was approximated reasonably well by setting
up the minimal driver flags when running the test suite, however we were
running the test suite against the library located in the build
directory.

This patch improves the situation by installing the library (the
headers, the built library, modules, etc) into a fake location and then
running the test suite against that fake "installation root".

This should open the door to getting rid of the temporary copy of the
headers we make during the build process, however this is left for a
future improvement.

Note that this adds quite a bit of verbosity whenever running the test
suite because we install the headers beforehand every time. We should be
able to override this to silence it, however CMake doesn't currently
give us a way to do that, see https://gitlab.kitware.com/cmake/cmake/-/issues/26085.
2024-08-28 09:23:00 -04:00
A. Jiang
4ea2c73886
[libc++] Deprecate and remove std::uncaught_exception (#101830)
Works towards P0619R4/#99985.

- std::uncaught_exception was not previously deprecated. This patch
  deprecates it since C++17 as per N4259. std::uncaught_exceptions is
  used instead as libc++ unconditionally provides this function.

- _LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION restores
  std::uncaught_exception.

- As a drive-by, this patch updates the C++20 status page to 
  explain that D.11 is already done, since it was done in 
  578d09c1b195d859ca7e62840ff6bb83421a77b5.
2024-08-27 17:15:03 -04:00
Nikolas Klauser
5c717d6b1d
[libc++] re-enable clang-tidy in the CI and fix any issues (#102658)
It looks like we've accidentally disabled clang-tidy in the CI. This
re-enables it and fixes the issues accumulated while it was disabled.
2024-08-10 10:08:41 +02:00
Mark de Wever
f08df56d3a
[libc++][format] Implements P3107R5 in <format>. (#86713)
This adds the new std::enable_nonlocking_formatter_optimization trait in
<format>. This trait will be used in std::print to implement the
performance benefits.

Implements parts of
- P3107R5 - Permit an efficient implementation of ``std::print``
2024-07-30 19:04:26 +02:00
PaulXiCao
af0d731b12
[libc++][math] Mathematical Special Functions: Hermite Polynomial (#89982)
Implementing the Hermite polynomials which are part of C++17's
mathematical special functions. The goal is to get early feedback which
will make implementing the other functions easier. Integration of
functions in chunks (e.g. `std::hermite` at first, then `std::laguerre`,
etc.) might make sense as well (also see note on boost.math below).

I started out from this abandoned merge request:
https://reviews.llvm.org/D58876 .

The C++23 standard defines them in-terms of `/* floating-point type */`
arguments. I have not looked into that.

Note, there is still an ongoing discussion on discourse whether
importing boost.math is an option.
2024-07-20 17:50:05 +02:00
nicole mazzuca
04760bfadb
[libc++][ranges] P1223R5: find_last (#99312)
Implements [P1223R5][] completely.

Includes an implementation of `find_last`, `find_last_if`, and
`find_last_if_not`.

[P1223R5]: https://wg21.link/p1223r5
2024-07-19 09:42:16 -07:00
Hristo Hristov
e475bb7ac3
[libc++][memory] P1132R8: out_ptr - a scalable output pointer abstraction (#73618)
Differential Revision: https://reviews.llvm.org/D150525

Implements:
- https://wg21.link/P1132R8 - `out_ptr` - a scalable output pointer
abstraction
- https://eel.is/c++draft/smartptr.adapt - 20.3.4 Smart pointer adaptors
- https://wg21.link/LWG3734 - Inconsistency in `inout_ptr` and `out_ptr`
for empty case
- https://wg21.link/LWG3897- `inout_ptr` will not update raw pointer to
0

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
2024-07-19 06:38:02 +03:00
Mark de Wever
a05724a1f8
[libc++][chrono] Adds year_month_day_last&::operator<=>. (#98169)
41f7bb9975bcaffae0267fa87b63c90b83ffd551 claimed it implemented this
change but the code was not adjusted. The other spaceship operators in
the calendar code have been validated too.

Implements parts of
- P1614R2 The Mothership has Landed
2024-07-16 19:01:00 +02:00
Mark de Wever
eae174c724
[libc++][TZDB] Implements zoned_seconds typedef. (#95141)
Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
2024-07-10 18:35:43 +02:00
Mark de Wever
dda4184808
[libc++][TZDB] Adds basics of zoned_time class. (#94999)
This implements the class, its non-templated constructors and its
getters to verify the construction.

Completes
- LWG3224 zoned_time constructor from TimeZonePtr does not specify
initialization of tp_

Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
2024-07-09 20:14:40 +02:00
Mark de Wever
2dadf8d7f5
[libc++] Update status after the St. Louis meeting. (#97951)
This updates:
- The status tables
- Feature test macros
- New headers for modules
2024-07-08 19:35:31 +02:00
RichardLuo
ed1273d4dd
[libc++] change the visibility of libc++ header to public in libcxx module (#91240)
This PR addresses a problem that headers may not be able to be found if
`#include` is used with std modules.

Consider the following file:

    #include <boost/json.hpp>
    import std;

    int main(int, const char **) { }


Boost will include something from libc++, but we are using -nostdinc++
at [1] so the compiler can not find any default std header. Therefore 
the locally built header needs to be public.

[1]: 15fdd47c4b/libcxx/modules/CMakeLists.txt.in (L52)
2024-06-25 09:57:53 -05:00
Mark de Wever
151bd7cab4
[libc++][TZDB] Implements zoned_traits. (#91059)
Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
2024-06-10 17:13:08 +02:00
Mark de Wever
87cedbec1c
[libc++][TZDB] Implements time_zone::to_sys. (#90901)
This implements the overload with the choose argument and adds this
enum.

Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
2024-06-10 08:40:04 +02:00
Mark de Wever
77116bd7d2
[libc++][TZDB] Implements time_zone::to_sys. (#90394)
This implements the throwing overload and the exception classes throw by
this overload.

Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
2024-06-10 00:33:39 +02:00
Nico Weber
716ed5fccd
[libc++] Undeprecate shared_ptr atomic access APIs (#92920)
This patch reverts 9b832b72 (#87111):
- [libc++] Deprecated `shared_ptr` Atomic Access APIs as per P0718R2
- [libc++] Implemented P2869R3: Remove Deprecated `shared_ptr` Atomic Access APIs from C++26

As explained in [1], the suggested replacement in P2869R3 is `__cpp_lib_atomic_shared_ptr`,
which libc++ does not yet implement. Let's not deprecate the old way of doing things before
the new way of doing things exists.

[1]: https://github.com/llvm/llvm-project/pull/87111#issuecomment-2112740039
2024-06-07 11:31:17 -04:00
Louis Dionne
bd135c3b9f
[runtimes][CMake] Simplify the propagation of test dependencies (#93558)
Instead of using FOO_TEST_DEPS global variables that don't get updated
properly from subdirectories, use targets to propagate the dependencies
across directories.
2024-05-28 18:31:01 -07:00
Damien L-G
42ba740aff
[libc++] Implement C++20 atomic_ref (#76647)
Implement the std::atomic_ref class template by reusing atomic_base_impl.
Based on the work from https://reviews.llvm.org/D72240
2024-05-21 15:54:08 -07:00
Mark de Wever
79921fbd5c
[libc++][CI] Reenables clang-tidy. (#90077)
The patch does several things:
- fixes module exports
- disables clang-tidy with Clang-17 due to known issues
- disabled clang-tidy on older libstdc++ versions since it lacks C++20
features used
- fixes the CMake dependency

The issue why clang-tidy was not used in the CI was the last issue; the
plugin was not a
dependency of the tests. Without a plugin the tests disable clang-tidy.

This was noticed while investigating
https://github.com/llvm/llvm-project/issues/89898
2024-05-08 20:17:59 +02:00
Mark de Wever
6c4dedde08
[libc++][modules] Uses _LIBCPP_USING_IF_EXISTS. (#90409)
This attribute is used in the headers. Not using this in the modules has
led to several issues. Add them to the modules to avoid these errors in
other placed.
2024-05-03 17:29:27 +02:00
Mark de Wever
d6c4ebbf78
[libc++][ranges] Exports operator|. (#90071)
This was omitted in c1086532d4d5 and not detected by the CI since
clang-tidy is not running. This fixes the exports.

Fixes: https://github.com/llvm/llvm-project/issues/89898
2024-04-26 18:20:45 +02:00
Martin Storsjö
91526d64a8
[libcxx] [modules] Add _LIBCPP_USING_IF_EXISTS on aligned_alloc (#89827)
This is missing e.g. on Windows. With this change, it's possible to make
the libcxx std module work on mingw-w64 (although that requires a few
fixes to those headers).

In the regular cstdlib header, we have _LIBCPP_USING_IF_EXISTS flagged
on every single reexported function (since
a9c9183ca42629fa83cdda297d1d30c7bc1d7c91), but the modules seem to only
have _LIBCPP_USING_IF_EXISTS set on a few individual functions, so far.
2024-04-24 11:45:27 +03:00
Xiaoyang Liu
3a9d8cd5fc
[libc++][ranges] export std::ranges::range_adaptor_closure (#89793)
This patch exports the `std::ranges::range_adaptor_closure` class
template implemented in #89148 from the C++ Modules file.
2024-04-23 13:23:50 -04:00
Mark de Wever
8a21d59f29
[libc++][TZDB] Adds local_info formatter. (#86256)
This adds the local_info type and its formatting options.
The usage of the local_info object will be done in separate patches.

Implements parts of:
- P0355 Extending to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
2024-04-18 17:23:07 +02:00
Hristo Hristov
9b832b726c
[libc++] Deprecated shared_ptr Atomic Access APIs as per P0718R2 & Implemented P2869R3: Remove Deprecated shared_ptr Atomic Access APIs from C++26 (#87111)
Implements https://wg21.link/P2869R4
Implements deprecations as per https://wg21.link/P0718R2
2024-04-14 14:37:51 +03:00
Mark de Wever
1fda1776e3
[libc++][chrono] Adds the sys_info class. (#85619)
Adds the sys_info class and time_zone::get_info(). The code still has a
few quirks and has not been optimized for performance yet.

The returned sys_info is compared against the output of the zdump tool
in the test giving confidence the implementation is correct.

Implements parts of:
- P0355 Extending <chrono> to Calendars and Time Zones

Implements:
- LWGXXXX The sys_info range should be affected by save
2024-04-10 07:50:17 +02:00
Jakub Mazurkiewicz
c8917048e3
[libc++] Implement bind_back (#81055)
Implement `std::bind_back` function from P2387R3 "Pipe support for
user-defined range adaptors".
2024-04-09 11:10:20 -04:00
Hristo Hristov
a834436099
[libc++] P2872R3: Remove `wstring_convert` From C++26 (#87100)
Implements: https://wg21.link/P2872R3
2024-04-05 22:04:07 +03:00
Mark de Wever
4167fec407
[libc++][chrono] Completes the tzdb class. (#82157)
It adds the missing member functions of the tzdb class and adds the free
functions that use these member functions.

Implements parts of:
- P0355 Extending <chrono> to Calendars and Time Zones
2024-04-04 19:03:01 +02:00
Hristo Hristov
fb635be0b8
[libc++] P2867R1: Remove Deprecated strstreams From C++26 (#87107)
Implements: https://wg21.link/P2867R2

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
2024-04-04 06:03:00 +03:00
Mark de Wever
6f2d8cc061
[libc++][chrono] Loads leap-seconds.list in tzdb. (#82113)
This implements the loading of the leap-seconds.list file and store its
contents in the tzdb struct.

This adds the required `leap_seconds` member.

The class leap_seconds is fully implemented including its non-member
functions.

Implements parts of:
- P0355 Extending <chrono> to Calendars and Time Zones
- P1614 The Mothership has Landed

Implements:
- P1981 Rename leap to leap_second
- LWG3359 <chrono> leap second support should allow for negative leap
seconds
- LWG3383 §[time.zone.leap.nonmembers] sys_seconds should be replaced
with seconds
2024-04-03 18:15:24 +02:00
Martin Storsjö
50801f1095
Reapply [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#86020)
This reapplies 272d1b44efdedb68c194970a610f0ca1b7b769c5 (from #85756),
which was reverted in
407937036fa7640f61f225474b1ea6623a40dbdd.

In the previous attempt, empty CMAKE_INSTALL_PREFIX was handled by
quoting them, in d209d1340b99d4fbd325dffb5e13b757ab8264ea. That made the
calls to cmake_path(ABSOLUTE_PATH) succeed, but the output paths of that
weren't actually absolute, which was required by file(RELATIVE_PATH).

Avoid this issue by constructing a non-empty base directory variable
to use for calculating the relative path.
2024-03-21 17:29:15 +02:00
Martin Storsjö
407937036f Revert "[libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#85756)"
This reverts commit 272d1b44efdedb68c194970a610f0ca1b7b769c5,
and the follow-up fix in d209d1340b99d4fbd325dffb5e13b757ab8264ea.

Even after the follow-up fix, building with an empty
CMAKE_INSTALL_PREFIX errors out with errors like this:

    CMake Error at /b/s/w/ir/x/w/llvm-llvm-project/libcxx/modules/CMakeLists.txt:215 (file):
      file RELATIVE_PATH must be passed a full path to the directory:
      lib/x86_64-pc-windows-msvc
2024-03-20 18:06:31 +02:00
Martin Storsjö
d209d1340b [libcxx] [cmake] Fix cmake_path(ABSOLUTE_PATH) for empty CMAKE_INSTALL_PREFIX
This should hopefully fix the issue brought up at
https://github.com/llvm/llvm-project/pull/85756#issuecomment-2009852291.
2024-03-20 17:50:12 +02:00
Martin Storsjö
272d1b44ef
[libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#85756)
In other contexts, install directories such as
LIBCXX_INSTALL_LIBRARY_DIR and LIBCXX_INSTALL_MODULES_DIR can be
specified either as a relative path, relative to CMAKE_INSTALL_PREFIX,
or as an absolute path.

When calculating the relative path between the two, account for the fact
that LIBCXX_INSTALL_MODULES_DIR and LIBCXX_INSTALL_LIBRARY_DIR can be
absolute paths too.
2024-03-20 10:45:43 +02:00
Eric
2c703ed728
Rework Modules CMake to be (more) idiomatic. (#84936)
- Fix bug in documentation regarding dependencies.
- Rework Modules CMake to be (more) idiomatic.
2024-03-15 08:23:07 -04:00
Louis Dionne
4d80df0922
[libc++] Do not forward-declare syncstream outside experimental (#82511)
We only define the classes in `<syncstream>` when experimental library
features are enabled, but we would forward-declare them in `<iosfwd>`
even when they are disabled. This led to confusing error messages about
being unable to instantiate an undefined template.
2024-03-04 18:16:52 -05:00
Mark de Wever
b50bcc7ffb
[libc++][modules] Fixes naming inconsistency. (#83036)
The modules used is-standard-library and is-std-library. The latter is
the name used in the SG15 proposal,

Fixes: https://github.com/llvm/llvm-project/issues/82879
2024-02-27 12:10:53 -05:00
Dominik Wójt
c19a81931c
[libc++] protect absent atomic types with ifdef (#82351)
Otherwise modules.std-module.sh.cpp test fails with following error:
    error: no member named 'atomic_signed_lock_free' in namespace 'std'
when the types are not available.
2024-02-27 07:27:02 +01:00
Hristo Hristov
2ea5d167ae
[libc++][complex] P2819R2: Add tuple protocol to complex (#79744)
Implements: P2819R2 <https://wg21.link/P2819R2>
- https://eel.is/c++draft/utilities#concept:tuple-like
- https://eel.is/c++draft/complex.syn
- https://eel.is/c++draft/complex.tuple

---------

Co-authored-by: Zingam <zingam@outlook.com>
2024-02-19 09:56:06 +02:00
Mark de Wever
d332d88b91
[libc++][chrono] Loads tzdata.zi in tzdb. (#74928)
This implements the loading of the tzdata.zi file and store its contents
in the tzdb struct.

This adds all required members except:
- the leap seconds,
- the locate_zone, and
- current_zone.

The class time_zone is incomplete and only contains the parts needed for
storing the parsed data.

The class time_zone_link is fully implemented including its non-member
functions.

Implements parts of:
- P0355 Extending <chrono> to Calendars and Time Zones
- P1614 The Mothership has Landed

Implements:
- P1982 Rename link to time_zone_link
2024-02-17 14:28:01 +01:00
ZijunZhaoCCK
a6b846ae1e
[libc++][ranges] Implement ranges::contains_subrange (#66963) 2024-02-13 15:42:37 -08:00
Mark de Wever
fc0e9c8315
[libc++][modules] Re-add build dir CMakeLists.txt. (#81370)
This CMakeLists.txt is used to build modules without build system
support. This was removed in d06ae33ec32122bb526fb35025c1f0cf979f1090.
This is used in the documentation how to use modules.

Made some minor changes to make it work with the std.compat module using
the std module.

Note the CMakeLists.txt in the build dir should be removed once build
system support is generally available.
2024-02-13 20:04:34 +01:00
Mark de Wever
f66f44eb0c [libc++][modules] Regenerates files.
After applying the review comments of
https://github.com/llvm/llvm-project/pull/80478
I've forgotten to update the generated files. This fixes the issue and
removes trailing whitespace.
2024-02-10 15:25:30 +01:00
Po-yao Chang
30cd1838dc
[libc++][modules] Fix disabling Unicode (#81294)
-DLIBCXX_ENABLE_UNICODE=OFF or -D_LIBCPP_HAS_NO_UNICODE doesn't build
without this change.
2024-02-10 15:22:16 +01:00
Mark de Wever
4bf9fa5fb5
[libc++][modules] Guard missing header validation on Windows. (#80478)
On Windows the libc++ test suite sees the MSVC STL headers and may
conclude these are libc++ headers when inspecting the name. Modules
guard against forgetting to export new headers. Finding MSVC STL's
headers gives false positives. Since the CI tests non-Windows platforms
too, the validation will be disabled on Windows.

Fixes: https://github.com/llvm/llvm-project/issues/79010

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2024-02-09 17:41:46 +01:00