Commit Graph

4158 Commits

Author SHA1 Message Date
Brad Smith 21ef59a55e [libcxx] Replace remaining _LIBCPP_INLINE_VISIBILITY in __support
Replace remaining _LIBCPP_INLINE_VISIBILITY in __support with _LIBCPP_HIDE_FROM_ABI.

Reviewed by: Mordante

Differential Revision: https://reviews.llvm.org/D129922
2022-07-16 19:08:34 -04:00
Xing Xue d29c947732 [libc++][AIX] Correct the definition of __regex_word for AIX
Summary:
The patch changes the definition of __regex_word to 0x8000 for AIX because the current definition 0x80 clashes with ctype_base::print (_ISPRINT is defined as 0x80 in AIX ctype.h).

Reviewed by: Mordante, hubert.reinterpretcast, libc++

Differential Revision: https://reviews.llvm.org/D129862
2022-07-16 18:11:04 -04:00
Hui Xie 3151b95dad [libc++][ranges] implement `std::ranges::set_union`
[libc++][ranges] implement `std::ranges::set_union`

Differential Revision: https://reviews.llvm.org/D129657
2022-07-14 21:05:30 +01:00
David Tenty a83004f4ff [libcxx][AIX][z/OS] Remove headers included via `_IBMCPP__`
D127650 removed support for non-clang-based XL compilers, but left some
of the headers used only by this compiler and included under the
__IBMCPP__ macro. This change cleans this up by deleting these headers.

Reviewed By: hubert.reinterpretcast, fanbo-meng

Differential Revision: https://reviews.llvm.org/D129491
2022-07-14 15:41:46 -04:00
Nikolas Klauser 0a92e0728c [libc++] Use __unwrap_iter_impl for both unwrapping and rewrapping
Reviewed By: ldionne, #libc

Spies: arichardson, sstefan1, libcxx-commits

Differential Revision: https://reviews.llvm.org/D129039
2022-07-14 20:01:19 +02:00
Nikolas Klauser 64d63f4823 [libc++] Error if someone tries to use MSVC and tell them to contact the libc++ developers
Nobody knows if there are users of libc++ with MSVC. Let's try to find that out and encourage them to upstream their changes to make that configuration work.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D129055
2022-07-14 19:35:12 +02:00
Nikolas Klauser 0f050528fd [libc++] Allow setting _LIBCPP_OVERRIDABLE_FUNC_VIS
Chromium changes this flag to be able to use a custom new/delete from a
dylib.
2022-07-14 15:09:38 +02:00
Hui Xie a5c0638dec [libc++][ranges] implement `std::ranges::set_symmetric_difference`
[libc++][ranges] implement `std::ranges::set_symmetric_difference`

Differential Revision: https://reviews.llvm.org/D129520
2022-07-13 21:24:32 +01:00
Nikolas Klauser 101d1e9b3c [libc++] Implement ranges::find_end, ranges::search{, _n}
Reviewed By: var-const, #libc, huixie90

Spies: thakis, h-vetinari, huixie90, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D124079
2022-07-13 20:30:55 +02:00
Mark de Wever 6589729206 [libc++][format] Improves parsing speed.
A format string like "{}" is quite common. In this case avoid parsing
the format-spec when it's not present. Before the parsing was always
called, therefore some refactoring is done to make sure the formatters
work properly when their parse member isn't called.

From the wording it's not entirely clear whether this optimization is
allowed

[tab:formatter]
```
  and the range [pc.begin(), pc.end()) from the last call to f.parse(pc).
```
Implies there's always a call to `f.parse` even when the format-spec
isn't present. Therefore this optimization isn't done for handle
classes; it's unclear whether that would break user defined formatters.

The improvements give a small reduciton is code size:
 719408	  12472	    488	 732368	  b2cd0	before
 718824	  12472	    488	 731784	  b2a88	after

The performance benefits when not using a format-spec are:

```
Comparing ./formatter_int.libcxx.out-baseline to ./formatter_int.libcxx.out
Benchmark                                                               Time             CPU      Time Old      Time New       CPU Old       CPU New
----------------------------------------------------------------------------------------------------------------------------------------------------
BM_Basic<uint32_t>                                                   -0.0688         -0.0687            67            62            67            62
BM_Basic<int32_t>                                                    -0.1105         -0.1107            73            65            73            65
BM_Basic<uint64_t>                                                   -0.1053         -0.1049            95            85            95            85
BM_Basic<int64_t>                                                    -0.0889         -0.0888            93            85            93            85
BM_BasicLow<__uint128_t>                                             -0.0655         -0.0655            96            90            96            90
BM_BasicLow<__int128_t>                                              -0.0693         -0.0694            97            90            97            90
BM_Basic<__uint128_t>                                                -0.0359         -0.0359           256           247           256           247
BM_Basic<__int128_t>                                                 -0.0414         -0.0414           239           229           239           229
```

