Commit Graph

11391 Commits

Author SHA1 Message Date
Louis Dionne
8fab16c86c [libc++][NFC] Remove trailing whitespace from release notes 2024-01-22 08:48:58 -05:00
Michael Schellenberger Costa
ad01447d30
[libcxx] Fix typo in parallel for_each_n test (#78954)
This fixes a trivial copy and paste error where we forgot to change
`for_each` to `for_each_n`
2024-01-22 12:10:30 +01:00
Hristo Hristov
03c19e91e8
[libc++][numeric] P0543R3: Saturation arithmetic (#77967)
Implements: https://wg21.link/P0543R3
- https://eel.is/c++draft/numeric.sat

Additional references:
- Division: https://eel.is/c++draft/expr.mul#4
- Arithmetic conversions: https://eel.is/c++draft/expr.arith.conv#1
- Clang builtins:
https://clang.llvm.org/docs/LanguageExtensions.html#builtin-functions

Depends on: https://github.com/llvm/llvm-project/pull/78086

---------

Co-authored-by: Zingam <zingam@outlook.com>
Co-authored-by: Mark de Wever <zar-rpg@xs4all.nl>
2024-01-22 06:57:45 +02:00
Louis Dionne
86b6dfc619
[libc++] Fix Coverity warning about use-after-move (#78780)
While the code is technically correct because the index is never
actually moved from (and anyway that wouldn't matter since it's an
integer), it's still better style not to access an object after it has
been moved-from. Since this is so easy to do, just save the index in a
temporary variable.

rdar://120501577
2024-01-21 16:24:04 -05:00
Mark de Wever
30d6806a08
[libc++][doc] Update the release notes for LLVM 18 (#78324)
This is a preparation for the upcoming LLVM 18 release.
2024-01-21 19:48:33 +01:00
bobsayshilol
f73bf45d68
[libc++] Fix typo in _LIBCPP_REMOVE_TRANSITIVE_INCLUDES (#78639)
Spotted by inspection when trialling out
`_LIBCPP_REMOVE_TRANSITIVE_INCLUDES`. No other instances of `_LIPCPP_`
were found in the repo.
2024-01-21 16:15:46 +01:00
Mark de Wever
5b7bb56a05 [libc++] Clang-tidy enable modernize-use-nullptr.
Clang-tidy 18 no longer has false positives with the spaceship operator.
Note that I'm quite sure there are more occurrences in our headers that
are not caught.

This relands https://github.com/llvm/llvm-project/pull/76659 with fixes
tested in https://github.com/llvm/llvm-project/pull/78746.
2024-01-21 13:08:18 +01:00
Mark de Wever
ae8d699d6c [NFC][libc++] tab -> space 2024-01-21 12:27:21 +01:00
Mark de Wever
8b47bb657b
[libc++] Install modules. (#75741)
Installs the source files of the experimental libc++ modules. These
source files (.cppm) are used by the Clang to build the std and 
std.compat modules.

The design of this patch is based on a discussing in SG-15 on
12.12.2023. (SG-15 is the ISO C++ Tooling study group):

- The modules are installed at a location, that is not known to build 
  systems and compilers.
- Next to the library there will be a module manifest json file.
  This json file contains the information to build the module from the
  libraries sources. This information includes the location where the
  sources are installed. @ruoso supplied the specification of this json
  file.
- If possible, the compiler has an option to give the location of the
  module manifest file
  (https://github.com/llvm/llvm-project/pull/76451).

Currently there is no build system support, but it expected to be added
in the future.

Fixes: https://github.com/llvm/llvm-project/issues/73089
2024-01-21 12:16:22 +01:00
Mark de Wever
04757337cd
[libc++][modules] Improves std.compat module. (#76330)
Let the std.compat module use the std module instead of duplicating the
exports.

Based on @ChuanqiXu9's suggestion in #71438.
2024-01-21 12:15:15 +01:00
Mark de Wever
1d6b6132ff [libc++] Reland CI module improvements.
Revert "Revert #76246 and #76083"

This reverts commit 5c150e7eeb.

Adds a small fix that should properly disable the tests on Windows.
Unfortunately the original poster has not provided feedback and the
original patch did not fail in the LLVM CI infrastructure.

Modules are known to fail on Windows due to non compliance of the
C library. Currently not having this patch prevents testing on other
platforms.
2024-01-21 12:10:36 +01:00
Hristo Hristov
7d9b5aa65b
[libc++][format] P2637R3: Member visit (std::basic_format_arg) (#76449)
Implements parts of: `P2637R3` https://wg21.link/P2637R3
(https://eel.is/c++draft/variant.visit)

Implements:
`basic_format_arg.visit()`
`basic_format_arg.visit<R>()`
Deprecates:
`std::visit_format_arg()`

The tests are as close as possible to the non-member function tests.

To land after: https://github.com/llvm/llvm-project/pull/76447,
https://github.com/llvm/llvm-project/pull/76268

---------

Co-authored-by: Zingam <zingam@outlook.com>
2024-01-21 12:30:25 +02:00
Hristo Hristov
38b5f2edfc
[libc++][spaceship][NFC] Status page update (#78894)
Co-authored-by: Zingam <zingam@outlook.com>
2024-01-21 12:27:16 +02:00
Konstantin Varlamov
dc57752031
[libc++][hardening] Categorize assertions that produce incorrect results (#77183)
Introduce a new `argument-within-domain` category that covers cases
where the given arguments make it impossible to produce a correct result
(or create a valid object in case of constructors). While the incorrect
result doesn't create an immediate problem within the library (like e.g.
a null pointer dereference would), it always indicates a logic error in
user code and is highly likely to lead to a bug in the program once the
value is used.
2024-01-20 23:38:02 -08:00
Vitaly Buka
f0c920ffb7
[libc++][hardening] XFAIL tests with HWASAN (#78866)
Follow up to #78862

These tests control hardening mode with `ADDITIONAL_COMPILE_FLAGS`, and
always set modes which use on TRAP. So we don't need to check
`libcpp-hardening-mode=fast`, and they must always fail with the current
HWASAN implementation.
2024-01-20 23:26:48 -08:00
Hristo Hristov
3412bc7658
[libc++][variant] P2637R3: Member visit (std::variant) (#76447)
Implements parts of: `P2637R3` https://wg21.link/P2637R3
(https://eel.is/c++draft/variant.visit)

Implements:
`variant.visit()`
`variant.visit<R>()`

The tests are as close as possible to the non-member function.

To land after: https://github.com/llvm/llvm-project/pull/76268

---------

Co-authored-by: Zingam <zingam@outlook.com>
2024-01-21 07:16:51 +02:00
ZhangYin
6bb5c989bd
[libc++] <experimental/simd> Add load constructor for class simd/simd_mask (#76610) 2024-01-21 12:48:30 +08:00
Hristo Hristov
07b5829fca
[libc++] FreeBSD CI: Adds <signal.h> to check_assertion.h (#78863)
...in attempt to fix the FreeBSD CI.

I noticed that suddenly some tests in the latest PRs fail to compile on
FreeBSD (`SIGILL` and `SIGTRAP` not defined). This tries to resolve
the issue.

Co-authored-by: Zingam <zingam@outlook.com>
2024-01-20 13:48:48 -08:00
Vitaly Buka
aaa7de1fc9
[libc++][hardening] XFAIL test in fast mode under HWASAN (#78862)
After #77883, `fast` mode uses TRAP, and HWASAN
replaces TRAP with abort or error exit code.

On a quick looks it should be possible to avoid doing
that in HWASAN, but historically this is convention for all
sanitizers. Changing this behavior may break existing
users.

Other sanitizers are not affected because they don't
install TRAP handlers by default. But if they do, they also
replace TRAP with abort/exit.
2024-01-20 13:37:38 -08:00
Hui
85a8e5c3e0
[libc++] fix condition_variable_any hangs on stop_request (#77127)
When I implemented `condition_variable_any::wait`, I missed the most
important paragraph in the spec:

> The following wait functions will be notified when there is a stop
request on the passed stop_token.
> In that case the functions return immediately, returning false if the
predicate evaluates to false.

From
https://eel.is/c++draft/thread.condition#thread.condvarany.intwait-1.

Fixes #76807
2024-01-20 21:18:44 +00:00
LEE KYOUNGHEON
448b8e6162
Module documentation improvement: prebuilt module location can be directly fetched via CMake variable. (#78405)
CMake officially supports binary directory variable of installed
dependency using `FetchContent`. According to the current documentation,
it fetches `std` module and use its binary directory as hardcoded
string, `${CMAKE_BINARY_DIR}/_deps/std-build`, however it can be
replaced with `${std_BINARY_DIR}`.

Reference: https://cmake.org/cmake/help/latest/module/FetchContent.html
2024-01-20 21:06:02 +01:00
Hristo Hristov
34feb2263e
[libc++][spaceship][NFC] Status page update: *libc++* Spaceship Operator Status (operator<=>)¶ (#78832)
Co-authored-by: Zingam <zingam@outlook.com>
2024-01-20 08:33:00 +02:00
Hristo Hristov
dbbeee6b83
[libc++][span] P2447R4: std::span over an initializer list (#78157)
Implements: https://wg21.link/P2447R6
- https://eel.is/c++draft/span.syn
- https://eel.is/c++draft/span.overview
- https://eel.is/c++draft/span.cons
- https://eel.is/c++draft/diff

---------

Co-authored-by: Zingam <zingam@outlook.com>
2024-01-20 06:09:46 +02:00
Hristo Hristov
552f5549de
[libc++][any] LWG3305: any_cast<void> (#78215)
Implements: https://wg21.link/LWG3305
- https://eel.is/c++draft/any.nonmembers

---------

Co-authored-by: Zingam <zingam@outlook.com>
2024-01-20 06:08:24 +02:00
Hristo Hristov
ed276dff46
[libc++][memory] P2868R1: Removing deprecated typedef std::allocator::is_always_equal (#78562)
Implements:
- https://wg21.link/P2868R1
- https://wg21.link/LWG3170

---------

Co-authored-by: Zingam <zingam@outlook.com>
2024-01-20 06:07:19 +02:00
Stephan T. Lavavej
123ab34abc
[libc++][test] Move format.functions ASCII tests to libcxx/test/libcxx (#78661)
As @cpplearner explained in microsoft/STL#4328:

> libc++'s "ascii" mode (controlled by the `_LIBCPP_HAS_NO_UNICODE`
> macro) means "every code unit outside ASCII is treated as a valid
> printable character". AFAIK we \[MSVC's STL\] don't support such a mode.

Because these files are testing a non-Standard mode, they should be
moved from `libcxx/test/std` to `libcxx/test/libcxx`.
2024-01-19 16:17:03 -08:00
Konstantin Varlamov
58780b811c
[libc++][hardening] In production hardening modes, trap rather than abort (#78561)
In the hardening modes that can be used in production (`fast` and
`extensive`), make a failed assertion invoke a trap instruction rather
than calling verbose abort. In the debug mode, still keep calling
verbose abort to provide a better user experience and to allow us to
keep our existing testing infrastructure for verifying assertion
messages. Since the debug mode by definition enables all assertions, we
can be sure that we still check all the assertion messages in the
library when running the test suite in the debug mode.

The main motivation to use trapping in production is to achieve better
code generation and reduce the binary size penalty. This way, the
assertion handler can compile to a single instruction, whereas the
existing mechanism with verbose abort results in generating a function
call that in general cannot be optimized away (made worse by the fact
that it's a variadic function, imposing an additional penalty). See the
[RFC](https://discourse.llvm.org/t/rfc-hardening-in-libc/73925) for more
details. Note that this mechanism can now be completely [overridden at
CMake configuration
time](https://github.com/llvm/llvm-project/pull/77883).

This patch also significantly refactors `check_assertion.h` and expands
its test coverage. The main changes:
- when overriding `verbose_abort`, don't do matching inside the function
-- just print the error message to `stderr`. This removes the need to
set a global matcher and allows to do matching in the parent process
after the child finishes;
- remove unused logic for matching source locations and for using
wildcards;
- make matchers simple functors;
- introduce `DeathTestResult` that keeps data about the test run,
primarily to make it easier to test.

In addition to the refactoring, `check_assertion.h` can now recognize
when a process exits due to a trap.
2024-01-19 13:48:13 -08:00
Mital Ashok
924701311a
[SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (#77768)
Closes #77638, #24186

Rebased from <https://reviews.llvm.org/D156032>, see there for more
information.

Implements wording change in [CWG2137](https://wg21.link/CWG2137) in the
first commit.

This also implements an approach to [CWG2311](https://wg21.link/CWG2311)
in the second commit, because too much code that relies on `T{ T_prvalue}` 
being an elision would break. Because that issue is still open and
the CWG issue doesn't provide wording to fix the issue, there may be
different behaviours on other compilers.
2024-01-19 21:10:51 +01:00
Twice
7ded34576f
[libc++] Implement LWG3940: std::expected<void, E>::value() also needs E to be copy constructible (#71819)
This patch includes the fix for
[LWG3940](https://cplusplus.github.io/LWG/issue3940)
(`std::expected<void, E>::value()` also needs `E` to be copy
constructible)
2024-01-19 10:06:11 +00:00
Vitaly Buka
2a54098de1
Revert "[ASan][libc++] Turn on ASan annotations for short strings" (#78627)
Reverts llvm/llvm-project#75882

To recover build bots :
https://lab.llvm.org/buildbot/#/builders/239/builds/5361
https://lab.llvm.org/buildbot/#/builders/168/builds/18126
2024-01-18 16:33:31 -08:00
Daniel Thornburgh
5c150e7eeb Revert #76246 and #76083
These cause test build failures on Windows.

This reverts the following commits:
  57ca748435
  d06ae33ec3
2024-01-18 15:07:33 -08:00
Mark de Wever
b689e1678c
[libc++] Renames ABI tag. (#78342)
The tag name was long for an ABI tag. The name was misleading too, the
tag is first introduced in LLVM 18 in 2024 and not in 2023.

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2024-01-18 18:46:46 +01:00
Dominik Wójt
7f05153236
[libc++] Un-xfail module tests in picolibc tests (#78580)
Some of the module tests now pass after picolibc update.
https://github.com/llvm/llvm-project/pull/77908

The remaining tests fail and are now set to xfail on picolibc
specifically.
2024-01-18 18:40:52 +01:00
ZhangYin
9917d39dfc
[libc++] <experimental/simd> Fix vector_aligned_tag (#76611)
Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
2024-01-18 13:59:01 +08:00
Tacet
d06fb0b29c
[ASan][libc++] Turn on ASan annotations for short strings (#75882)
This commit turns on ASan annotations in `std::basic_string` for short
stings (SSO case).

Originally suggested here: https://reviews.llvm.org/D147680

String annotations added here:
https://github.com/llvm/llvm-project/pull/72677

Requires to pass CI without fails:
- https://github.com/llvm/llvm-project/pull/75845
- https://github.com/llvm/llvm-project/pull/75858

Annotating `std::basic_string` with default allocator is implemented in
https://github.com/llvm/llvm-project/pull/72677 but annotations for
short strings (SSO - Short String Optimization) are turned off there.
This commit turns them on. This also removes
`_LIBCPP_SHORT_STRING_ANNOTATIONS_ALLOWED`, because we do not plan to
support turning on and off short string annotations.

Support in ASan API exists since
dd1b7b797a.
You can turn off annotations for a specific allocator based on changes
from
2fa1bec7a2.

This PR is a part of a series of patches extending AddressSanitizer C++
container overflow detection capabilities by adding annotations, similar
to those existing in `std::vector` and `std::deque` collections. These
enhancements empower ASan to effectively detect instances where the
instrumented program attempts to access memory within a collection's
internal allocation that remains unused. This includes cases where
access occurs before or after the stored elements in `std::deque`, or
between the `std::basic_string`'s size (including the null terminator)
and capacity bounds.

The introduction of these annotations was spurred by a real-world
software bug discovered by Trail of Bits, involving an out-of-bounds
memory access during the comparison of two strings using the
`std::equals` function. This function was taking iterators
(`iter1_begin`, `iter1_end`, `iter2_begin`) to perform the comparison,
using a custom comparison function. When the `iter1` object exceeded the
length of `iter2`, an out-of-bounds read could occur on the `iter2`
object. Container sanitization, upon enabling these annotations, would
effectively identify and flag this potential vulnerability.

If you have any questions, please email:

    advenam.tacet@trailofbits.com
    disconnect3d@trailofbits.com
2024-01-18 05:55:34 +01:00
Konstantin Varlamov
8dfc67d672
[libc++][hardening] Rework how the assertion handler can be overridden. (#77883)
Previously there were two ways to override the verbose abort function
which gets called when a hardening assertion is triggered:
- compile-time: define the `_LIBCPP_VERBOSE_ABORT` macro;
- link-time: provide a definition of `__libcpp_verbose_abort` function.

This patch adds a new configure-time approach: the vendor can provide
a path to a custom header file which will get copied into the build by
CMake and included by the library. The header must provide a definition
of the
`_LIBCPP_ASSERTION_HANDLER` macro which is what will get called should
a hardening assertion fail. As of this patch, overriding
`_LIBCPP_VERBOSE_ABORT` will still work, but the previous mechanisms
will be effectively removed in a follow-up patch, making the
configure-time mechanism the sole way of overriding the default handler.

Note that `_LIBCPP_ASSERTION_HANDLER` only gets invoked when a hardening
assertion fails. It does not affect other cases where
`_LIBCPP_VERBOSE_ABORT` is currently used (e.g. when an exception is
thrown in the `-fno-exceptions` mode).

The library provides a default version of the custom header file that
will get used if it's not overridden by the vendor. That allows us to
always test the override mechanism and reduces the difference in
configuration between the pristine version of the library and
a platform-specific version.
2024-01-17 18:56:07 -08:00
Sanjay Marreddi
67f5df78d7
Revert "[libc++] Fix regex_search to match $ alone with match_default flag" (#78349)
The behavior of `std::regex_search` for patterns anchored both to the
start and to the end of the input went wrong after merging #77256 .
Patterns like `"^b*$"` started matching the strings such as `"a"`, which
is not expected.

Reverts the PR: #77256
2024-01-17 13:51:29 +01:00
Konstantin Varlamov
94da2b21ee
Revert "[libc++] Clang-tidy enable modernize-use-nullptr. (#76659)" (#78409)
This reverts commit 020ea3e8d1.

This seems to break `test/libcxx/clang_tidy.gen.py/regex.sh.cpp` (in
C++03 mode for some reason):

```
2024-01-17T07:32:22.1759374Z # RUN: at line 12
2024-01-17T07:32:22.1773919Z clang-tidy-18 /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/test/libcxx/clang_tidy.gen.py/regex.sh.cpp --warnings-as-errors=* -header-filter=.* --config-file=/home/runner/_work/llvm-project/llvm-project/libcxx/.clang-tidy -- -Wweak-vtables -nostdinc++ -I /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1 -I /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1 -I /home/runner/_work/llvm-project/llvm-project/libcxx/test/support -std=c++03 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety -Wuser-defined-warnings  -fno-modules
2024-01-17T07:32:22.1803227Z # executed command: clang-tidy-18 /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/test/libcxx/clang_tidy.gen.py/regex.sh.cpp '--warnings-as-errors=*' '-header-filter=.*' --config-file=/home/runner/_work/llvm-project/llvm-project/libcxx/.clang-tidy -- -Wweak-vtables -nostdinc++ -I /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1 -I /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1 -I /home/runner/_work/llvm-project/llvm-project/libcxx/test/support -std=c++03 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety -Wuser-defined-warnings -fno-modules
2024-01-17T07:32:22.1817757Z # .---command stdout------------
2024-01-17T07:32:22.1820160Z # | /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/__iterator/iterator_traits.h:124:50: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
2024-01-17T07:32:22.1822498Z # |   124 |   static const bool value = decltype(__test<_Tp>(0, 0, 0, 0, 0))::value;
2024-01-17T07:32:22.1823337Z # |       |                                                  ^
2024-01-17T07:32:22.1824052Z # |       |                                                  nullptr
2024-01-17T07:32:22.1826651Z # | /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/__iterator/iterator_traits.h:124:53: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
2024-01-17T07:32:22.1829325Z # |   124 |   static const bool value = decltype(__test<_Tp>(0, 0, 0, 0, 0))::value;
2024-01-17T07:32:22.1831137Z # |       |                                                     ^
2024-01-17T07:32:22.1831963Z # |       |                                                     nullptr
2024-01-17T07:32:22.1834149Z # | /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/__iterator/iterator_traits.h:124:56: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
2024-01-17T07:32:22.1848711Z # |   124 |   static const bool value = decltype(__test<_Tp>(0, 0, 0, 0, 0))::value;
2024-01-17T07:32:22.1849506Z # |       |                                                        ^
2024-01-17T07:32:22.1849997Z # |       |                                                        nullptr
2024-01-17T07:32:22.1851528Z # | /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/__iterator/iterator_traits.h:124:59: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
2024-01-17T07:32:22.1853391Z # |   124 |   static const bool value = decltype(__test<_Tp>(0, 0, 0, 0, 0))::value;
2024-01-17T07:32:22.1854277Z # |       |                                                           ^
2024-01-17T07:32:22.1854841Z # |       |                                                           nullptr
2024-01-17T07:32:22.1856314Z # | /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/__iterator/iterator_traits.h:124:62: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
2024-01-17T07:32:22.1857768Z # |   124 |   static const bool value = decltype(__test<_Tp>(0, 0, 0, 0, 0))::value;
2024-01-17T07:32:22.1858493Z # |       |                                                              ^
2024-01-17T07:32:22.1858998Z # |       |                                                              nullptr
2024-01-17T07:32:22.1859503Z # `-----------------------------
2024-01-17T07:32:22.1859900Z # .---command stderr------------
2024-01-17T07:32:22.1860259Z # | 43 warnings generated.
2024-01-17T07:32:22.1860710Z # | Suppressed 33 warnings (33 in non-user code).
2024-01-17T07:32:22.1861809Z # | Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2024-01-17T07:32:22.1862750Z # | 5 warnings treated as errors
2024-01-17T07:32:22.1863229Z # `-----------------------------
2024-01-17T07:32:22.1863622Z # error: command failed with exit status: 1
```

(see
https://github.com/llvm/llvm-project/actions/runs/7552394884/job/20561192096)
2024-01-17 01:30:52 -08:00
Tacet
2b3cdd69f7
[ASan][libc++][NFC] refactor vector annotations arguments (#78322)
This commit simplifies ASan helper functions in `std::vector` by
removing arguments which can be calculated later.

Short term it improves readability of helper functions in `std::vector`.

Long term it aims to help with a bigger refactor of container
annotations.
2024-01-17 08:50:10 +01:00
Mark de Wever
fb79f80bf6
[libc++][modules] Fixes clang-tidy exports. (#76288)
As suggested in #71438 we should use
  export import std;
in the std.compat module.

Using this exports some named declarations from functions and records,
adding them to the global namespace. Clang correctly does not export
these and it's an issue in the declaration filtering. Declarations in
function or record context are not considered a global named
declaration.
2024-01-17 08:27:00 +01:00
Mark de Wever
020ea3e8d1
[libc++] Clang-tidy enable modernize-use-nullptr. (#76659)
Clang-tidy 18 no longer has false positives with the spaceship operator.
Note that I'm quite sure there are more occurrences in our headers that
are not caught.
2024-01-17 08:22:43 +01:00
Mark de Wever
e6ac33b936
[libc++][modules] Increase clang-tidy version used. (#76268)
As suggested in #71438 we should use
  export import std;
in the std.compat module.

Testing this locally failed when building with the clang-tidy-17 plugin.
The std module was considered corrupt in the test
  libcxx/test/libcxx/module_std_compat.gen.py
however the test
  libcxx/test/libcxx/module_std.gen.py
passed. Both test generated identical std.pcm files. Using the
clang-tidy-18 plugin solves the issue.
2024-01-17 08:18:36 +01:00
Mark de Wever
57ca748435
[libc++][modules] Adds module testing. (#76246)
This adds a new module test infrastructure. This requires tagging tests
using modules. The test runner uses this information to determine the
compiler flags needed to build and use the module.

Currently modules are build per test, which allows testing them for
tests with ADDITIONAL_COMPILE_FLAGS. At the moment only 4 tests use
modules. Therefore the performance penalty is not measurable. If in the
future more tests use modules it would be good to measure the overhead
and determine whether it's acceptable.
2024-01-17 08:15:18 +01:00
Mark de Wever
d06ae33ec3
[libc++][modules] Removes module testing. (#76083)
This removes the entire modules testing infrastructure.

The current infrastructure uses CMake to generate the std and std.compat
module. This requires quite a bit of plumbing and uses CMake. Since
CMake introduced module support in CMake 3.26, modules have a higher
CMake requirement than the rest of the LLVM project. (The LLVM project
requires 3.20.) The main motivation for this approach was how libc++
generated its modules. Every header had its own module partition. This
was changed to improve performance and now only two modules remain. The
code to build these can be manually crafted.

A followup patch will reenable testing modules, using a different
approach.
2024-01-17 08:11:25 +01:00
Mark de Wever
ab398416a7 [libc++][modules] Fixes RTTI build.
This was reviewed in https://github.com/llvm/llvm-project/pull/76246
2024-01-16 20:16:29 +01:00
Louis Dionne
127c390fc4
[libc++] Rewrite the IWYU generation (#78295)
This simplifies the IWYU generation script by treating everything as a
file, instead of dealing with directories and files separately.

This has the downside that the `libcxx.imp` file is a lot larger than it
used to be, however we now have the flexibility of mapping files under
detail directories to different public headers. For example, this allows
us to map <__fwd/subrange.h> to <ranges> but <__fwd/pair.h> to
<utility>.

This patch also adds basic validation to ensure that we never map a
header to a public header that doesn't exist. We may still be missing
some mappings or we may be mapping to incorrect headers, but we won't be
mapping to headers that downright don't exist.

Fixes #63346
2024-01-16 13:45:05 -05:00
Louis Dionne
8803112bee [libc++][NFC] Add deprecated mention for _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS in the docs
This was missed in the patch where I marked the macro as deprecated.
2024-01-16 13:16:15 -05:00
Mark de Wever
4a87db6b10
[libc++][print] Enables it on Apple backdeployment. (#76293)
As suggested in #73262 this enable the stream printing on Apple
backdeployment targets. This omits the check whether the file is a
terminal. This is not entirely conforming, but the differences should be
minor and are typically not observable.

Fixes https://github.com/llvm/llvm-project/issues/75225
2024-01-16 19:14:33 +01:00
Mark de Wever
34933d1872
[libc++] Improves _LIBCPP_HAS_NO_THREADS guards. (#76624)
Previously the header included several headers, possibly granularized
threading headers. This could lead to build errors when these headers
were incompatible with threading disabled.

Now test the guard before inclusion. This matches the pattern used for
no localization and no wide characters.

Fixes: https://github.com/llvm/llvm-project/issues/76620
2024-01-16 19:13:40 +01:00
Mark de Wever
e0443624b9
[libc++] Deprecate removed features macros. (#77879)
We discussed the removal of these enable-all macros in the libc++
monthly meeting and we agreed that we should deprecate these macros in
LLVM 18, and then remove them in LLVM 19 since they can silently enable
deprecated features that are implemented after the first release of the
macro.

This patch does the first part of this -- it deprecates the macro.

Note that the file
  test/libcxx/depr/enable_removed_cpp20_features.compile.pass.cpp
does not exist so this file is not adapted. Since the feature is
deprecated and slated for removal soon the missing test is not
implemented.

Partly addresses: https://github.com/llvm/llvm-project/issues/75976

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2024-01-16 19:12:59 +01:00