12528 Commits

Author SHA1 Message Date
Petr Hosek
edf9439e00
[libcxx] Support for using timespec_get (#117362)
clock_gettime is a POSIX API that may not be available on platforms like
baremetal; timespec_get is the C11 equivalent. This change adds support
for using timespec_get instead of clock_gettime to improve compatibility
with non-POSIX platforms. For now, this is only enabled with LLVM libc
which implemented timespec_get in #116102, but in the future this can be
expanded to other platforms.

Related to #84879.
2024-12-17 08:16:55 -08:00
Petr Hosek
62bd10f7d1
[libcxx] Use alias for detecting overriden function (#114961)
This mechanism is preferable in environments like embedded since it
doesn't require special handling of the custom section.
2024-12-17 08:16:26 -08:00
Louis Dionne
d8a0709b10
[libc++] Bump the version of CMake built in the CI Docker image (#120240)
This will allow using the $<LINK_LIBRARY> generator expression in some
of our configurations. We should separately pursue officially bumping
the minimum CMake version across all LLVM so we can use this feature
more widely.
2024-12-17 10:29:18 -05:00
Louis Dionne
ce4ac99452
[libc++] Remove explicit mentions of __need_FOO macros (#119025)
This change has a long history. It was first attempted naively in
https://reviews.llvm.org/D131425, which didn't work because we broke the
ability for code to include e.g. <stdio.h> multiple times and get
different definitions based on the pre-defined macros.

However, in #86843 we managed to simplify <stddef.h> by including the
underlying system header outside of any include guards, which worked.

This patch applies the same simplification we did to <stddef.h> to the
other headers that currently mention __need_FOO macros explicitly.
2024-12-17 09:52:34 -05:00
Nikolas Klauser
59890c1334
[libc++] Granularize <new> includes (#119964) 2024-12-17 11:29:16 +01:00
Louis Dionne
084309a0ef
[libc++] Refactor the Windows and MinGW implementation of the locale base API (#115752)
This patch reimplements the locale base support for Windows flavors in a
way that is more modules-friendly and without defining non-internal
names.

Since this changes the name of some types and entry points in the built
library, this is effectively an ABI break on Windows (which is
acceptable after checking with the Windows/libc++ maintainers).
2024-12-16 17:46:05 -05:00
Vitaly Buka
31272e4f83
[libc++] Update locale grouping tests (#119463)
Fixes #119047
2024-12-16 12:50:59 -05:00
Louis Dionne
4104906a23 [libc++] Revert new test for integral_constant that breaks CI
This commit reverts c3276a96d9 and 1901da32, which added a test to
ensure that type traits are derived from integral_constant. While that
is a fine test to add, the commit didn't go through a PR and as a result
it looks like some of our CI has been broken by it.

This should be an uncontroversial change, but let's re-land it via a PR
to get our usual CI coverage.
2024-12-16 10:41:16 -05:00
Nikolas Klauser
c3276a96d9 [libc++] Disable deprecation warnings in derived_from_integral_constant.compile.pass.cpp 2024-12-14 16:19:40 +01:00
Nikolas Klauser
1901da32a4 [libc++] Add a test to make sure all the type traits derived from bool_constant 2024-12-14 15:19:19 +01:00
Nikolas Klauser
6157dbe48c
[libc++] Introduce __forward_as (#118168)
This allows forwarding an object as a specific type. This is usually
useful when using `deducing this` to avoid calling any functions in a
deriving class.
2024-12-14 15:09:16 +01:00
Louis Dionne
2135babe28
[libc++] Save benchmark results in a json file (#119761)
When running a benchmark, also save the benchmark results in a JSON
file. That is cheap to do and useful to compare benchmark results
between different runs.
2024-12-13 14:19:35 -05:00
Louis Dionne
9474e09459
[libc++] Granularize the <new> header (#119270)
This disentangles the code which previously had a mix of many #ifdefs, a
non-versioned namespace and a versioned namespace. It also makes it
clearer which parts of <new> are implemented on Windows by including <new.h>.
2024-12-13 14:17:56 -05:00
Louis Dionne
62bdb85f9b [libc++][NFC] Fix incorrect comment for vector::assign(iter, iter) test 2024-12-13 09:35:56 -05:00
Peng Liu
979e9361f0
[libc++] Fix improper static_cast in std::deque and __split_buffer (#119106)
This PR addresses the improper use of `static_cast` to `size_t` where
`size_type` is intended. Although the `size_type` member type of STL
containers is usually a synonym of `std::size_t`, there is no guarantee
that they are always equivalent. The C++ standard does not mandate this
equivalence.

In libc++'s implementations of `std::deque`, `std::vector`, and
`__split_buffer`, the `size_type` member type is defined as
`std::allocator_traits<allocator_type>::size_type`, which is either
`allocator_type::size_type` if available or
`std::make_unsigned<difference_type>::type`. While it is true for
`std::allocator` that the `size_type` member type is `std::size_t`, for
user-defined allocator types, they may mismatch. This justifies the need
to replace `static_cast<size_t>` with `static_cast<size_type>` in this
PR.
2024-12-13 09:28:30 -05:00
Nikolas Klauser
5fd385b3c1
[libc++][NFC] Simplify the implementation of string and string_views operator== (#117184) 2024-12-13 13:17:19 +01:00
Louis Dionne
81dcbefba3
[libc++] Add testing configurations for libstdc++ and a native stdlib (#98539)
This allows running the test suite against the native Standard Library
on most systems, and against libstdc++ installed at a custom location.

Of course, these configurations don't run 100% clean at the moment. In
particular, running against the native stdlib is almost guaranteed not
to work out-of-the-box, since the test suite generally contains tests
for things that have been implemented on tip-of-trunk but not released
to most major platforms yet. However, having an easy way to run the test
suite against that library is still both useful and interesting.
2024-12-12 17:01:46 -05:00
Louis Dionne
6a9279ca40
[libc++] Slight reorganization of the benchmarks (#119625)
Move various container benchmarks to the same subdirectory, and regroup
some format-related benchmarks.
2024-12-12 08:14:50 -05:00
Louis Dionne
4b8bf6aac8
[libc++] Properly guard flat_map includes based on C++ version (#119227)
That's what we (try to) do consistently for all other umbrella headers.

As a drive-by, remove the <__assert> header which is not mandated
anymore.
2024-12-11 16:53:33 -05:00
Louis Dionne
7b2d592a19 [libc++] Fix test FTM header guard
That template is actually not used to generate the version header yet,
but we can at least fix the include guards which are clearly incorrect.
2024-12-11 12:39:43 -05:00
Nikolas Klauser
323bedd0d6
[libc++][C++03] Add #if 0 to the experimental/ and ext/ headers as well (#119541)
This has already been done for the most headers in
https://github.com/llvm/llvm-project/pull/119234, but I
forgot to also do it for the experimental/ and ext/ headers.

This is part of https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc.
2024-12-11 10:35:21 -05:00
Peng Liu
eacdbc269e
[libc++][test] Fix invalid const conversion in limited_allocator (#118189)
This patch fixes a const-qualification on the return type of a method
of `limited_allocator`, which is widely used for testing allocator-aware
containers.
2024-12-10 10:24:40 -05:00
Louis Dionne
01512d29b7
[libc++] Document guidelines for symbols baked into the ABI (#118526)
Closes #112395
2024-12-10 10:15:13 -05:00
Louis Dionne
bd8eb7894f [libc++] Temporarily disable FreeBSD runners
They have been out for over 10 days, which only causes confusion
when looking at CI results.
2024-12-10 10:11:27 -05:00
Nikolas Klauser
c166a9c713
[libc++] Add #if 0 block to all the top-level headers (#119234)
Including The frozen C++03 headers results in a lot of formatting
changes in the main headers, so this splits these changes into a
separate commit instead.

This is part of
https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc.
2024-12-10 16:02:12 +01:00
Stephan T. Lavavej
cb4433b677
[libcxx][test] Silence nodiscard warnings for std::expected (#119174)
I'm exploring marking microsoft/STL's std::expected as [[nodiscard]],
which affects all functions returning std::expected, including its
own monadic member functions.

As usual, libc++'s test suite contains calls to these member functions
to make sure they compile, but it's discarding the returns. I'm adding
void casts to silence the [[nodiscard]] warnings without altering
what the test is covering.
2024-12-10 07:23:09 -05:00
Louis Dionne
4c4606a743
[libc++] Add missing assertion in std::span constructor (#118396)
The (iterator, size) constructor should ensure that it gets passed a
valid range when the size is not 0.

Fixes #107789
2024-12-09 11:51:07 -05:00
Louis Dionne
10ef00faf1 [libc++][NFC] Run clang-format on test_allocator.h 2024-12-09 11:47:14 -05:00
Nikolas Klauser
ce7771902d
[libc++][C++03] Update include guards (#109001)
This patch updates the includes guards of the C++ 03 headers.

This is part of https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc.
2024-12-09 17:34:37 +01:00
Louis Dionne
c9009543ab
[libc++] Run the LLDB data formatter tests after libc++'s own tests (#119028)
It makes more sense to start testing libc++ with the latest compiler and
only then to run the LLDB data formatter tests, since that provides more
signal than starting with the data formatter tests.
2024-12-09 11:17:40 -05:00
Hui
f22ecdd9b9
[libc++] Move out flat_map::iterator (for reusing it in flat_multimap) (#117445) 2024-12-09 09:22:27 -05:00
Louis Dionne
0e34f3f496
[libc++] Extract a clean base support API for std::atomic (#118129)
This patch documents the underlying API for implementing atomics on a
platform.

This doesn't change the operations that std::atomic is based on, but it
reorganizes the C11 / GCC implementation split to make it clearer what's
the base support layer and what's not.
2024-12-09 09:14:17 -05:00
Louis Dionne
6cb339f9c1
[libc++] Refactor tests for aligned allocation and sized deallocation (#117915)
This patch refactors the tests around aligned allocation and sized
deallocation to avoid relying on passing the -fsized-deallocation or
-faligned-allocation flags by default. Since both of these features are
enabled by default in >= C++14 mode, it now makes sense to make that
assumption in the test suite.

A notable exception is MinGW and some older compilers, where sized
deallocation is still not enabled by default. We treat that as a "bug"
in the test suite and we work around it by explicitly adding
-fsized-deallocation, but only under those configurations.
2024-12-06 16:12:30 -05:00
Louis Dionne
cd74ebaec6
[libc++] Make a few test helper constructors explicit (#118975) 2024-12-06 15:31:20 -05:00
David Spickett
1bdb0a408f [libcxx] Add Maintainers.md file 2024-12-06 14:52:23 +00:00
Peng Liu
37797d3e80
[libc++][test] Fix and refactor exception tests for std::vector constructors (#117662)
The existing exceptions tests for `vector<T>` have several issues: some
tests did not throw exceptions at all, making them not useful for
exception-safety testing, and some tests did not throw exceptions at the
intended points, failing to serve their expected purpose. This PR fixes
those tests for vector's constructors. Morever, this PR extracted common
classes and utilities into a separate header file, and renamed those
classes using more descriptive names.
2024-12-06 09:03:17 -05:00
cmtice
384e69a914
[libc++] Add _LIBCPP_NODEBUG on internal allocator trait aliases (#118835)
Put _LIBCPP_NODEBUG on the new allocator trait aliases introduced in
https://github.com/llvm/llvm-project/pull/115654. This prevents a large
increase in the gdb_index size that was introduced by that PR.
2024-12-06 08:53:56 -05:00
serge-sans-paille
f7ff3cde96
[libc++] Fix sub-overflow in std::gcd implementation (#117984)
Fix #117249
2024-12-06 07:57:49 +00:00
Louis Dionne
2393ab65ed
[libc++] Fix unintended ABI break in associative containers with reference comparators (#118685)
While reference comparators are a terrible idea and it's not entirely
clear whether they are supported, fixing the unintended ABI break is
straightforward so we should do it as a first step.

Fixes #118559
2024-12-05 15:56:00 -05:00
Louis Dionne
e84f79e925 [libc++][docs] Use --show-all in the sample command-line to run benchmarks
It's really not useful at all to run benchmarks without --show-all since
you don't get the benchmark output. And since --show-all is the suggested
default way to run benchmarks, it's not necessary anymore to mention it
right below.
2024-12-05 15:52:02 -05:00
Peng Liu
a821937b6d
[libc++][test] Refactor increasing_allocator (#115671)
The increasing_allocator<T> class, originally introduced to test shrink_to_fit()
for std::vector, std::vector<bool>, and std::basic_string, has duplicated
definitions across several test files. Given the potential utility of this
class for capacity-related tests in various sequence containers, this patch
refactors the definition of increasing_allocator<T> into a single, reusable
location.
2024-12-05 15:44:05 -05:00
Louis Dionne
c8060423fe
[libc++] Drop dependency on __functional/operations.h from <atomic> (#117302)
This should reduce the preprocessed size of the atomic header and other
headers in the synchronization library.
2024-12-03 16:57:17 -05:00
Louis Dionne
3d437893c3
[libc++] Re-enable Clang-tidy checks in the CI (#110026)
Now that we've gained control of our CI docker image again,
we can re-enable the clang-tidy tests.
2024-12-02 14:26:28 -05:00
Louis Dionne
02eaeec1ac
[libc++] Remove obsolete CMake variable (#118119)
That variable is not referenced anywhere anymore, so it can be removed.
2024-12-02 13:57:18 -05:00
Louis Dionne
1b03747ed8
[libc++] Augment Github - CSV synchronization script to auto-create new Github issues (#118139)
This makes it easier to create the Github issues and add them to the
libc++ conformance project after a WG21 meeting.
2024-12-02 13:47:47 -05:00
Louis Dionne
582754280c [libc++][NFC] Fix slightly incorrect row in the CSV files 2024-12-02 11:52:43 -05:00
A. Jiang
c2950982fe
[libc++] Add Wroclaw straw polls (#118116) 2024-12-02 08:54:07 -05:00
Nikolas Klauser
04cc492ec3 [libc++][NFC] Remove unused macros from <__configuration/availability.h> 2024-11-30 13:18:33 +01:00
Louis Dionne
ae9b91acc7 [libc++] Fix malformed CSV entry for C++26 LWG issue 2024-11-29 16:03:40 -05:00
Louis Dionne
ef50d790c2 [libc++] Update run-buildbot-container with up-to-date image information 2024-11-29 12:10:45 -05:00