For the cases where a format-spec is used the results remain similar,
some are faster some are slower, differing per run.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D129426
2022-07-13 17:39:09 +02:00
Mark de Wever fd36a3d48d [libc++][chrono] Adds operator<=> for day.
Since the calendar classes were introduced in C++20 there's no need to
keep the old comparison operators.

This commit does the day calender class, the other calendar classes will
be in a followup commit.

Implements parts of:
- P1614R2 The mothership has landed

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D128603
2022-07-13 17:20:31 +02:00
Nikolas Klauser 1f04759316 Revert "[libc++] Implement ranges::find_end, ranges::search{, _n}"
This reverts commit 76a7651850.
2022-07-13 13:41:25 +02:00
Nikolas Klauser 76a7651850 [libc++] Implement ranges::find_end, ranges::search{, _n}
Reviewed By: var-const, #libc, huixie90

Spies: h-vetinari, huixie90, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D124079
2022-07-13 13:11:26 +02:00
Konstantin Varlamov 295b951ebc [lib++][ranges][NFC] Refactor `iterator_operations.h` to use tags.
Change the mechanism in `iterator_operations.h` to pass around a generic
policy tag indicating whether an internal function is being invoked from
a "classic" STL algorithm or a ranges algorithm. `IterOps` is now
a template class specialized on the policy tag.

The advantage is that this mechanism is more generic and allows defining
arbitrary conditions in a clean manner.

Also add a few more iterator functions to `IterOps`.

Differential Revision: https://reviews.llvm.org/D129390
2022-07-12 17:53:58 -07:00
David Tenty 4a009797ec [libc++][NFC] Add MVS guard for locale_mgmt_zos.h
This header need not be included on non-z/OS IBM platforms (and indeed
will add nothing when it is), so add a guard. This let's us remove the
header without things breaking when shipping libc++ for AIX.

Reviewed By: hubert.reinterpretcast, fanbo-meng

Differential Revision: https://reviews.llvm.org/D129493
2022-07-12 14:15:42 -04:00
Mark de Wever ef25db495b [libc++][chrono] Avoid tautological comparisions.
In our implementation the year is always less than or equal to the
class' `max()`. It's unlikely this ever changes since changing the
year's range will be an ABI break. A static_assert is added as a
guard.

This was reported by @philnik.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D129442
2022-07-12 19:15:24 +02:00
Konstantin Varlamov 73ebcabff2 [libc++][ranges][NFC] Implement the repetitive parts of the remaining range algorithms:
- create the headers (but not include them from `<algorithm>`);
- define the niebloid and its member functions with the right signatures
  (as no-ops);
- make sure all the right headers are included that are required by each
  algorithm's signature;
- update `CMakeLists.txt` and the module map;
- create the test files with the appropriate synopses.

The synopsis in `<algorithm>` is deliberately not updated because that
could be taken as a readiness signal. The new headers aren't included
from `<algorithm>` for the same reason.

Differential Revision: https://reviews.llvm.org/D129549
2022-07-12 02:48:31 -07:00
Raul Tambre 1544d1f9fd [libc++] Undeprecate ATOMIC_FLAG_INIT (LWG3659)
According to @aaron.ballman this was marked Tentatively Ready as of 2022-07-07.
D129362 implemented the C counterpart.

Reviewed By: ldionne, #libc, Mordante

Differential Revision: https://reviews.llvm.org/D129380
2022-07-12 08:00:40 +03:00
Hui Xie e90e7e70ef [libc++] Rename variables to use the snake case instead of camel case
For some reason the pre-commit CI of https://reviews.llvm.org/D129233 was all green so I didn't spot this
https://reviews.llvm.org/B174525

Reviewed By: #libc, philnik, Mordante

Differential Revision: https://reviews.llvm.org/D129503
2022-07-11 21:56:57 +02:00
Nikolas Klauser 7d426a392f [libc++] Implement ranges::{reverse, rotate}_copy
Reviewed By: var-const, #libc

Spies: huixie90, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D127211
2022-07-11 21:13:08 +02:00
Hui Xie 96b674f23c [libc++][ranges] implement `std::ranges::set_intersection`
implement `std::ranges::set_intersection` by reusing the classic `std::set_intersenction`
added unit tests

Differential Revision: https://reviews.llvm.org/D129233
2022-07-11 06:55:09 +01:00
Mark de Wever 606e280811 [libc++][format] Use forwarding references.
This implements a not accepted LWG issue. Not doing so would require
integral types to use the handle class instead of being directly stored
in the basic_format_arg.

The previous code used `std::forward` in places where it wasn't required
by the Standard. These are now removed.

