Commit Graph

10863 Commits

Author SHA1 Message Date
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 014830193b.
and ce12d6563e.

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 2916b125f6.

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 d57fe1dbe0.
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
Mark de Wever
c9c71a7e0b [libc++][C++20 modules] Tests no filesystem build.
Depends on D158331

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158337
2023-08-22 20:15:59 +02:00
Mark de Wever
ef3a39160d [libc++][C++20 modules] Tests no threading build.
Depends on D158330

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158331
2023-08-22 20:15:16 +02:00
Mark de Wever
7e8c80fc60 [libc++][C++20 modules] Tests no locale build.
This fixes some missing #ifndef and implements the header restrictions
in the modules script.

Depends on D158192

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158330
2023-08-22 20:14:28 +02:00
Mark de Wever
41161aeb54 [libc++][modules] Generates std.cppm.in.
This takes the header restrictions into account instead of manually
duplicating this build information. This is a preparation to properly
support the libc++ disabled parts in the std module.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158192
2023-08-22 20:13:39 +02:00
Mark de Wever
30f9b47907 [libc++][CI] Test std module in C++26 mode.
Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D153408
2023-08-22 20:08:52 +02:00
Mark de Wever
d9e3c85f57 [libc++][modules] Simplifies C++20 module testing.
The building of the std module has been moved from `params.py` and
`dsl.py` to a `lit.local.cfg` for the entire test suite. In theory this
change allows testing modules in most configurations, except:
- combined with clang modules
- C++ versions that don't support the std module

Currently only C++23 with all parts enabled works.
C++26 is expected to work properly with CMake 3.27. That versions of CMake
knows how to invoke clang using C++26.
The parts disabled modi of libc++ have not been modularized yet.

It still is the goal that in the future CMake will be able to do the work
done in `lit.local.cfg`. Doing this in CMake would require a more mature
libc++ implementation.

Thanks a lot to @ldionne for giving hints how to enable modules in a
`lit.local.cfg`.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D157625
2023-08-22 20:06:28 +02:00
Mark de Wever
71a7192d69 [libc++][doc] Marks LLVM-17 release notes as final.
Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D158340
2023-08-20 15:47:41 +02:00
yrong
96377e5cc1 [libc++][expected] Implement LWG3836
Implement LWG3836 (https://wg21.link/LWG3836)
`std::expected<bool, E1>` conversion constructor `expected(const expected<U, G>&)` should take precedence over `expected(U&&)` with operator `bool`

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D155701
2023-08-20 20:18:09 +08:00
Nikolas Klauser
cd34e89cfa [libc++][NFC] Remove __has_keyword
__has_keyword is almost not used anymore. There are only two cases. One can be replaced by __has_builtin and the other seems entirely redundant, so we can remove the definition.

Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D158215
2023-08-19 15:46:13 -07:00
Nikolas Klauser
3583bf3ad8 [libc++] Make everything in namespace std have default type visibility and hidden visibility and remove _LIBCPP_ENUM_VIS
This avoids having to add `_LIBCPP_ENUM_VIS`, since that is handled through `type_visibility` and GCC always makes the visibility of enums default. It also fixes and missing `_LIBCPP_EXPORTED_FROM_ABI` on classes when using Clang.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D153658
2023-08-19 15:16:04 -07:00
Mark de Wever
1eb90b9a4e [libc++] Fixes disabling wide character.
While testing the std module with -DLIBCXX_ENABLE_WIDE_CHARACTERS=OFF
the build failed. These functions are not exported from the module since
they use wchar_t. Disable them in the headers too.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D158199
2023-08-19 19:09:16 +02:00
Mark de Wever
f471b4975f [NFC][libc++] Removes no longer existing define.
_LIBCPP_HAS_NO_INCOMPLETE_FORMAT has been removed from libc++ for a
while now.
2023-08-19 14:06:42 +02:00
Kim Gräsman
eac0b67ed1 [docs] Fix include-what-you-use example
The --mapping_file switch was missing; the example would have been
rejected.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D157785
2023-08-19 13:33:07 +02:00