10876 Commits

Author SHA1 Message Date
Mark de Wever
3401b308f8 [libc++] Renames modules-build.
This is a followup of D157625. Using the name clang-modules-build makes
it clear this is regarding the clang modules and not the C++23 std or
std.compat module.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158927
2023-09-06 17:11:13 +02:00
yronglin
9f67143be0 [libc++] Implement LWG3938 (Cannot use std::expected monadic ops with move-only error_type)
Implement LWG3938 (Cannot use std::expected monadic ops with move-only error_type)
https://wg21.link/LWG3938

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D154116
2023-09-06 22:38:29 +08:00
Louis Dionne
e375fd0343 [libc++] Remove unused include in __threading_support
Differential Revision: https://reviews.llvm.org/D138528
2023-09-06 09:39:39 -04:00
Louis Dionne
98d28e947c [libc++] Fix issue in std.cppm after introducing views::chunk_by
This should fix CI issues introduced by 065dc485bd where the std.cppm
module won't build in C++20 mode because views::chunk_by was added in
C++23 but wasn't marked as such in ranges.inc.
2023-09-06 09:19:07 -04:00
Ed Maste
43d05f4cc9
[libc++] Switch FreeBSD CI job to Clang 16 (#65422)
libc++ will drop support for Clang 15 before long.
2023-09-05 22:07:28 -04:00
Jakub Mazurkiewicz
065dc485bd [libc++][ranges] Implement P2443R1: views::chunk_by
This patch implements https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2443r1.html (`views::chunk_by`).

Reviewed By: #libc, var-const

Differential Revision: https://reviews.llvm.org/D144767
2023-09-05 16:19:49 -07:00
varconst
390ac82317 [libc++][ranges] Add benchmarks for the from_range constructors of vector and deque.
Differential Revision: https://reviews.llvm.org/D150747
2023-09-05 15:57:45 -07:00
Louis Dionne
6b46c7688f [libc++][NFC] Remove an outdated UNSUPPORTED annotation
This is likely a rebase artifact. libcpp-has-no-concepts is not a
Lit feature we ever define anymore.
2023-09-05 16:00:44 -04:00
Chris Bowler
fbdf684fae [libc++] Avoid destructor call for error_category singletons
When a handle to an error_category singleton object is used during the
termination phase of a program, the destruction of the error_category
object may have occurred prior to execution of the current destructor
or function registered with atexit, because the singleton object may
have been constructed after the corresponding initialization or call
to atexit. For example, the updated tests from this patch will fail if
using a libc++ built using a compiler that updates the vtable of the
object on destruction.

This patch attempts to avoid the issue by causing the destructor to not
be called in the style of ResourceInitHelper in src/experimental/memory_resource.cpp.
This approach might not work if object lifetime is strictly enforced.

Differential Revision: https://reviews.llvm.org/D65667

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-09-05 13:44:10 -04:00
Mark de Wever
6f8b17703d [libc++][C++20 modules] Tests no except build.
Depends on D158661

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158862
2023-09-05 18:29:27 +02:00
Mark de Wever
98c6c985f1 [libc++][C++20 modules] Tests no wchar_t build.
Depends on D158358

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158661
2023-09-05 18:22:10 +02:00
Mark de Wever
b9f24033f7 [libc++][C++20 modules] Enabling in C++20.
The vendors of the MSVC STL, libstdc++ and libc++ have agreed [1] to
make the C++23 modules std and std.compat available in C++20. This
provides the std module; libc++ has not implemented the std.compat
module yet.

[1] https://github.com/microsoft/STL/issues/3945

Depends on D158357

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158358
2023-09-05 18:10:46 +02:00
Mark de Wever
10343c910b
[libc++][C++20 modules] Fixes CMake include paths. (#65079)
When the modules are used in a bootstrap build the paths
${LIBCXX_GENERATED_INCLUDE_DIR} and
${LIBCXX_GENERATED_INCLUDE_TARGET_DIR} have a different value and both
are needed to build modules.

This issue has been reported on Slack.
2023-09-04 20:35:46 +02:00
Nikolas Klauser
b6d2460fd4 [libc++] Remove _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17 documentation
We've removed this flag a while ago, so we shouldn't list it anymore.
2023-09-02 07:17:32 -07:00
Nikolas Klauser
9f3e3efd98 [libc++][NFC] Refactor __enable_if return types to defaulted template parameters
This brings most of the enable_ifs in libc++ to the same style. It also has the nice side-effect of reducing the size of names of these symbols, since the depedent return type is shorter.

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D157787
2023-09-01 17:52:31 -07:00
Nikolas Klauser
6256ccfd4f [libc++][NFC] Update the remaining enable_ifs
This brings most of the enable_ifs in libc++ to the same style.

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D157753
2023-09-01 17:51:17 -07:00
Konstantin Varlamov
a168135487 [libc++] Fix Lit config in string.io.
This file was accidentally formatted by D140612, resulting in incorrect
syntax.
2023-09-01 14:37:15 -07:00
Brendan Emery
a40bada91a [libc++] Apply clang formatting to all string unit tests
This applies clang-format to the std::string unit tests in preparation
for landing https://reviews.llvm.org/D140550.

Differential Revision: https://reviews.llvm.org/D140612
2023-09-01 13:35:18 -04:00
Nikolas Klauser
0a97720d01 [libc++] Assume that __BYTE_ORDER__ is always present
Both Clang and GCC always define __BYTE_ORDER__, so there is no need to test the byte order a million different ways.

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits, krytarowski

Differential Revision: https://reviews.llvm.org/D158216
2023-09-01 09:12:07 -07:00
Nikolas Klauser
b6310e65f6 [libc++] Add lifetimebound attributes to clamp
Reviewed By: #libc, ldionne

Spies: ldionne, arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D158327
2023-09-01 09:04:11 -07:00
Ruslan Arutyunyan
be4adb5c2b [libcxx][test] Add tests for hash_function() and key_eq() in unordered containers
Add tests for `hasher hash_function() const` and `key_equal key_eq() const`
observers in unordered containers.

Differential Revision: https://reviews.llvm.org/D119703
2023-09-01 08:50:56 -04:00
Konstantin Varlamov
d2232e6873 [libc++] Initialize all member variables of __state in <regex>
This is to prevent a GCC warning (
https://github.com/llvm/llvm-project/issues/65132). It looks like
`__at_first` is always assigned before it's used, but all other member
variables of this struct are initialized in the constructor, so there is
no reason not to initialize `__at_first` as well.

Differential Revision: https://reviews.llvm.org/D159249
2023-08-31 22:14:01 -07:00
Louis Dionne
c01794e7ae [libc++] Move once_flag outside of <mutex>
This allows including once_flag directly from <__locale> instead of
depending on all of <mutex>, which requires threading. In turn, this
makes it easier to support locales on platforms without threading.

Drive-by change: clang-format once_flag.h and use _LIBCPP_HIDE_FROM_ABI

Differential Revision: https://reviews.llvm.org/D155487
2023-08-31 14:56:42 -04:00
Eric Fiselier
3e0bc8cf78 Remove lit's --summary flag from buildbots.
The summary flag causes a progress bar to appear and be rewritten using
a curses like interface. This works great for interactive sessions, but
produces line after line of garbage in the logs.

This should cause the logs to be much smaller and more readable.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D159120
2023-08-31 14:23:51 -04:00
Louis Dionne
b397921fc7 [runtimes] Fix some duplicate word typos
Those fixes were taken from https://reviews.llvm.org/D137338.
2023-08-31 11:55:10 -04:00
Nikolas Klauser
22347afb72 [libc++][NFC] Remove some dead code
We only support Clang on windows, so this code path is never taken.

Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D158230
2023-08-30 21:07:14 -07:00
David Tenty
ef3e27385b Revert "[libc++] Comment out the AIX jobs that are failing"
This reverts commit 014830193b21ff87639762cbb89dad79ae5831ec.
and ce12d6563e84c209c7200de3bfbf84c5d349824c.

Differential Revision: https://reviews.llvm.org/D158754
2023-08-30 13:28:30 -04:00
Mark de Wever
8930d04d55 [libc++][format] Fixes out of bounds access.
Fixes https://llvm.org/PR65011

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158940
2023-08-30 17:40:58 +02:00
Konstantin Varlamov
ec4005ff87 [libc++][hardening] Mark the remaining stray assertions as uncategorized
This avoids enabling them unconditionally in all hardening modes.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D158970
2023-08-29 16:32:23 -07:00
Mark de Wever
3c28ce6bec [libc++] Adds __throw_system_error overload.
This was mention in D150044 and D154995 that this would be useful.
This addresses the last review coment of D150044.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D156019
2023-08-29 19:08:18 +02:00
Mark de Wever
195015cf67 [libc++][doc] Improves contribution page.
This adds more information regarding the libc++ coding style and
reference that are useful when working on a standard library
implementation.

This information is based on review comments and tips I give to new
contributors an information I wish I'd know when I started working on
libc++.

Depends on D156051

Reviewed By: #libc, jloser, var-const, ldionne

Differential Revision: https://reviews.llvm.org/D156052
2023-08-29 19:05:31 +02:00
Joel E. Denny
c981c53305 [lit] Improve test output from lit's internal shell
This patch and D154984 were discussed in
<https://discourse.llvm.org/t/rfc-improving-lits-debug-output/72839>.

Motivation
----------

D154984 removes the "Script:" section that lit prints along with a
test's output, and it makes -v and -a imply -vv.  For example, after
D154984, the "Script:" section below is never shown, but -v is enough
to produce the execution trace following it:

```
 Script:
 --
 : 'RUN: at line 1'; echo hello | FileCheck bogus.txt && echo success
 --
 Exit Code: 2

 Command Output (stdout):
 --
 $ ":" "RUN: at line 1"
 $ "echo" "hello"
 # command output:
 hello

 $ "FileCheck" "bogus.txt"
 # command stderr:
 Could not open check file 'bogus.txt': No such file or directory

 error: command failed with exit status: 2

 --
```

In the D154984 review, some reviewers point out that they have been
using the "Script:" section for copying and pasting a test's shell
commands to a terminal window.  The shell commands as printed in the
execution trace can be harder to copy and paste for the following
reasons:

- They drop redirections and break apart RUN lines at `&&`, `|`, etc.
- They add `$` at the start of every command, which makes it hard to
  copy and paste multiple commands in bulk.
- Command stdout, stderr, etc. are interleaved with the commands and
  are not clearly delineated.
- They don't always use proper shell quoting.  Instead, they blindly
  enclose all command-line arguments in double quotes.

Changes
-------

D154984 plus this patch converts the above example into:

```
 Exit Code: 2

 Command Output (stdout):
 --
 # RUN: at line 1
 echo hello | FileCheck bogus-file.txt && echo success
 # executed command: echo hello
 # .---command stdout------------
 # | hello
 # `-----------------------------
 # executed command: FileCheck bogus-file.txt
 # .---command stderr------------
 # | Could not open check file 'bogus-file.txt': No such file or directory
 # `-----------------------------
 # error: command failed with exit status: 2

 --
```

Thus, this patch addresses the above issues as follows:

- The entire execution trace can be copied and pasted in bulk to a
  terminal for correct execution of the RUN lines, which are printed
  intact as they appeared in the original RUN lines except lit
  substitutions are expanded.  Everything else in the execution trace
  appears in shell comments so it has no effect in a terminal.
- Each of the RUN line's commands is repeated (in shell comments) as
  it executes to show (1) that the command actually executed (e.g.,
  `echo success` above didn't) and (2) what stdout, stderr, non-zero
  exit status, and output files are associated with the command, if
  any.  Shell quoting in the command is now correct and minimal but is
  not necessarily the original shell quoting from the RUN line.
- The start and end of the contents of stdout, stderr, or an output
  file is now delineated clearly in the trace.

To help produce some of the above output, this patch extends lit's
internal shell with a built-in `@echo` command.  It's like `echo`
except lit suppresses the normal execution trace for `@echo` and just
prints its stdout directly.  For now, `@echo` isn't documented for use
in lit tests.

Without this patch, libcxx's custom lit test format tries to parse the
stdout from `lit.TestRunner.executeScriptInternal` (which runs lit's
internal shell) to extract the stdout and stderr produced by shell
commands, and that parse no longer works after the above changes.
This patch makes a small adjustment to
`lit.TestRunner.executeScriptInternal` so libcxx can just request
stdout and stderr without an execution trace.

(As a minor drive-by fix that came up in testing: lit's internal `not`
command now always produces a numeric exit status and never `True`.)

Caveat
------

This patch only makes the above changes for lit's internal shell.  In
most cases, we do not know how to force external shells (e.g., bash,
sh, window's `cmd`) to produce execution traces in the manner we want.

To configure a test suite to use lit's internal shell (which is
usually better for test portability than external shells anyway), add
this to the test suite's `lit.cfg` or other configuration file:

```
config.test_format = lit.formats.ShTest(execute_external=False)
```

Reviewed By: MaskRay, awarzynski

Differential Revision: https://reviews.llvm.org/D156954
2023-08-29 12:01:24 -04:00
Aaron Ballman
a02f9a7756 Revert "[clang] Enable sized deallocation by default in C++14 onwards"
This reverts commit 2916b125f686115deab2ba573dcaff3847566ab9.

Reverting due to failures on:
https://lab.llvm.org/buildbot/#/builders/216/builds/26407
https://lab.llvm.org/staging/#/builders/247/builds/5659
http://45.33.8.238/win/83485/step_7.txt
2023-08-29 09:36:59 -04:00
yronglin
06ef752b7c [libc++] Implement LWG3464(istream::gcount() can overflow)
Implement LWG3464 https://wg21.link/LWG3464

Reviewed By: #libc, Mordante, philnik

Differential Revision: https://reviews.llvm.org/D158749
2023-08-29 20:18:25 +08:00
wangpc
2916b125f6 [clang] Enable sized deallocation by default in C++14 onwards
Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.

Reviewed By: rnk, aaron.ballman, #libc, ldionne, Mordante, MaskRay

Differential Revision: https://reviews.llvm.org/D112921
2023-08-29 15:42:50 +08:00
yronglin
2051a41219 Revert "[libc++] Implement LWG3464(istream::gcount() can overflow)"
This reverts commit d57fe1dbe0506c006d8f082101a7c00fde798ddb.
2023-08-27 13:34:32 +08:00
yronglin
d57fe1dbe0 [libc++] Implement LWG3464(istream::gcount() can overflow)
Implement LWG3464 https://wg21.link/LWG3464

Reviewed By: Mordante

Differential Revision: https://reviews.llvm.org/D158749
2023-08-27 11:24:40 +08:00
Louis Dionne
7a5ecbd891 [libc++][NFC] Fix typos in comments 2023-08-25 14:37:31 -04:00
Samuel Thibault
1cfcc36812 [libc++] Fix GNU/Hurd build
GNU/Hurd does have clock_gettime, it just doesn't define _POSIX_TIMERS because its support for timers is not complete.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D158584
2023-08-25 19:54:54 +02:00
Lei Huang
5adac8bebc [PowerPC] Exclude frexp(long double) on linux
PowerPC on linux currently don't have support for lowering long double for
frexp().  Removing the tests until implementation is provided.

Reviewed By: #libc, amyk, Mordante

Differential Revision: https://reviews.llvm.org/D158547
2023-08-25 12:17:51 -05:00
Rishabh Bali
2dc6281b98 [libc++]Declaring '__asign_view__' as a non noexcept function
`__assign_view__` is declared as a noexcept function in `libcxx/include/__filesystem/path.h` however internally it calls `std::basic_string<char>::basic_string<char>(std::string_view)` which is not a noexcept function this may lead to a `std::terminate()` call when allocation of a new string fails.

Fixes : https://github.com/llvm/llvm-project/issues/64858

Reviewed By: Mordante, #libc

Differential Revision: https://reviews.llvm.org/D158826
2023-08-25 18:26:22 +02:00
Mark de Wever
ea82a822d9 [libc++] Adds string_view constructor overload
Implements
- P2697R1 Interfacing bitset with string_view

Depends on D153192

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D153201
2023-08-25 17:56:27 +02:00
Ian Anderson
6021c78fe5 [libc++][Modules] locale fails to compile with clang modules when _LIBCPP_LOCALE__L_EXTENSIONS is undefined
When `__locale_dir/locale_base_api/locale_guard.h is` compiled independently, as it is when it's in its own clang module, it fails to compile due to `locale_t` being undefined. It needs to include `__locale` to get that, instead of just `clocale`.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D158669
2023-08-24 14:22:41 -07:00
Louis Dionne
aa60b2687c [libc++] Temporary workaround to make the CI green again
This is obviously a hack, but it's too late at night to figure out the
exact issue and which commit introduced it, and I want to get the CI
back to green for contributors overnight.
2023-08-23 22:19:37 -04:00
Will Hawkins
3db0e400f0 [libcxx][NFC] Update status documentation for stride range view
Note that there is a Differential revision for the stride ranges
view implementation and the names of the people who are developing
it.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D158446
2023-08-23 19:28:37 +02:00
Mark de Wever
92ac360063 [libc++][charconv] Adds operator bool.
Implements
- P2497R0 Testing for success or failure of <charconv> functions

Depends on D153192

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D153199
2023-08-23 19:25:10 +02:00
Mark de Wever
f105ed11ae [NFC][libc++][test] Improve name test file.
With C++20 modules in libc++ the old name modules is ambiguous. This
rename makes it clear this is regarding the clang modules.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D153042
2023-08-22 20:29:41 +02:00
Mark de Wever
c1d49ce67a [libc++][CI] Moves modules build to C++23.
The std module can be tested in the generic C++23 build. This removes the
special module build.

Note it is possible to enable modules automatically in CMake, but that
would fail in the "parts disabled" builds; they have not been properly
been converted to modules yet.

Depends on D157625

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D157744
2023-08-22 20:19:48 +02:00
Mark de Wever
cfab8686bf [libc++][C++20 modules] Tests no unicode build.
Depends on D158347

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158357
2023-08-22 20:17:37 +02:00
Mark de Wever
0e26efe3dc [libc++][C++20 modules] Tests no random device build.
Depends on D158337

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158347
2023-08-22 20:16:53 +02:00