Implements:
- P2418R2 Add support for std::generator-like types to std::format
- LWG 3631 basic_format_arg(T&&) should use remove_cvref_t<T> throughout

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D127570
2022-07-10 17:19:28 +02:00
Mark de Wever d55985789b [libc++][NFC] Update #ifdef comments.
These review comments weren't addressed in D129056.
2022-07-10 14:08:35 +02:00
Ivan Trofimov 3085e42f80 [libc++] Don't call key_eq in unordered_map/set rehashing routine
As of now containers key_eq might get called when rehashing happens, which is redundant for unique keys containers.

Reviewed By: #libc, philnik, Mordante

Differential Revision: https://reviews.llvm.org/D128021
2022-07-10 11:44:12 +02:00
Brad Smith 8e19a2b435 [libcxx] Uglify __support/musl
Uglify __support/musl

Reviewed By: philnik

Differential Revision: https://reviews.llvm.org/D129429
2022-07-09 18:01:21 -04:00
Brad Smith 865737581a [libcxx] Uglify __support/openbsd
Uglify __support/openbsd

Reviewed By: philnik

Differential Revision: https://reviews.llvm.org/D129412
2022-07-08 21:37:00 -04:00
Konstantin Varlamov c945bd0da6 [libc++][ranges] Implement modifying heap algorithms:
- `ranges::make_heap`;
- `ranges::push_heap`;
- `ranges::pop_heap`;
- `ranges::sort_heap`.

Differential Revision: https://reviews.llvm.org/D128115
2022-07-08 13:48:41 -07:00
Konstantin Varlamov 23c7328bad [libc++][ranges] Implement `ranges::nth_element`.
Differential Revision: https://reviews.llvm.org/D128149
2022-07-08 11:26:02 -07:00
Nikolas Klauser b48c5010a4 [libc++] Make parameter names consistent and enforce the naming style using readability-identifier-naming
Ensure that parameter names have the style `__lower_case`

Reviewed By: ldionne, #libc

Spies: aheejin, sstefan1, libcxx-commits, miyuki

Differential Revision: https://reviews.llvm.org/D129051
2022-07-08 18:17:47 +02:00
Louis Dionne d2e86866be [libc++] Re-apply the use of ABI tags to provide per-TU insulation
This commit re-applies 9ee97ce3b8, which was reverted by 61d417ce
because it broke the LLDB data formatter tests. It also re-applies
6148c79a (the manual GN change associated to it).

Differential Revision: https://reviews.llvm.org/D127444
2022-07-08 08:38:36 -04:00
Hui Xie 1cdec6c96e [libcxx][ranges] implement `std::ranges::set_difference`
implement `std::ranges::set_difference`
reused classic std::set_difference
added unit tests

Differential Revision: https://reviews.llvm.org/D128983
2022-07-08 13:26:23 +01:00
Jonas Devlieghere 61d417ceff
Revert "[libc++] Use ABI tags instead of internal linkage to provide per-TU insulation"
This reverts commit 9ee97ce3b8.
2022-07-07 08:58:55 -07:00
Mark de Wever 0857a02ef0 [libc++][format] Implements 128-bit support.
With to_chars supporting 128-bit it's possible to support the full
128-bit range in format. This only removes the previous restrictions
and updates the tests to validate proper support.

Depends on D128929.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D129007
2022-07-07 17:36:03 +02:00
Mark de Wever 3f78683353 [libc++] Implements 128-bit support in to_chars.
This is required by the Standard and makes it possible to add full
128-bit support to format.

The patch also fixes 128-bit from_chars "support". One unit test
required a too large value, this failed on 128-bit; the fix was to add
more characters to the input.

Note only base 10 has been optimized. Other bases can be optimized.

