117 Commits

Author SHA1 Message Date
Louis Dionne
09e3a36058
[libc++][modules] Fix missing and incorrect includes (#108850)
This patch adds a large number of missing includes in the libc++ headers
and the test suite. Those were found as part of the effort to move
towards a mostly monolithic top-level std module.
2024-09-16 15:06:20 -04:00
David Spickett
cdd608b8f0
[libcxx][test] Use smaller time range for 32 bit time_t (#104762)
This fixes the test on Arm 32 bit Ubuntu Jammy where time_t is 32 bit.
2024-09-13 09:14:53 +01:00
Louis Dionne
5e19fd1720
[libc++][modules] Consolidate leaf modules into their own top-level modules (#107147)
Some modules are leaf modules in the sense that they are not used by any
other part of the headers. These leaf modules are easy to consolidate
since there is no risk to create a cycle. As a result of regrouping
these modules, several missing includes were found and fixed in this
patch.
2024-09-04 16:39:55 -04:00
David Spickett
6f6422f4a2 [lldb][test] Mark sys_info zdump test unsupported on 32 bit Arm Linux
Until https://github.com/llvm/llvm-project/pull/103056 lands
or another more appropriate check can be found.

This test fails on Ubuntu Focal where zdump is built with 32 bit time_t
but passes on Ubuntu Jammy where zdump is built with 64 bit time_t.

Marking it unsupported means Linaro can upgrade its bots to Ubuntu
Jammy without getting an unexpected pass.
2024-08-15 08:16:05 +00:00
Mark de Wever
642259a2f2
[libc++][chrono][test] Fixes bogus loops. (#101890)
Changes the loop range to match similar tests and avoids zero
iterations. The original motivation to reduce the number of iterations
was to allow the test to be executed during constant evaluation.

Fixes: https://github.com/llvm/llvm-project/issues/100502
2024-08-06 19:38:46 +02:00
Nikolas Klauser
5dfdac74ca
[libc++][NFC] Avoid opening namespace std in the tests (#94160)
This also adds a few FIXMEs where we use UB in the tests.
2024-08-01 10:57:21 +02:00
Louis Dionne
6a54dfbfe5 [libc++][NFC] Add missing license headers
Also standardize the license comment in several files where it was
different from what we normally do.
2024-07-31 12:58:09 -04:00
Stephan T. Lavavej
b27360c346
[libc++][test] Fix Clang -Wunused-variable warnings in time.zone.members/to_sys.pass.cpp (#100504) 2024-07-25 15:45:29 -07:00
Mark de Wever
afbfb16d29
[libc++][TZDB] Implements zoned_time formatters. (#98347)
Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
- P1361 Integration of chrono with text formatting
- P2372 Fixing locale handling in chrono formatters
2024-07-20 19:24:41 +02:00
David Spickett
f0617d2def
[libcxx][test] Remove picolib UNSUPPORTED for now.pass.cpp (#99503)
This ARM semihosting call was implemented in QEMU by
4d834039c2
and is present in the qemu-system-arm v8.1.3 used by the builders.
2024-07-19 09:59:06 +01:00
A. Jiang
684a61506a
[libc++][chrono] Remove non-standard relational operators for std::chrono::weekday (#98730)
These operators are absent in https://eel.is/c++draft/time.syn and a note in
https://eel.is/c++draft/time.cal.wd.overview#1 indicates that the absence is 
intended.

This patch removes the undocumented extension, while providing a migration path
for vendors by providing the `_LIBCPP_ENABLE_REMOVED_WEEKDAY_RELATIONAL_OPERATORS`
macro. This macro will be honored for the LLVM 19 release and will be removed after 
that, at which point allocator will be removed unconditionally.
2024-07-18 09:58:35 -04: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
6c97ad4e68
[libc++][chrono] Fix streaming for unsigned durations. (#97889)
This fixes formatting for durations using the unsigned types unsigned
short, unsigned, unsigned long, and unsigned long long. It does not
allow the unsigned char type. Since the formatting function uses
ostream::operator<< this type probably does not do what it should do.

Note that based on the standard all arithmetic types are allowed,
including bool, char, wchar_t. These types are not implemented either.
Allowing them seems like a defect in the Standard.

No effort is done to support user-defined types; the wording in the
Standard is unclear regarding the constrains for these types.

[LWG 4118](https://cplusplus.github.io/LWG/issue4118) discusses this
issue further.

Fixes https://github.com/llvm/llvm-project/issues/96820
2024-07-10 20:13:05 +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
2b1b4e3025
[libc++][TZDB] Implements zoned_time's operator==. (#95140)
Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
- P1614R2 The Mothership has Landed
2024-07-10 16:06:29 +02:00
Mark de Wever
e77b295ada
[libc++][TZDB] Adds zoned_time deduction guides. (#95139)
Completes
- LWG3232 Inconsistency in zoned_time  deduction guides
- LWG3294 zoned_time  deduction guides misinterprets stringchar*

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
2024-07-10 13:46:56 +02:00
Mark de Wever
0a95f2f7fe
[libc++][TZDB] Finishes zoned_time member functions. (#95026)
Note the implementation of
  zoned_time& operator=(const local_time<Duration>& lt);
is not correct; however the wording cannot be easily implemented. It
could be if the object caches the local_time assigned. However this does
not seem to intended. The current implementation matches MSVC STL and
libstdc++.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
2024-07-10 11:46:44 +02:00
Mark de Wever
a1d73ace13
[libc++][TZDB] Finishes zoned_time constructors. (#95010)
Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept
zoned_time<Duration2, TimeZonePtr2>

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
2024-07-09 20:15:49 +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
Nikolas Klauser
9e9404387d
[libc++] Remove annotations for GCC 13 and update the documentation (#97744)
GCC 14 has been released a while ago. We've updated the CI to use GCC 14
now. This removes any old annotations in the tests and updates the
documentation to reflect the updated version requirements.
2024-07-06 16:52:45 +02:00
Mark de Wever
093ddac68c
[libc++][chrono] Fixes leap seconds. (#90070)
While implementing the UTC clock it turns out that the implementation of
the leap seconds was not correct, it should store the individual value,
not the sum.

It also looks like LWG3359 has not been fully implemented.

Implements parts of:
- LWG3359 <chrono> leap second support should allow for negative leap
seconds
2024-07-04 20:45:15 +02:00
Mark de Wever
e48f211ab8
[libc++][TZDB] Disables a failing test. (#95659)
The test fails depending on the timezone database used. Disable it for
now so it can be properly investigated later.
2024-06-15 19:59:05 +02:00
Louis Dionne
148417bfaa
[libc++] Mark local_time test as a long test (#95170)
It can otherwise timeout under some slow configurations.
2024-06-12 17:24:38 -04:00
Florian Mayer
00c5474918 [HWASan] make get_info.local_time.pass.cpp UNSUPPORTED 2024-06-11 09:06:07 -07:00
Florian Mayer
503fb1aaf4 [HWASan] skip libcxx test that times out with hwasan 2024-06-10 10:35:18 -07: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
da03175cae
[libc++][TZDB] Implements time_zone::to_local. (#91003)
Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
2024-06-10 12:40:27 +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
Mark de Wever
de736d9c6a
[libc++][TZDB] Implements time_zone get_info(local_time). (#89537)
Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
2024-06-09 18:21:35 +02:00
Nikolas Klauser
cb7a03b41f
[libc++] Fix failures with GCC 14 (#92663)
Fixes #91831
2024-06-01 12:20:41 +02:00
Stephan T. Lavavej
2ba0838615
[libc++] [test] Fix portability issues for MSVC (#93259)
* Guard `std::__make_from_tuple_impl` tests with `#ifdef _LIBCPP_VERSION` and `LIBCPP_STATIC_ASSERT`.
* Change `_LIBCPP_CONSTEXPR_SINCE_CXX20` to `TEST_CONSTEXPR_CXX20`.
+ Other functions in `variant.swap/swap.pass.cpp` were already using the proper test macro.
* Mark `what` as `[[maybe_unused]]` when used by `TEST_LIBCPP_REQUIRE`.
  + This updates one occurrence in `libcxx/test/libcxx` for consistency.
* Windows `_putenv_s()` takes 2 arguments, not 3.
  + See MSVC documentation: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-s-wputenv-s?view=msvc-170
+ POSIX `setenv()` takes `int overwrite`, but Windows `_putenv_s()` always overwrites.
* Avoid non-Standard zero-length arrays.
  + Followup to #74183 and #79792.
* Add `operator++()` to `unsized_it`.
+ The Standard requires this due to [N4981][] [move.iter.requirements]/1 "The template parameter `Iterator` shall
  either meet the *Cpp17InputIterator* requirements ([input.iterators])
  or model `input_iterator` ([iterator.concept.input])."
+ MSVC's STL requires this because it has a strengthened exception
  specification in `move_iterator` that inspects the underlying iterator's
  increment operator.
* `uniform_int_distribution` forbids `int8_t`/`uint8_t`.
  + See [N4981][] [rand.req.genl]/1.5. MSVC's STL enforces this.
+ Note that when changing the distribution's `IntType`, we need to be
  careful to preserve the original value range of `[0, max_input]`.
* fstreams are constructible from `const fs::path::value_type*` on wide systems.
  + See [ifstream.cons], [ofstream.cons], [fstream.cons].
* In `msvc_stdlib_force_include.h`, map `_HAS_CXX23` to `TEST_STD_VER` 23 instead of 99.
+ On 2023-05-23, 71400505ca
  started recognizing 23 as a distinct value.
* Fix test name typo: `destory_elements.pass.cpp` => `destroy_elements.pass.cpp`

[N4981]: https://wg21.link/N4981
2024-05-28 12:20:58 -07:00
Mark de Wever
4e9decf294
[libc++][TZDB] Fixes reverse time lookups. (#89502)
Testing with the get_info() returning a local_info revealed some issues
in the reverse lookup. This needed an additional quirk. Also the
skipping when not in the current continuation optimization was wrong. It
prevented merging two sys_info objects.
2024-04-23 22:28:31 +02:00
Mark de Wever
579d30109a
[libc++][chrono] Fixes format output of negative values. (#89408)
When trying to express a time before the epoch (e.g. "one nanosecond
before 00:01:40 on 1900-01-01")
the date would be shown as:

  1900-01-01 00:01:39.-00000001

After this patch, that time would be correctly shown as:

  1900-01-01 00:01:39.999999999
2024-04-23 19:42:00 +02:00
Mark de Wever
a4422a5194
[libc++][TZDB] Renames incomplete. (#89250)
The new name uses experimental which better conveys what it means.
2024-04-20 12:09:13 +02:00
Mark de Wever
e9654880df [NFC][libc++][chrono] Renames a file.
This uses a period instead of a comma; the latter was a typo.
2024-04-18 19:39:22 +02: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
Mark de Wever
6f7976c883
[libc++][TZDB] Adds sys_info formatter. (#85896)
Implements parts of:
- P0355 Extending <chrono> to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
2024-04-17 20:55:51 +02:00
Mark de Wever
812963f6aa
[libc++][chrono] Improves date formatting. (#86127)
The formatting of years has been done manually since the results of %Y
outside the "typical" range may produce unexpected values. The same
applies to %F which is identical to %Y-%m-%d. None of these conversion
specifiers is affected by the locale used. So it's trivial to manually
handle this case.

This removes several platform specific ifdefs from the tests.
2024-04-17 17:02:07 +02:00
Mark de Wever
a6fcbcce8f
[libc++][TZDB] Improves time zone format specifiers. (#85797)
Per [tab:time.format.spec]
%z  The offset from UTC as specified in ISO 8601-1:2019, subclause
    5.3.4.1. For example -0430 refers to 4 hours 30 minutes behind UTC.
    If the offset is zero, +0000 is used. The modified commands %Ez and
    %Oz insert a : between the hours and minutes: -04:30. If the offset
    information is not available, an exception of type format_error is
    thrown.

Typically the modified versions Oz or Ez would have wording like

  The modified command %OS produces the locale's alternative
  representation.

In this case the modified version does not depend on the locale.

This change is a preparation for formatting sys_info which has time zone
information. The function time_put<_CharT>::put() does not have proper
time zone support, therefore it's a manual implementation.

Fixes https://github.com/llvm/llvm-project/issues/78184
2024-04-17 07:59:43 +02:00
Mark de Wever
8885813ebb [libc++][chrono] Disables a test.
This tests seems problematic on different platforms. There is still a
test that ensures coverage, but in an automatic fashion. This test needs
to be investigated.
2024-04-16 20:46:47 +02:00
Mark de Wever
ecf44b4b71 [libc++][TZDB] Removes test_indian_kerguelen test.
The work-around in 26852565a5f609e6b466f43c2f690ce3047d04c7 didn't fix
the CI. Since the entire local database is compared with the libc++
implementation in a separate this this change does not remove coverage.
2024-04-13 20:35:59 +02:00
Mark de Wever
26852565a5 [libc++][TZDZ] Validates the database version.
It seems one of the tests requires a very recent timezone database. Skip
the test when the database is older.
2024-04-13 16:08:07 +02:00
Mark de Wever
0a1317564a
[libc++] Adds a global private constructor tag. (#87920)
This removes the similar tags used in the chrono tzdb implementation.

Fixes: https://github.com/llvm/llvm-project/issues/85432
2024-04-10 20:34:58 +02: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
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
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
Mark de Wever
abe292f9f8
[libc++] Enables TZDB tests. (#82108)
With the timezone information available in the CI these tests can be
enabled again.

Fixes: https://github.com/llvm/llvm-project/issues/81654
2024-03-15 08:17:08 +01:00
Lei Huang
e4d4cfa5a0
[libc++] Fixes time formatter test output for Linux on PowerPC (#75526)
Fix output to match actual.
2024-03-07 09:32:43 -05:00
Dominik Wójt
d1a461dbb2
[libc++] tests with picolibc: prevent looking for unneeded "rt" library (#82262)
Picolibc does not provide the clock_gettime function nor the "rt" library.
check_library_exists was invalidly detecting the "rt" library due to cmake issue 
present, when cross-compiling[1]. This resulted with "chrono.cpp" trying to link
to the "rt" library and following error:
    unable to find library from dependent library specifier: rt

[1] https://gitlab.kitware.com/cmake/cmake/-/issues/18121
2024-02-29 08:54:58 +01:00