Commit Graph

10555 Commits

Author SHA1 Message Date
Louis Dionne
b356928058 [libc++] Fix the check-format job
Previously, it wouldn't take into account files in ignore_format.txt
(at least not on OSX) because the `find` command would return file names
like `libcxx/src//new_handler.cpp`, which never matched the file names
in `ignore_format.txt`.

Differential Revision: https://reviews.llvm.org/D153416
2023-06-21 17:59:32 -04:00
Louis Dionne
bcca95da5e [libc++] Refactor the selection of string's ABI in __config
This doesn't change the selection, but it expands the conditions to
add comments and make it clearer what's happening. It also removes a
-Wundef instance when we checked __ARM_ARCH_7K__ >= 2 without checking
that it is defined in the first place.

Differential Revision: https://reviews.llvm.org/D153413
2023-06-21 17:53:57 -04:00
Petr Hosek
037952f6d4 [libcxx] Include <sys/time.h> in posix_compat.h
posix_compat.h uses struct timeval which is defined in <sys/time.h>
but it doesn't include it. On most POSIX platforms like Linux or macOS,
that headers is transitively included by other headers like <sys/stat.h>,
but there are other platforms where this is not the case.

Differential Revision: https://reviews.llvm.org/D153384
2023-06-21 16:10:01 +00:00
Louis Dionne
afc5cca0d4 [libc++] Get rid of _LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS
Whether we include operator new and delete into libc++ has always
been a build time setting, and piggy-backing on a macro like
_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS is inconsistent with how
we handle similar cases for e.g. LIBCXX_ENABLE_RANDOM_DEVICE. Instead,
simply avoid including new.cpp in the sources of the library when we
do not wish to include these operators in the build.

This also makes us much closer to being able to share the definitions
between libc++ and libc++abi, since we could technically build those
definitions into a standalone static library and decide whether we link
it into libc++abi.dylib or libc++.dylib.

Differential Revision: https://reviews.llvm.org/D153272
2023-06-21 09:01:24 -04:00
Louis Dionne
9ff36c24a0 [libc++] Guard terminate_successful with TEST_HAS_NO_EXCEPTIONS
This one is a bit twisted. Some platforms don't have support for
exiting in a clean manner, so they don't provide std::exit(). As
a result, defining `terminate_successful()` on those platforms won't
work, and the PSTL tests that rely on `terminate_successful()` also
won't work.

However, we don't have a notion of "no clean termination" in libc++,
so we can't properly guard this. Since embedded platforms that don't
support clean termination usually also don't enable exceptions, we
don't need to be able to run those `terminate_successful` PSTL tests,
and guarding the definition of `terminate_successful` with
TEST_HAS_NO_EXCEPTIONS works pretty well.

This is kind of a hack for the lack of having a concept of "no clean
termination" in the library and in the test suite.

Differential Revision: https://reviews.llvm.org/D153302
2023-06-21 08:34:51 -04:00
Mark de Wever
48abcf11ad [libc++][format] Adds formattable-with concept.
This change has a few additional effects:
- Abstract classes are now formattable.
- Volatile objects are no longer formattable.

Implements
- LWG3631 basic_format_arg(T&&) should use remove_cvref_t<T> throughout
- LWG3925 Concept formattable's definition is incorrect

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D152092
2023-06-21 08:05:33 +02:00
Louis Dionne
333384c5bc [libc++][NFC] clang-format filesystem_error.h
It's giving me trouble in an upcoming patch so I figured I'd do it as
a NFC before landing that other patch.
2023-06-20 16:27:26 -04:00
Louis Dionne
5a6e6adb91 [libc++] Make sure our .clang-format is used for all languages
In particular, this ensures that it is used for Objective-C and
Objective-C++, since we have a few files that get detected as that.

Differential Revision: https://reviews.llvm.org/D153289
2023-06-20 15:00:53 -04:00
Mark de Wever
59f266d2e2 [chrono][test] Fixes some tests on Windows.
The tests switched from assert to TEST_EQUAL to make it easier to debug
assertion failures. This is used to fix most tests on Windows.

Some CI tests give no output, which needs to be investigated separately.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D152062
2023-06-20 19:35:38 +02:00
Mark de Wever
a5931e2c7b [libc++][format] Removes an AIX work-around.
This work-around was for Clang 13 and older, which we no longer support.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D152175
2023-06-20 19:31:08 +02:00
Mark de Wever
202054559c [libc++][test] Removes old fallbacks.
All supported compilers support the -std=year except Clang < 17 which
doesn't support C++23. This fallback is marked for removal once we no
longer support Clang 16.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D152106
2023-06-20 19:29:49 +02:00
Mark de Wever
09addf9cbe [libc++][format] Fixes UTF-8 continuation.
The mask used to check whether a code unit is a valid continuation was
incorrect and accepts non-continuation code points. This fixes the
issue.