Note the 128-bit lookup table could be made smaller. This will be done later. I
really want to get 128-bit working in to_chars and format in the upcomming
LLVM 15 release, these optimizations aren't critical.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D128929
2022-07-07 17:32:27 +02:00
Mark de Wever 207e7e4a70 [libc++[format][NFC] Removes dead code.
This removes a part of the now obsolete formater code.
The removal also removes the _v2 suffix where it's no longer needed.

Depends on D128785

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D128846
2022-07-07 08:00:43 +02:00
Mark de Wever 152d922295 [libc++][format] Improve floating-point formatters.
This changes the implementation of the formatter. Instead of inheriting
from a specialized parser all formatters will use the same generic
parser. This reduces the binary size.

The new parser contains some additional fields only used in the chrono
formatting. Since this doesn't change the size of the parser the fields
are in the generic parser. The parser is designed to fit in 128-bit,
making it cheap to pass by value.

The new format function is a const member function. This isn't required
by the Standard yet, but it will be after LWG-3636 is accepted.
Additionally P2286 adds a formattable concept which requires the member
function to be const qualified in C++23. This paper is likely to be
accepted in the 2022 July plenary.

This is based on D125606. That commit did the groundwork and did similar
changes for the string formatters.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D128785
2022-07-07 08:00:05 +02:00
Louis Dionne 9ee97ce3b8 [libc++] Use ABI tags instead of internal linkage to provide per-TU insulation
Instead of marking private symbols with internal_linkage (which leads to
one copy per translation unit -- rather wasteful), use an ABI tag that
gets rev'd with each libc++ version. That way, we know that we can't have
name collisions between implementation-detail functions across libc++
versions, so we'll never violate the ODR. However, within a single program,
each symbol still has a proper name with external linkage, which means
that the linker is free to deduplicate symbols even across TUs.

This actually means that we can guarantee that versions of libc++ can
be mixed within the same program without ever having to take a code size
hit, and without having to manually opt-in -- it should just work out of
the box.

Differential Revision: https://reviews.llvm.org/D127444
2022-07-06 15:30:04 -04:00
Nikolas Klauser f8cbe3cdf0 [libc++] Implement ranges::remove{, _if}
Reviewed By: var-const, #libc

Spies: huixie90, sstefan1, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D128618
2022-07-06 18:47:13 +02:00
Nikolas Klauser 2040fde909 [libc++] Prefer __has_builtin for detecting compiler-provided type_traits
Both clang and GCC support using `__has_builtin` for detecting compiler-provided type_traits. Use it instead of `__has_keyword` or `__has_feature` to remove special-casing for GCC-provided builtins

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D129056
2022-07-06 13:33:50 +02:00
Nikolas Klauser 0d0bd17fcf [libc++] Fix __split_buffer::__construct_at_end definition to match declaration 2022-07-05 10:19:21 +02:00
Nikolas Klauser 00927334df [libc++] Use __is_exactly_{input, forward}_iterator
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D128646
2022-07-05 10:06:27 +02:00
Hui Xie 25607d143d [libc++] Implement `std::ranges::merge`
Implement `std::ranges::merge`. added unit tests

Differential Revision: https://reviews.llvm.org/D128611
2022-07-04 13:44:31 +01:00
Nikolas Klauser 4887d047a3 [libc++][NFC] Replace enable_if with __enable_if_t in a few places
Reviewed By: ldionne, #libc

Spies: jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D128400
2022-07-04 11:09:34 +02:00
Nikolas Klauser 2aea8af251 [libc++] Make _LIBCPP_DEBUG_RANDOMIZE_RANGE a function
Reviewed By: ldionne, Mordante, var-const, #libc

Spies: mgorny, libcxx-commits

Differential Revision: https://reviews.llvm.org/D128181
2022-07-03 18:03:44 +02:00
Konstantin Varlamov 94c7b89fe5 [libc++][ranges] Implement `ranges::stable_sort`.
Differential Revision: https://reviews.llvm.org/D127834
2022-07-01 16:34:26 -07:00
Nikolas Klauser adc0f5b3a6 [libc++] Remove dead code and unneeded C++03 specializations from type_traits
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D128906
2022-06-30 16:49:17 +02:00
Nikolas Klauser 3ee9a50a14 [libc++] Implement P0618R0 (Deprecating <codecvt>)
Reviewed By: ldionne, #libc

Spies: cfe-commits, llvm-commits, libcxx-commits

Differential Revision: https://reviews.llvm.org/D127313
2022-06-30 16:47:50 +02:00
Nikolas Klauser 44c8ef01ba [libc++] Disentangle _If, _Or and _And
Reviewed By: ldionne, #libc, EricWF

Spies: EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D127919
2022-06-30 14:01:10 +02:00
Michael Platings 9184002d66 Uglify __support/xlocale
This allows including the headers without risk of conflict with
user-defined macros e.g. max

Differential Revision: https://reviews.llvm.org/D128728
2022-06-30 11:45:29 +01:00
Mark de Wever ffe262a198 [libc++][format] Improve pointer formatters.
This changes the implementation of the formatter. Instead of inheriting
from a specialized parser all formatters will use the same generic
parser. This reduces the binary size.

The new parser contains some additional fields only used in the chrono
formatting. Since this doesn't change the size of the parser the fields
are in the generic parser. The parser is designed to fit in 128-bit,
making it cheap to pass by value.

The new format function is a const member function. This isn't required
by the Standard yet, but it will be after LWG-3636 is accepted.
Additionally P2286 adds a formattable concept which requires the member
function to be const qualified in C++23. This paper is likely to be
accepted in the 2022 July plenary.

This is based on D125606. That commit did the groundwork and did similar
changes for the string formatters.

Depends on D128139.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D128671
2022-06-29 08:39:42 +02:00