1503 Commits

Author SHA1 Message Date
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
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
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
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
Louis Dionne
ae9b91acc7 [libc++] Fix malformed CSV entry for C++26 LWG issue 2024-11-29 16:03:40 -05:00
Nikolas Klauser
59716479fc
[libc++] Add coding guidelines to the docs (#117051)
We have a buch of coding guidelines which are either documented as
design docs, which aren't really applicable or not at all. This moves
coding guidelines we have currently in the design docs into a separate
file and adds a bunch of guidelines which we have but aren't documented
anywhere.
2024-11-28 23:06:28 +01:00
Peng Liu
056153f36e
Optimize vector::assign for InputIterator-only pair inputs (#113852)
This PR optimizes the input iterator overload of `assign(_InputIterator,
_InputIterator)` in `std::vector<_Tp, _Allocator>` by directly assigning
to already initialized memory, rather than first destroying existing
elements and then constructing new ones. By eliminating unnecessary
destruction and construction, the proposed algorithm enhances the
performance by up to 2x for trivial element types (e.g.,
`std::vector<int>`), up to 2.6x for non-trivial element types like
`std::vector<std::string>`, and up to 3.4x for more complex non-trivial
types (e.g., `std::vector<std::vector<int>>`).

###  Google Benchmarks

Benchmark tests (`libcxx/test/benchmarks/vector_operations.bench.cpp`)
were conducted for the `assign()` implementations before and after this
patch. The tests focused on trivial element types like
`std::vector<int>`, and non-trivial element types such as
`std::vector<std::string>` and `std::vector<std::vector<int>>`.



#### Before
```
-------------------------------------------------------------------------------------------------
Benchmark                                                       Time             CPU   Iterations
-------------------------------------------------------------------------------------------------
BM_AssignInputIterIter/vector_int/1024/1024                  1157 ns         1169 ns       608188
BM_AssignInputIterIter<32>/vector_string/1024/1024          14559 ns        14710 ns        47277
BM_AssignInputIterIter<32>/vector_vector_int/1024/1024      26846 ns        27129 ns        25925
```


#### After
```
-------------------------------------------------------------------------------------------------
Benchmark                                                       Time             CPU   Iterations
-------------------------------------------------------------------------------------------------
BM_AssignInputIterIter/vector_int/1024/1024                   561 ns          566 ns      1242251
BM_AssignInputIterIter<32>/vector_string/1024/1024           5604 ns         5664 ns       128365
BM_AssignInputIterIter<32>/vector_vector_int/1024/1024       7927 ns         8012 ns        88579
```
2024-11-28 20:52:59 +01:00
Nikolas Klauser
6cbc37383f
[libc++] Remove the pointer safety functions from the dylib (#117390)
The pointer safety functions were never implemented by anyone in a
non-trivial way, which lead us to removing them entirely from the
headers when they were removed in C++23. This also means that just about
nobody ever called these functions, especially not in production code.
Because of that, we expect there to be no references in the wild to the
functions in the dylib. Because of that, this patch removes the symbols
from the dylib.
2024-11-28 15:36:05 +01:00
Louis Dionne
afae1a5f32
[libc++] Remove _LIBCPP_DISABLE_AVAILABILITY macro (#112952)
This was slated for removal years ago, so now's a good time to remove it.
2024-11-23 20:02:15 -05:00
h-vetinari
99f44c8fed
[libc++] update comment for P0067R5 (#113239)
Fix review comment from #91651 that was not addressed.
2024-11-12 10:57:08 -05:00
Alona Enraght-Moony
0a7e5e3456
[libc++][docs] Document _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION (#115405)
This was added in 681cde7dd8b5613dbafc9ca54e0288477f946be3, but isn't
currently documented.
2024-11-08 12:35:31 +01:00
Louis Dionne
427a5cf105
[libc++] Add support for bounded iterators in std::array (#110729)
This patch introduces a new kind of bounded iterator that knows the size
of its valid range at compile-time, as in std::array. This allows computing
the end of the range from the start of the range and the size, which requires
storing only the start of the range in the iterator instead of both the start
and the size (or start and end). The iterator wrapper is otherwise identical
in design to the existing __bounded_iter.

Since this requires changing the type of the iterators returned by
std::array, this new bounded iterator is controlled by an ABI flag.

As a drive-by, centralize the tests for std::array::operator[] and add
missing tests for OOB operator[] on non-empty arrays.

Fixes #70864
2024-11-07 09:23:21 -05:00
Louis Dionne
e236a52a88
[libc++] Unify the benchmarks with the test suite (#101399)
Instead of building the benchmarks separately via CMake and running them
separately from the test suite, this patch merges the benchmarks into
the test suite and handles both uniformly.

As a result:
- It is now possible to run individual benchmarks like we run tests
  (e.g. using libcxx-lit), which is a huge quality-of-life improvement.

- The benchmarks will be run under exactly the same configuration as
  the rest of the tests, which is a nice simplification. This does
  mean that one has to be careful to enable the desired optimization
  flags when running benchmarks, but that is easy with e.g.
  `libcxx-lit <...> --param optimization=speed`.

- Benchmarks can use the same annotations as the rest of the test
  suite, such as `// UNSUPPORTED` & friends.

When running the tests via `check-cxx`, we only compile the benchmarks
because running them would be too time consuming. This introduces a bit
of complexity in the testing setup, and instead it would be better to
allow passing a --dry-run flag to GoogleBenchmark executables, which is
the topic of https://github.com/google/benchmark/issues/1827.

I am not really satisfied with the layering violation of adding the
%{benchmark_flags} substitution to cmake-bridge, however I believe
this can be improved in the future.
2024-11-07 09:07:50 -05:00
Nikolas Klauser
c6f3b7bcd0
[libc++] Refactor the configuration macros to being always defined (#112094)
This is a follow-up to #89178. This updates the `<__config_site>`
macros.
2024-11-06 10:39:19 +01:00
A. Jiang
76b71c0bc4
[libc++] Set __cpp_lib_smart_ptr_for_overwrite (#114700)
The features were implemented in LLVM 16, but mistakenly considered
unimplemented in FTM tools.
2024-11-05 13:27:40 +08:00
h-vetinari
8b19d29a3f
[libc++] remove minor version in status pages (#113241)
Minor version of releases starts at `N.1.0` for all releases since 4532617ae42005.

The current status pages are not terribly wrong (the version during
development can be considered `N.0`), but still it's kinda weird to use
versions that never get released as the lower bound.
2024-11-04 10:48:50 -05:00
Louis Dionne
dfe737f231
[libc++] Apply post-commit review comments for unique_ptr<T[]> hardening (#111704) 2024-11-04 10:45:12 -05:00
A. Jiang
63eb40eeb1
[libc++] Deprecate and remove meaningless <cxxx> headers (#111615)
This PR deprecates `<ccomplex>`, `<cstdbool>`, `<ctgmath>`, and
`<ciso646>` in C++17 and "removes" them in C++20 by special deprecation
warnings.

`<cstdalign>` is previously missing. This PR also tries to add them, and
then deprecates and "removes" `<cstdalign>`.

Papers:
- https://wg21.link/P0063R3
- https://wg21.link/P0619R4

Closes #99985.

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2024-10-30 09:49:26 +08:00
Louis Dionne
c9d9dc9c24
[libc++] Remove _LIBCPP_ENABLE_ASSERTIONS, which had been deprecated (#113592) 2024-10-29 10:48:18 -04:00
Hui
0be1883c36
[libc++] Implement P0429R9 std::flat_map (#98643)
Around half of the tests are based on the tests Arthur O'Dwyer's
original implementation of std::flat_map, with modifications and
removals.

partially implement #105190
2024-10-26 18:58:53 +01:00
A. Jiang
cae351f345
[libc++] Bump __cpp_lib_optional and __cpp_lib_variant (#113650)
In C++20 mode, `__cpp_lib_optional` and `__cpp_lib_variant` should be
`202106L` due to DR P2231R1.

In C++26 mode, `__cpp_lib_variant` should be bumped to `202306L` due to
P2637R3.
- Clang 16/17 shouldn't get this bumping (as member `visit` requires
explicit object parameters), but it's very tricky to make the bumping
conditionally enabled. I _hope_ unconditionally bumping in C++26 will be
OK for LLVM 20 when the support for Clang 17 is dropped.

Related PRs:
- https://reviews.llvm.org/D102119
- #83335
- #76447
2024-10-26 07:38:52 +08:00
Louis Dionne
d269ec321d
[libc++] Add a escape hatch for making __libcpp_verbose_abort non-noexcept again (#113310)
This allows a slightly smoother transition for people after #109151, as
requested on that PR.
2024-10-23 17:07:15 -04:00
Xiaoyang Liu
7c721999ca
[libc++][ranges] LWG4016: container-insertable checks do not match what container-inserter does (#113103)
This patch implements LWG4016: container-insertable checks do not match
what container-inserter does.
2024-10-23 10:04:50 -04:00
ZhangYin
2c3d7d5322
[libc++] <experimental/simd> Add unary operators for class simd (#104764) 2024-10-23 12:26:48 +08:00
Michael Jones
6c4267fb17
[libcxx][libc] Hand in Hand PoC with from_chars (#91651)
Implements std::from_chars for float and double.

The implementation uses LLVM-libc to do the real parsing. Since this is
the first time libc++
uses LLVM-libc there is a bit of additional infrastructure code. The
patch is based on the
[RFC] Project Hand In Hand (LLVM-libc/libc++ code sharing)

https://discourse.llvm.org/t/rfc-project-hand-in-hand-llvm-libc-libc-code-sharing/77701
2024-10-21 15:04:06 -07:00
A. Jiang
397707f718
[libc++] __uglify non-conforming member typedef base (#112843)
Currently, libc++'s `bitset`, `forward_list`, and `list` have
non-conforming member typedef name `base`. The typedef is private, but
can cause ambiguity in name lookup.

Some other classes in libc++ that are either implementation details or
not precisely specified by the standard also have member typdef `base`.
I think this can still be conforming.

Follows up #80706 and #111127.
2024-10-18 23:27:12 +08:00
Louis Dionne
e67442486d
[runtimes] Improve the documentation for LIBCXX_ADDITIONAL_COMPILE_FLAGS (#112733)
This clarifies how that option is meant to be used to avoid confusion.
As a drive-by, also fix an incorrect usage in the recently-added GPU
caches.
2024-10-17 16:17:40 -04:00
Doug Wyatt
954836634a
[libc++] Make __libcpp_verbose_abort() noexcept like std::terminate() (#109151)
Make __libcpp_verbose_abort() noexcept (it is already noreturn), to
match std::terminate(). Clang's function effect analysis can use this to
ignore such functions as being beyond its scope. (See
https://github.com/llvm/llvm-project/pull/99656).
2024-10-17 10:38:29 -04:00
A. Jiang
cbe03646c6
[libc++][ranges] LWG3692: zip_view::iterator's operator<=> is overconstrained and changes of zip_view in P2165R4 (#112077)
The changes are nearly pure simplifications, so I think it's OK to do
them together in the same PR.

Actual test coverages were already added in commit ad41d1e26b12
(https://reviews.llvm.org/D141216). Thanks to Casey Carter!

Fixes #104975
Towards #105200
2024-10-16 09:34:31 -04:00
Adrian Vogelsgesang
7e16571eb0
[lldb][libc++] Hide all libc++ implementation details from stacktraces (#108870)
This commit changes the libc++ frame recognizer to hide implementation
details of libc++ more aggressively. The applied heuristic is rather
straightforward: We consider every function name starting with `__` as
an implementation detail.

This works pretty neatly for `std::invoke`, `std::function`,
`std::sort`, `std::map::emplace` and many others. Also, this should
align quite nicely with libc++'s general coding convention of using the
`__` for their implementation details, thereby keeping the future
maintenance effort low.

However, this heuristic by itself does not work in 100% of the cases:
E.g., `std::ranges::sort` is not a function, but an object with an
overloaded `operator()`, which means that there is no actual call
`std::ranges::sort` in the call stack. Instead, there is a
`std::ranges::__sort::operator()` call. To make sure that we don't hide
this stack frame, we never hide the frame which represents the entry
point from user code into libc++ code
2024-10-10 19:27:27 +02:00
A. Jiang
159d694c05
[libc++] __uglify internal member names of iterators in bitset (#111127)
[template.bitset.general] indicates that `bitset` shouldn't have member
typedef-names `iterator` and `const_iterator`. Currently libc++'s
typedef-names are causing ambiguity in name lookup, which isn't
conforming.

As these iterator types are themselves useful, I think we should just
use __uglified member typedef-names for them.

Fixes #111125
2024-10-10 09:14:05 -04:00
Hristo Hristov
a06591b4d4
[libc++][type_traits] P2674R1: A trait for implicit lifetime types (#106870)
Implements P2674R1: https://wg21.link/P2674R1

- https://eel.is/c++draft/type.traits
  - https://eel.is/c++draft/meta.type.synop
  - https://eel.is/c++draft/meta.unary.prop
- https://eel.is/c++draft/support.limits
  - https://eel.is/c++draft/version.syn

Implementation details:
- Uses compiler intrinsic `__builtin_is_implicit_lifetime`:
  - https://github.com/llvm/llvm-project/pull/101807
- Tests based on:
-
d213981c80/clang/test/SemaCXX/type-traits.cpp (L1989)

References:
- Implicit-lifetime
- Implicit-lifetime types [basic.types.general]/9:
https://eel.is/c++draft/basic.types.general
- Implicit-lifetime class [class.prop]/9:
https://eel.is/c++draft/class.prop
- P0593R6 Implicit creation of objects for low-level object
manipulation: https://wg21.link/P0593R6
- P1010R1 Container support for implicit lifetime types:
https://wg21.link/P1010R1
- P0593R6 Implicit creation of objects for low-level object
manipulation: https://wg21.link/P0593R6

Closes: #105259

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
2024-10-09 08:19:14 +02:00
Louis Dionne
5c88aa9d34
[libc++] Document the de-facto status of compiler extension support (#110877)
This was brought up in a maintainer's meeting a few months ago. This
simply documents the current status quo.
2024-10-07 17:27:29 -04:00
A. Jiang
19c6958d24
[libc++] Re-apply LWG3870: Remove voidify (#110944)
This reverts commit f3d58f4161b86a479f68acb453e9622911c688a0.

Relands #110355.
2024-10-03 08:28:26 -04:00
A. Jiang
557f7e1398
[libc++] P2167R3: Improved Proposed Wording for LWG 2114 (#109102)
Only the [cmp.alg] part (for `comparison_meow_fallback` CPOs) in the
paper required changes. Other parts merely fixed preconditions of some
standard library functions.

I strongly feel that P2167R3 should be a DR despite that it is not a DR
officially: CPOs -> C++20; remain parts -> C++98/11 (except that
_`boolean-testable`_ should be transformed into the original
_BooleanTestable_ requirements in the old resolution of LWG2114).

Note that P2167R3 damaged the resolution of LWG3465: the type of `F < E`
was left underconstrained. I've tried to submit an LWG issue for this,
which is now LWG4157.

Drive-by change:
- enable some test coverages in `compare_strong_order_fallback.pass.cpp`
when `TEST_LONG_DOUBLE_IS_DOUBLE`, following up #106742

Closes #105241.
2024-10-03 01:09:53 +08:00
Louis Dionne
8805ff72a0
[libc++] Mark LWG3317 as complete in LLVM 16 (#110757)
This was fixed in 719c3dc6f2f7 and landed in LLVM 16.

Closes #100429
2024-10-02 09:00:41 -04:00
Michael Buch
f3d58f4161
Revert "[libc++] LWG3870: Remove voidify (#110355)" (#110587)
This reverts commit 78f9a8b82d772ff04a12ef95f2c9d31ee8f3e409.

This caused the LLDB test `TestDataFormatterGenericOptional.py` to fail, and we need
a bit more time to look into it.
2024-10-01 08:57:03 -04:00
A. Jiang
78f9a8b82d
[libc++] LWG3870: Remove voidify (#110355)
Instead of changing the cast sequence to implicit conversion in
_`voidify`_, I think it is better to totally remove `__voidify` and use
`static_cast` to `void*`, which has equivalent effects.

Test coverage for const iterators are removed.

Now most affected algorithms are underconstrained, for which I submitted
[LWG3888](https://cplusplus.github.io/LWG/issue3888). I'm not sure
whether we should speculatively implement it at this moment, and thus
haven't added any `*.verify.cpp`.

In some control block types and `optional`, the stored objects are
changed to have cv-unqualified type.

Fixes #105119.
2024-10-01 01:24:00 +08:00
Xiaoyang Liu
51259deb72
[libc++] LWG4025: Move assignment operator of std::expected<cv void, E> should not be conditionally deleted (#109363)
This patch implements LWG4025: Move assignment operator of
`std::expected<cv void, E>` should not be conditionally deleted.

Closes #105324
2024-09-27 12:54:22 -04:00
Xiaoyang Liu
1693c63922
[libc++][NFC] mark LWG3723 as implemented (#109356)
This patch marks LWG3723 as implemented, with the implementation
completed in commit 87f3ff3 and released in `libc++` 17.0.

Closes #105104
2024-09-23 13:45:45 -04:00
Jakub Mazurkiewicz
698be40a51
[libc++] Follow-up to "Poison Pills are Too Toxic" (#88383)
Update the LLVM 19 release notes and the C++23 status
to mention that we implemented this as a DR in C++20.
2024-09-19 10:21:07 -04:00
Hristo Hristov
12b88f835d
[libc++][NFC] Mark P1424R1 as partially implemented (#107751)
`hh_mm_ss` and related functions from https://wg21.link/P1466R3 were
partially implemented in LLVM 10 (fde236b1f719b3a).
2024-09-17 13:04:02 -04:00
Hristo Hristov
6f5dd65630
[libc++][docs] Fix inline code style - use double backticks (#108974)
This is an apparrent omission. Single backick (Markdown style) was used
instead of double backtick for inline code style.
2024-09-17 11:12:44 -04:00
A. Jiang
2d13302d38
[libc++][test] Confirm that P0508R0 has been implemented (#108172)
The paper was implemented by commit b0386a515b60c
(https://reviews.llvm.org/D46845) in LLVM 7.0. But it would be nice to
have test coverage for desired properties of `insert_return_type`.

Closes #99944
2024-09-16 15:34:40 -04:00
Hristo Hristov
397e4dcdc9
[libc++][docs] Add link to VendorDocumentation.rst from TestingLibcxx.rst (#108714)
This makes it easier for readers to locate how to build the library.
2024-09-16 15:34:02 -04:00
Nikolas Klauser
01df775dc4
[libc++] Take the ABI break for std::list's pointer UB unconditionally (#100585)
This ABI break only affects fancy pointer which have a different value
representation when pointing to a base of T instead of T itself. This
seems like a rather small set of fancy pointers, which themselves
already represent a very small niche. This patch swaps a pointer to T
with a pointer to base of T in a few library-internal types.
2024-09-16 11:55:33 -04:00
A. Jiang
94e7c0b051
[libc++] Remove get_temporary_buffer and return_temporary_buffer (#100914)
Works towards P0619R4 / #99985.

The use of `std::get_temporary_buffer` and `std::return_temporary_buffer`
are replaced with `unique_ptr`-based RAII buffer holder.

Escape hatches:
- `_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER` restores
`std::get_temporary_buffer` and `std::return_temporary_buffer`.

Drive-by changes:
- In `<syncstream>`, states that `get_temporary_buffer` is now removed,
because `<syncstream>` is added in C++20.
2024-09-16 11:53:05 -04:00
Nikolas Klauser
27c83382d8
[libc++] Replace __compressed_pair with [[no_unique_address]] (#76756)
This significantly simplifies the code, improves compile times and
improves the object layout of types using `__compressed_pair` in the
unstable ABI. The only downside is that this is extremely ABI sensitive
and pedantically breaks the ABI for empty final types, since the address
of the subobject may change. The ABI of the whole object should not be
affected.

Fixes #91266
Fixes #93069
2024-09-16 11:08:57 +02:00
Hristo Hristov
51f5525689
[libc++][NFC] Mark P1869R1 as implemented (#107746)
https://wg21.link/p1869r1: Rename `condition_variable_any` interruptible
wait methods

The paper was implemented as experimental feature in Clang 18 in:
4fa812bb52

Experimental status removed in:
https://github.com/llvm/llvm-project/pull/107900

Closes https://github.com/llvm/llvm-project/issues/100031

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
2024-09-13 19:05:20 +03:00