Reviewed By: ldionne, tahonermann, #libc

Differential Revision: https://reviews.llvm.org/D149672
2023-06-20 19:28:02 +02:00
Mark de Wever
f5b82022ff [libc++][CI] Install newer CMake version.
This version allowed testing the std module in C++26 mode.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D153227
2023-06-20 19:20:08 +02:00
Louis Dionne
c20d81bd63 [libc++] Add missing [[maybe_unused]] attribute in format tests
Otherwise, Clang complains about format_ctx being unused in the tests
when exceptions are disabled in Freestanding mode. I don't know why it
doesn't complain not in freestanding mode.

Differential Revision: https://reviews.llvm.org/D153301
2023-06-20 11:25:01 -04:00
Mark de Wever
ffe0495105 [NFC][libc++] Addresses LWG3927.
Changes to preconditions have no impact on the library.

Implements
- LWG3927 Unclear preconditions for operator[] for sequence containers

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153286
2023-06-20 17:19:55 +02:00
Mark de Wever
946116fc05 [NFC][libc++] Addresses LWG3935.
Note libc++ implemented this in its initial version.

Implements
- LWG3935 template<class X> constexpr complex& operator=(const complex<X>&) has no specification

Reviewed By: #libc, philnik, ldionne

Differential Revision: https://reviews.llvm.org/D153287
2023-06-20 17:16:06 +02:00
Louis Dionne
2da049a141 [libc++] Add incomplete availability markup for std::pmr
This fixes rdar://110330781, which asked for the feature-test macro
for std::pmr to take into account the deployment target. It doesn't
fix https://llvm.org/PR62212, though, because the availability markup
itself must be disabled until some Clang bugs have been fixed.

This is pretty vexing, however at least everything should work once
those Clang bugs have been fixed. In the meantime, this patch at least
adds the required markup (as disabled) and ensures that the feature-test
macro for std::pmr is aware of the deployment target requirement.

Differential Revision: https://reviews.llvm.org/D135813
2023-06-20 10:59:05 -04:00
Louis Dionne
3350ec9b3e [libc++] Add missing 'return 0' from main functions in tests 2023-06-19 13:43:34 -04:00
Louis Dionne
1288e72d10 [libc++][NFC] Sort header list in header_information.py 2023-06-19 11:54:04 -04:00
Louis Dionne
5aa03b648b [libc++][NFC] Apply clang-format on large parts of the code base
This commit does a pass of clang-format over files in libc++ that
don't require major changes to conform to our style guide, or for
which we're not overly concerned about conflicting with in-flight
patches or hindering the git blame.

This roughly covers:
- benchmarks
- range algorithms
- concepts
- type traits

I did a manual verification of all the changes, and in particular I
applied clang-format on/off annotations in a few places where the
result was less readable after than before. This was not necessary
in a lot of places, however I did find that clang-format had pretty
bad taste when it comes to formatting concepts.

Differential Revision: https://reviews.llvm.org/D153140
2023-06-19 11:19:51 -04:00
Mark de Wever
f805c799bf [libc++] "Implements" new SI prefixis.
Like yocto, zepto, zetta, and yotta. The new prefixes quecto, ronto,
ronna, and quetta can't be implemented in a intmax_t. So their
implementation does nothing.

Implements
- P2734R0 Adding the new SI prefixes

Depends on D153192

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153200
2023-06-19 17:04:35 +02:00
Mark de Wever
cdcfc5ec9b [libc++][regex] Removes operator!=.
Implements part of:
- P1614R2 The Mothership has Landed

Reviewed By: #libc, H-G-Hristov, philnik

Differential Revision: https://reviews.llvm.org/D153222
2023-06-19 17:01:56 +02:00
Mark de Wever
a4f0764aef [libc++] Marks __cpp_lib_bitops as implemented.
This FTM was introduced in
  P0553R4 Bit operations

Which has been implemented since libc++ 9.

This was noticed while working on D153192.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153225
2023-06-19 17:01:27 +02:00
Mark de Wever
3f05d044f4 [libc++] Update status after Varna meeting.
This updates:
- The status tables
- Feature test macros
- New headers for modules
The latter avoids forgetting about modules when implementing the feature
in a new header.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153192
2023-06-19 16:55:30 +02:00
Louis Dionne
3956a34e4f [libc++] Move non operator new definitions outside of new.cpp
This makes it such that new.cpp contains only the definitions of
operator new and operator delete, like its libc++abi counterpart.

