13171 Commits

Author SHA1 Message Date
Brad Smith
5f001294b1
Remove last few bits for Native Client support (#148983) 2025-07-18 11:26:36 -04:00
Louis Dionne
0e40695804
[libc++] Remove unused _LIBCPP_HAS_NO_STD_MODULES macro from __config_site (#148902)
Since 1d6b6132f, that macro isn't used anywhere anymore.
2025-07-18 11:06:27 -04:00
Paul Kirth
fd12e9aed8
[libc++][tests] Update XFAIL annotations for some tests on Windows (#149124)
These tests still fail on Windows with clang-22, as reported in #70225.
This started failing due to the version bump to Clang 22.
2025-07-18 11:03:19 -04:00
Kazu Hirata
4c85bf2fe8 Revert "[Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (#143653)"
This reverts commit c27e283cfbca2bd22f34592430e98ee76ed60ad8.

A builbot failure has been reported:
https://lab.llvm.org/buildbot/#/builders/186/builds/10819/steps/10/logs/stdio

I'm also getting a large number of warnings related to %zu and %zx.
2025-07-17 21:04:01 -07:00
YexuanXiao
c27e283cfb
[Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (#143653)
Including the results of `sizeof`, `sizeof...`, `__datasizeof`,
`__alignof`, `_Alignof`, `alignof`, `_Countof`, `size_t` literals, and
signed `size_t` literals, the results of pointer-pointer subtraction and
checks for standard library functions (and their calls).

The goal is to enable clang and downstream tools such as clangd and
clang-tidy to provide more portable hints and diagnostics.

The previous discussion can be found at #136542.

This PR implements this feature by introducing a new subtype of `Type`
called `PredefinedSugarType`, which was considered appropriate in
discussions. I tried to keep `PredefinedSugarType` simple enough yet not
limited to `size_t` and `ptrdiff_t` so that it can be used for other
purposes. `PredefinedSugarType` wraps a canonical `Type` and provides a
name, conceptually similar to a compiler internal `TypedefType` but
without depending on a `TypedefDecl` or a source file.

Additionally, checks for the `z` and `t` format specifiers in format
strings for `scanf` and `printf` were added. It will precisely match
expressions using `typedef`s or built-in expressions.

The affected tests indicates that it works very well.

Several code require that `SizeType` is canonical, so I kept `SizeType`
to its canonical form.

The failed tests in CI are allowed to fail. See the
[comment](https://github.com/llvm/llvm-project/pull/135386#issuecomment-3049426611)
in another PR #135386.
2025-07-17 22:45:57 -03:00
Ryan Prichard
8aa4fc0a9f
[libc++][Android] Reenable 2 tests for Android (#149415)
Now that the Android clang has been upgraded to clang-r563880
(llvm.org/pr148998), these two tests pass again.
2025-07-17 18:08:52 -07:00
Michael Buch
8f4deff5d5
[libcxx][fstream][NFC] Make __failed helper lambda a member function (#149390)
This patch makes the `__failed` lambda a member function on `fstream`.
This fixes two LLDB expression evaluation test failures that got
introduced with https://github.com/llvm/llvm-project/pull/147389:
```
16:22:51  ********************
16:22:51  Unresolved Tests (2):
16:22:51    lldb-api :: commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
16:22:51    lldb-api :: commands/expression/import-std-module/list/TestListFromStdModule.py
```

The expression evaluator is asserting in the Clang parser:
```
Assertion failed: (capture_size() == Class->capture_size() && "Wrong number of captures"), function LambdaExpr, file ExprCXX.cpp, line 1277.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```

Ideally we'd figure out why LLDB is falling over on this lambda. But to
unblock CI for now, make this a member function.

In the long run we should figure out the LLDB bug here so libc++ doesn't
need to care about whether it uses lambdas like this or not.
2025-07-17 23:50:39 +01:00
Nikolas Klauser
be3d614cc1
[libc++] Fix hash_multi{map,set}::insert (#149290) 2025-07-17 23:23:04 +02:00
Nikolas Klauser
4695aea28e
[libc++] Move more tests into better places (#148419) 2025-07-17 11:12:01 +02:00
Nikolas Klauser
4993f5b12c
[libc++][NFC] Use variable templates in <string> (#149038)
Variable templates are a bit lighter on the compiler than class
templates.
2025-07-17 11:11:30 +02:00
Nikolas Klauser
3dc5d687b0
[libc++] Remove minimal_cxx11_configuration.pass.cpp (#149119)
This test doesn't seem to be very useful. If it is the only test that
fails we would just remove the failing parts of the test, and otherwise
it doesn't provide any value either, since there will be another test
that fails.
2025-07-17 10:55:29 +02:00
Jonathan Wakely
3071fe55f8
[libc++] Add missing include <limits> to bitset to_ullong.pass.cpp test (#149149)
This was added to to_ulong.pass.cpp years ago by
cf1dc8d39e2c9870468ca86f7956a65c7745fece but I don't think the other
part of that commit matters here.
2025-07-17 09:46:45 +02:00
William Tran-Viet
2194bca2b7
[libc++] Granularize range_format and format_kind declarations (#148876)
While working on #105430 I ran into an issue implementing
[[optional.syn]](https://eel.is/c++draft/optional.syn) because of a
circular include that looked like the following: `optional ->
__format/range_default_formatter.h -> __format/range_formatter.h ->
__format/format_context.h -> optional`. Only `format_kind` and
`range_format` are needed, and so they looked like candidates to be put
into an internal header.
2025-07-17 09:43:12 +02:00
Ryan Prichard
038e80cfd3
[libc++][Android] Update compiler and sysroot (#148998)
* Upgrade from r536225 to r563880.

* Upgrade from ab/12644632 to f8b85cc5262c6e5cbc9a92c1bab2b18b32a4c63f,
the current HEAD commit of
https://android.googlesource.com/platform/prebuilts/ndk/+/refs/heads/mirror-goog-main-ndk

The previous source of sysroots (ci.android.com), deleted its artifacts
after a short period of time, and is currently out-of-date because of
the aosp-main turndown.

Updating the Docker image also fixes two tests.
2025-07-16 15:57:13 -07:00
Steve O'Brien
a89e6f6672
Minor formatting fix in 'generate_feature_test_macro_components' (#148889)
Fixes a small annoyance where generated files have a format which does
not agree with the one checked during `code-formatter` in CI.

For example `libcxx-generate-files` updates (among possibly others) the
`*.version.compile.pass.cpp` files. Previously these files contained an
extra newline which would fail the code format check. If you update that
file manually to remove just that extra trailing newline, then
`check-generated-output` will fail due to the file's contents differing
from what's expected.

Contains a number of changes: one actual change to the py script, and
lots of resulting whitespace changes.

My process for this was:
* Update `generate_feature_test_macro_components`: just remove an extra
newline which causes the code-format step to fail
* Run `$NINJA libcxx-generate-files` to rebuild all these
`.version.pass.cpp`'s
* Watch this PR's CI run to ensure things pass (i.e. this didn't break
things worse)
2025-07-16 17:19:54 +02:00
Nikolas Klauser
b8b99d83a6
[libc++] Simplify __hash_table further (#148375) 2025-07-16 17:13:08 +02:00
Corentin Jabot
9e5470e7d6
[Clang] Diagnose forming references to nullptr (#143667)
Per [decl.ref],

> Because a null pointer value or a pointer past the end of an object
does not point to an object, a reference in a well-defined program
cannot refer to such things.

Note this does not fixes the new bytecode interpreter.

Fixes #48665
2025-07-16 14:25:24 +02:00
enh-google
62bd778fd4
Remove workarounds for NDK versions before 2017's r16. (#148879) 2025-07-16 07:39:17 -04:00
Nikolas Klauser
46b4bd2882
[libc++] Implement _LIBCPP_SUPPRESS_DEPRECATED macros in terms of _LIBCPP_DIAGNOSTIC macros (#143857)
This makes the code a bit more consistent, since we use the
`_LIBCPP_DIAGNOSTIC` macros everywhere else.
2025-07-16 11:24:17 +02:00
Nikolas Klauser
50096134f8
[libc++][NFC] Remove some __tree internal accessor functions (#147266) 2025-07-16 10:33:21 +02:00
Nikolas Klauser
ffcb0a4559
[libc++] Update polymorphic_allocator to never contain a nullptr (#148423)
According to `[mem.poly.allocator.ctor]` the pointer contained in
`polymorphic_allocator` can never be null. The default constructor uses
`get_default_resource()`, which never returns null and the constructor
taking a pointer explicitly has a precondition that the pointer is
non-null.

This patch adds a warning and an assertion in case a user passes a null
pointer to `polymorphic_allocator` as well as marking `resource()` to
never return null.

This also fixes some tests which contained UB.

Fixes #148420
2025-07-16 10:03:57 +02:00
Nikolas Klauser
cee679aa3f
[libc++] Always initialize __tree::{,const_}iterator (#147167)
This was probably added to support https://wg21.link/n3644 but there's
no reason not to initialize the pointer in all standard modes. This is
technically an extension since n3644 only required value-initialized
iterators to be comparable, but supporting this as an extension should
be uncontroversial since it avoids potential reads of uninitialized
memory in C++03/C++11 without doing any harm.
2025-07-16 10:01:32 +02:00
Nikolas Klauser
db2eb4d031
[libc++] Simplify std::launder (#147985)
Both Clang and GCC diagnose invalid calls to `__builtin_launder`, which
causes duplicate diagnostics when using `std::launder` in an invalid
way. While the diagnostic message for the builtin isn't perferct, it's
definitely good enough to understand the problem and adding our own
diagnostic doesn't really make things any clearer. Because of that, this
patch simply removes the `static_assert`s and lets the compiler handle
diagnosing incorrect arguments instead. This not only simplifies our
implementation, but also improves compile times a bit, since we avoid
instantiating some type traits.
2025-07-16 09:42:09 +02:00
Nikolas Klauser
3b41e4d4b5
[libc++] Annotate barrier functions that are defined in the dylib (#148542)
This can improve code gen slightly.
2025-07-16 00:44:16 +02:00
Konstantin Varlamov
31e6fe78b2
[libc++] Add missing unsupported attributes to hardening timezone tests. (#148406)
Before this patch, these tests fail under `extensive` and `debug`
hardening modes.
2025-07-15 12:48:35 -04:00
A. Jiang
3d688233bd
[libc++][docs] Add missing entry for status pages, fix bad formatting, and deduplicate (#148186)
In a previously PR, the entry for P3491R3 define_static_{string,object,array} was missing.
This patch adds it back.

The number of LWG2687, LWG2709, LWG3315, LWG3395, LWG3987, and LWG4113
were duplicated in the title. It seems better to avoid such duplicates.

Also fixes some formatting to properly use italic and code styles, and
remove one improper leading space from the title of P3682R0 (which
caused incorrect alignment in the generated page).
2025-07-15 11:14:41 -04:00
Louis Dionne
d145f716ae
[libc++] Bump Xcode support (#148651)
Libc++'s policy is to support only the latest released Xcode, which is
Xcode 16.x. We did update our CI jobs to Xcode 16.x, but we forgot to
update the documentation, which still mentioned Xcode 15. This patch
updates the documentation and cleans up outdated mentions of
apple-clang-15 in the test suite.
2025-07-15 10:45:37 -04:00
Louis Dionne
6291b63a9a
[libc++] Ensure that we restore invariants in basic_filebuf::overflow (#147389)
In rare circumstances, the invariants could fail to be restored.
2025-07-15 10:40:54 -04:00
Tobias Hieta
01f36b39bd Bump version to 22.0.0-git 2025-07-15 16:03:12 +02:00
Nikolas Klauser
339a1f2e8f
Revert "[libc++][hardening] Introduce assertion semantics" (#148822)
Reverts llvm/llvm-project#148268

It looks like this was based on #148266, which I reverted in #148787.
2025-07-15 12:43:37 +02:00
Nikolas Klauser
fda3fbee6f
Revert "[libc++][hardening] Introduce a dylib function to log hardening errors." (#148787)
Reverts llvm/llvm-project#148266

I'm reverting this temporarily, since the release branch is today and
this is ABI sensitive. Let's wait until after the branch so that we have
plenty time to discuss the patch.
2025-07-15 12:12:41 +02:00
Nikolas Klauser
0c3a2faa85
[libc++] Simplify the implementation of __libcpp_{,de}allocate (#147989)
GCC 15 also supports `__buitin_operator_{new,delete}` now, so the
`#else` cases are dead code. This patch inlines the calls to the wrapper
functions and simplifies some surrounding code.
2025-07-15 11:43:55 +02:00
Konstantin Varlamov
7345508c6f
[libc++][hardening] Introduce assertion semantics (#148268)
Assertion semantics closely mimic C++26 Contracts evaluation semantics.
This brings our implementation closer in line with C++26 Library
Hardening (one particular benefit is that using the `observe` semantic
makes adopting hardening easier for projects).
2025-07-15 02:14:30 -07:00
Hristo Hristov
5fc844acd8
[libc++] P2944R3: Constrained comparisons - optional (#144249)
Partially implements [P2944R3](https://wg21.link/P2944R3) which adds
constrained comparisons to std::optional.

Closes #136767


# References
[optional.relops](https://wg21.link/optional.relops)
[optional.comp.with.t](https://wg21.link/optional.comp.with.t)

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
2025-07-15 10:12:39 +02:00
Konstantin Varlamov
49d2b5f1cd
[libc++][hardening] Introduce a dylib function to log hardening errors. (#148266)
Unlike `verbose_abort`, this function merely logs the error but does not
terminate execution. It is intended to make it possible to implement the
`observe` semantic for Hardening.
2025-07-14 17:04:33 -07:00
Igor Kudrin
00dacf8c22
[clang] Add -Wuninitialized-const-pointer (#148337)
This option is similar to -Wuninitialized-const-reference, but diagnoses
the passing of an uninitialized value via a const pointer, like in the
following code:
```
void foo(const int *);
void test() {
  int v;
  foo(&v);
}
```
This is an extract from #147221 as suggested in [this
comment](https://github.com/llvm/llvm-project/pull/147221#discussion_r2190998730).
2025-07-14 15:44:43 -07:00
Michael Buch
d4f5ed6a23
Revert "[libc++][NFC] atomic::wait use public API on macOS" (#148705)
Reverts llvm/llvm-project#147146

This is failing to build on our public macOS CI:
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake-sanitized/

```
06:48:56  FAILED: libcxx/src/CMakeFiles/cxx_shared.dir/atomic.cpp.o 
06:48:56  /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/lldb-build/bin/clang++ --target=arm64-apple-darwin23.1.0 -DLIBCXX_BUILDING_LIBCXXABI -DLIBC_NAMESPACE=__llvm_libc_common_utils -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/libcxx/src -I/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/lldb-build/include/c++/v1 -I/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/libcxxabi/include -I/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/cmake/Modules/../../libc -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -O3 -DNDEBUG -std=c++23 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=14.1 -fPIC -UNDEBUG -faligned-allocation -nostdinc++ -fvisibility-inlines-hidden -fvisibility=hidden -fsized-deallocation -Wall -Wextra -Wnewline-eof -Wshadow -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type -Wextra-semi -Wundef -Wunused-template -Wformat-nonliteral -Wzero-length-array -Wdeprecated-redundant-constexpr-static-def -Wno-nullability-completeness -Wno-user-defined-literals -Wno-covered-switch-default -Wno-suggest-override -Wno-error -fdebug-prefix-map=/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/lldb-build/include/c++/v1=/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/libcxx/include -MD -MT libcxx/src/CMakeFiles/cxx_shared.dir/atomic.cpp.o -MF libcxx/src/CMakeFiles/cxx_shared.dir/atomic.cpp.o.d -o libcxx/src/CMakeFiles/cxx_shared.dir/atomic.cpp.o -c /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/libcxx/src/atomic.cpp
06:48:56  /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/libcxx/src/atomic.cpp:46:12: fatal error: 'os/os_sync_wait_on_address.h' file not found
06:48:56     46 | #  include <os/os_sync_wait_on_address.h>
06:48:56        |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
06:48:56  1 error generated.
```

This is the configuration the failing bots are running:
```
06:25:12  + sw_vers
06:25:12  ProductName:		macOS
06:25:12  ProductVersion:		14.1
06:25:12  BuildVersion:		23B74
06:25:12  + xcodebuild -version
06:25:12  Xcode 15.2
06:25:12  Build version 15C5500c
```


The Intel bots are building fine though. Probably because they're on a
newer OS where the headers are available?
```
10:03:35  + sw_vers
10:03:35  ProductName:		macOS
10:03:35  ProductVersion:		15.1.1
10:03:35  BuildVersion:		24B91
10:03:35  + xcodebuild -version
10:03:39  Xcode 16.2
10:03:39  Build version 16C5031c
10:03:39  + cmake --version
10:03:39  cmake version 3.30.2
```
2025-07-14 20:14:39 +01:00
A. Jiang
4177bfdb46
[libc++][docs] Confirm that P2372R3 has been implemented (#148573)
In #125921, the changes requested by P2372R3 were completed and tested
together with corresponding `chrono` types. But that PR didn't mention
P2372R3. The `__cpp_lib_format` FTM was even bumped by an earlier PR
#98275.

This PR confirms that P2372R3 was completed in LLVM 21 (together with P1361R2).
Closes #100043
2025-07-14 10:23:27 -04:00
Konstantin Varlamov
5951c44573
[libc++] Introduce the _LIBCPP_VERBOSE_TRAP macro (#148262)
Split out the calls to __builtin_verbose_trap into a separate header.
This is just a refactoring to make the code a bit more structured.
2025-07-14 09:56:19 -04:00
Kazu Hirata
ef48b7fae5
[libcxx] Fix a typo in documentation (#148557) 2025-07-13 22:20:03 -07:00
Nikolas Klauser
d3b339e36d
[libc++] Don't instantiate allocators in __hash_table on an incomplete type (#148353)
Currently, we try to instantiate the allocator on `__hash_value_type`,
which we don't define anymore. Instead, just use the
`map::allocator_type` to instantiate `__tree`, since that's what we
actually want anyways.
2025-07-13 08:59:07 +02:00
Louis Dionne
27ccb962c1 [libc++][NFC] Fix documentation for using the libstdc++ test config 2025-07-11 17:08:00 -04:00
Hui
b9d8d1e416
[libc++][NFC] atomic::wait use public API on macOS (#147146)
At the moment, we use the os internal functions `__ulock_wait`. This
patch updates the code on macOS to use the public API
`os_sync_wait_on_address`.

Fixes #146142
2025-07-11 13:11:22 -04:00
Nikolas Klauser
13bb3281f3 [libc++] XFAIL is_bounded_array.pass.cpp for Android as well
The Android CI is currently using a compiler that's too old.
2025-07-11 16:08:06 +02:00
Nikolas Klauser
03f6f48b73
[libc++] Move a few tests into more correct places (#147557) 2025-07-10 20:55:07 +02:00
Joseph Huber
f56b6ecf08 [LLVM] Fix GPU build of libcxx/compiler-rt libraries
Summary:
Recent changes altered the name without updating this, add it in and
also tell the builtins build that C++ compilers work because it seems to
require that now.
2025-07-10 09:28:18 -05:00
Nikolas Klauser
cebfb75c9f [libc++] Temporarily disable failing test for Android CI runners
This test is currently failing in the Android CI, since the compiler
used there is too old. Once the Clang version is updated this XFAIL
should be removed again.
2025-07-10 09:28:46 +02:00
Nikolas Klauser
afcf76bda1
[libc++] Fix insert() calling incorrect constructors (#146231)
This fixes `insert()` calling the wrong `allocator_traits::construct` in
the associative containers by removing the special handling that lead to
the inconsistencty inside `__tree` and `__hash_table`.
2025-07-10 09:24:15 +02:00
Nikolas Klauser
9052977c35
[libc++] Implement the public invoke API in terms of the libc++-internal API (#146334)
This adds one additional variable template to the libc++-internal API.
This allows us to implement the public API once instead of twice.
2025-07-10 09:23:28 +02:00
Nikolas Klauser
30f8c64b1d
[libc++][NFC] Simplify std::__destroy_at a bit (#147025) 2025-07-10 09:22:54 +02:00