Differential Revision: https://reviews.llvm.org/D153136
2023-06-19 09:46:40 -04:00
Louis Dionne
c7d3c84449 [libc++] Split sources for <filesystem>
The operations.cpp file contained the implementation of a ton of
functionality unrelated to just the filesystem operations, and
filesystem_common.h contained a lot of unrelated functionality as well.

Splitting this up into more files will make it possible in the future
to support parts of <filesystem> (e.g. path) on systems where there is
no notion of a filesystem.

Differential Revision: https://reviews.llvm.org/D152377
2023-06-19 09:07:05 -04:00
Louis Dionne
dc71a77d33 [libc++][NFC] Move several .fail.cpp tests to .verify.cpp
A few tests were also straightforward to translate to SFINAE tests
instead, so in a few cases I did that and removed the .fail.cpp test
entirely.

Differential Revision: https://reviews.llvm.org/D153149
2023-06-19 09:06:13 -04:00
Louis Dionne
d8655fb365 [libc++][NFC] Rename __lower_bound_impl to __lower_bound
For consistency with other algorithms.

Differential Revision: https://reviews.llvm.org/D153141
2023-06-19 09:05:14 -04:00
Hristo Hristov
0dda8691b2 [libc++][ranges] Mark views::stride in progress 2023-06-19 11:48:12 +03:00
Hristo Hristov
4f7680ceda [libc++][spaceship][NFC] P1612R2: Mark remove operator!= from "Ranges Library" items as "Complete"
Marked already implemented parts of P1612R2 as "Complete":
- `ranges::iota_view::iterator` https://reviews.llvm.org/D110774
- `iota_view::sentinel` https://reviews.llvm.org/D107396
- `filter_view::iterator` https://reviews.llvm.org/D109086
- `filter_view::sentinel` https://reviews.llvm.org/D109086
- `ranges::transform_view::iterator` https://reviews.llvm.org/D110774
- `transform_view::sentinel` https://reviews.llvm.org/D103056
- `take_view::sentinel` https://reviews.llvm.org/D123600
- `join_view::iterator` https://reviews.llvm.org/D107671
- `join_view::sentinel ` https://reviews.llvm.org/D107671
- `split_view::outer_iterator` https://reviews.llvm.org/D142063
- `split_view::inner_iterator` https://reviews.llvm.org/D142063

Note these operators were added and removed in C++20.

Reviewed By: Mordante, #libc

Differential Revision: https://reviews.llvm.org/D152721
2023-06-18 21:18:40 +03:00
Hui
cea4285949 [libc++][NFC] Granularise <thread> header
- This was to make implementing jthread easier and requested in https://reviews.llvm.org/D151559

Differential Revision: https://reviews.llvm.org/D151792
2023-06-17 12:28:52 +01:00
Louis Dionne
100cb5bacc [libc++] Fix signedness comparison issue on GCC in a test 2023-06-16 13:30:58 -04:00
Mark de Wever
b72a7cb320 [libc++][doc] Move not yet adopted issues to C++26.
The development of C++23 is complete, so these issues will be adopted in
C++26 (or later).

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153053
2023-06-16 17:39:08 +02:00
Nikolas Klauser
31eeba3f7c [libc++] Introduce __make_uninitialized_buffer and use it instead of get_temporary_buffer
This will also be used in some PSTL backends.

Reviewed By: ldionne, #libc, Mordante

Spies: arichardson, mstorsjo, Mordante, sstefan1, jplehr, libcxx-commits

Differential Revision: https://reviews.llvm.org/D152208
2023-06-16 07:53:56 -07:00
Louis Dionne
5e73fda53c [libc++][NFC] Consistently qualify malloc and free calls with std:: 2023-06-16 09:40:31 -04:00
Louis Dionne
d53cf0fdd1 [libc++] Make libc++ and libc++abi's definitions of operator new be exact copies
This allows mechanically copying any changes made to `operator new`
from libc++ into libc++abi as-is. This is also a step towards
de-duplicating this code entirely.

Differential Revision: https://reviews.llvm.org/D153035
2023-06-16 09:40:08 -04:00
Louis Dionne
f7679bcfb6 [libc++][NFC] Reformat params.py
After the Black reformatting changes, the code became pretty hard to
read and inconsistently formatted. This fixes that.

Differential Revision: https://reviews.llvm.org/D152839
2023-06-15 14:46:14 -04:00
Nikolas Klauser
3a7876f6e2 [libc++][PSTL] Implement std::is_partitioned
Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D152853
2023-06-15 11:23:07 -07:00
Nikolas Klauser
b935ab8e74 [libc++] Add tests to make sure that stable algorithms work without memory available
Reviewed By: #libc, ldionne

Spies: power-llvm-team, ldionne, libcxx-commits, arichardson, mstorsjo

Differential Revision: https://reviews.llvm.org/D152939
2023-06-15 10:59:34 -07:00
Mark de Wever
9b08c8a225 [libc++][modules] Adds the C++23 std module.
The patch is based on D144994.

D151030 added the module definitions for the module std.
This patch wires in the module and enables the basic testing.

Some notable features are missing:
- There is no test that libc++ can be fully imported as a module.
- This lacks the parts for the std.compat module.
- The module is not shipped with libc++.

Implements parts of
- P2465R3 Standard Library Modules std and std.compat

Reviewed By: ldionne, aaronmondal, #libc

Differential Revision: https://reviews.llvm.org/D151814
2023-06-15 18:14:15 +02:00
Mark de Wever
6551e59802 [libc++][modules] Update the .cppm files.
There are some minor fixes in the definiton and it is synced with
upstream changes.

This has been reviewed as part of D151814.
2023-06-15 18:12:06 +02:00
Nikolas Klauser
f1ea0b11ca [libc++] Merge _LIBCPP_FUNC_VIS, _LIBCPP_TYPE_VIS and _LIBCPP_EXCEPTION_ABI into _LIBCPP_EXPORTED_FROM_ABI
These macros are always defined identically, so we can simplify the code a bit by merging them.

Reviewed By: ldionne, #libc

Spies: libcxx-commits, krytarowski, smeenai

Differential Revision: https://reviews.llvm.org/D152652
2023-06-15 08:56:45 -07:00
Louis Dionne
fa90e2b988 [libc++] Don't automatically define LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS with libcxxrt
libcxxrt is only used on FreeBSD and the FreeBSD CMake cache already
sets LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS to ON, as it should. This
avoids defining LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS redundantly in
a place where it doesn't belong.

Differential Revision: https://reviews.llvm.org/D152971
2023-06-15 11:23:45 -04:00
Louis Dionne
aee3a9f5bc [libc++][NFC] clang-format new_handler.cpp 2023-06-15 11:14:26 -04:00
Louis Dionne
80e4ccab79 [libc++] Move the definition of std::new_handler out of new.cpp
This reduces the difference between libc++'s new.cpp and libc++abi's
stdlib_new_delete.cpp files, which are essentially copies of each other.

Differential Revision: https://reviews.llvm.org/D152956
2023-06-15 11:14:14 -04:00
Hristo Hristov
e7e36d56d6 [libc++][ranges][NFC] Status page: Adds views::enumerate 2023-06-15 00:53:15 +03:00
Hristo Hristov
9838dd7f76 [libc++][spaceship][NFC] P1614R2: Status page - mark header synopsis sections as "Complete"
Header synospis sections of P1614R2 are implemented by other items usually. For completeness, let's mark some of them as "Complete".

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D152775
2023-06-15 00:28:10 +03:00
Louis Dionne
3456b2f60a [libc++] Refactor __debug_three_way_comp
This makes __debug_three_way_comp consistent with __debug_less and
in particular gets rid of a potential use-after-move caused by the
use of std::forward. In the previous version of the code, we would
call `__do_compare_assert` after forwarding the arguments into the
comparator, which could end up using the arguments after they've been
moved from.

This also simplifies how we call `__do_compare_assert` by using
`if constexpr` and adds a missing test for proxy iterators in
lexicographical_compare_three_way, which could have found this
issue.

Differential Revision: https://reviews.llvm.org/D152753
2023-06-13 14:24:56 -07:00
Louis Dionne
52310ce9c1 [libc++][NFC] Reformat features.py
This file was reformatted using the Black tool, which led to entirely
unreadable code due to how lines are broken. Formatting tools are fine,
but not when they lead to code that humans have trouble reading. In the
case of features.py, a lot of it was meant to be aligned in a repetitive
but consistent way to make the structure of the code stand out.
Reformatting with the tool lost that property.

Differential Revision: https://reviews.llvm.org/D152737
2023-06-13 10:24:46 -07:00
Louis Dionne
520c7fbbd0 [libc++] Mark slow tests as unsupported on GCC
Some tests in our test suite are unbelievably slow on GCC due to the
use of the always_inline attribute. See [1] for more details.

This patch introduces the GCC-ALWAYS_INLINE-FIXME lit feature to
disable tests that are plagued by that issue. At the same time, it
moves several existing tests from ad-hoc `UNSUPPORTED: gcc-12` markup
to the new GCC-ALWAYS_INLINE-FIXME feature, and marks the slowest tests
reported by the CI as `UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME`.

[1]: https://discourse.llvm.org/t/rfc-stop-supporting-extern-instantiations-with-gcc/71277/1

Differential Revision: https://reviews.llvm.org/D152736
2023-06-13 10:20:30 -07:00