9806 Commits

Author SHA1 Message Date
Louis Dionne
609b95cea1 [libc++] Remove CMake workaround for the discontinued Projects build
Differential Revision: https://reviews.llvm.org/D138801
2022-11-28 11:10:52 -05:00
Louis Dionne
b95379d20e [libc++][NFC] Add assertions before calling memmove
Since we're checking preconditions for calling memmove, we might
as well do that properly.

Differential Revision: https://reviews.llvm.org/D138798
2022-11-28 11:10:04 -05:00
Louis Dionne
b938b8702f [libc++][NFC] Rename include guards under /support/
For consistency with the rest of the code base.
2022-11-28 09:04:33 -05:00
Louis Dionne
5888e5aebc [libc++][NFC] Remove stray whitespace in string_view 2022-11-28 08:04:15 -05:00
Louis Dionne
df942d5692 [libc++][NFC] Use using declaration instead of typedef in string_view 2022-11-28 08:04:09 -05:00
Louis Dionne
e4aad511e6 [libc++][NFC] Add missing include to ext/__hash
Note that we use <stddef.h> instead of <cstddef> because we're
using size_t (not std::size_t) and we're outside of namespace std.

Differential Revision: https://reviews.llvm.org/D138716
2022-11-25 11:49:01 -05:00
Louis Dionne
732bf92c9e [libc++][NFC] Remove unused includes from poll_with_backoff.h
Differential Revision: https://reviews.llvm.org/D138687
2022-11-25 10:39:24 -05:00
Louis Dionne
480cd780d6 [libc++][NFC] Consistently use newline between license and include guard 2022-11-25 10:25:17 -05:00
Louis Dionne
396fbe264f [libc++] Bump AppleClang compiler requirement
Per our policy, the latest released AppleClang has been 14 for a while,
so libc++ is removing support for AppleClang 13. Our CI bots have been
moved to AppleClang 14 a few weeks ago.

Differential Revision: https://reviews.llvm.org/D138685
2022-11-25 09:51:44 -05:00
Louis Dionne
f62d4135c5 [libc++] Use builtins when redeclaring <string.h> functions
When we define the const-correct overloads of <string.h> functions in
libc++ itself, use builtins whenever possible. This avoids depending on
the presence of these functions in the C library headers.

Also, as a fly-by, improve the tests for these functions since we
basically didn't check anything but their signature. We could have
used the wrong builtin (as long as the signature matched) without ever
noticing, which was quite scary.

Differential Revision: https://reviews.llvm.org/D138684
2022-11-25 09:22:09 -05:00
David Tenty
194ab73a41 [libc++][AIX] Add AIX buildbot owners
This adds the AIX (i.e. Power) buildbot owners in the format established
by https://reviews.llvm.org/D138445

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D138580
2022-11-24 11:44:56 -05:00
Louis Dionne
08a0faf4cd [libc++] Keep char_traits<T> for arbitrary T around until LLVM 18
This is in response to failures seen after landing D138307.

Differential Revision: https://reviews.llvm.org/D138596
2022-11-24 08:22:39 -05:00
Nikolas Klauser
c418dccdbd [libc++] Remove P1908 from the status page
The paper doesn't include anything affecting the library. AFAICT there isn't even anything to do for the compiler, since it just reserved the std attribute namespace.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D138128
2022-11-24 14:10:19 +01:00
Nikolas Klauser
3574b800cf [libc++][clang-tidy] Enable readability-simplify-boolean-expr
Reviewed By: ldionne, #libc

Spies: Eugene.Zelenko, aheejin, libcxx-commits, xazax.hun

Differential Revision: https://reviews.llvm.org/D137804
2022-11-24 00:42:19 +01:00
Louis Dionne
09f7554890 [libc++][NFC] Fix documentation build 2022-11-23 10:31:21 -05:00
Louis Dionne
aeecef08c3 [libc++] Remove default definition of std::char_traits
This patch removes the base template implementation for std::char_traits.
If my reading of http://eel.is/c++draft/char.traits is correct, the
Standard mandates that the library provides specializations for several
types like char and wchar_t, but not any implementation in the base
template. Indeed, such an implementation is bound to be incorrect for
most types anyways, since things like `eof()` and `int_type` will definitely
have to be customized.

Since the base template implementation should not have worked for anyone,
this shouldn't be a breaking change (I expect that anyone defining a
custom character type today will already have to provide their own
specialization of char_traits). However, since we're aware of some users
of char_traits for unsigned char and signed char, we're keeping those two
specializations around for two releases to give people some time to migrate.

Differential Revision: https://reviews.llvm.org/D138307
2022-11-23 09:51:01 -05:00
Louis Dionne
647ddc08f4 [libc++] Add missing __has_include checks for C headers not provided by libc++
This makes the library consistent in how it handles C library headers. For C headers provided by libc++,
we unconditionally include <foo.h> from <cfoo>, and then <foo.h> conditionally include_next <foo.h>.
For headers not provided by libc++, <cfoo> conditionally includes the system's <foo.h> directly.

Differential Revision: https://reviews.llvm.org/D138512
2022-11-23 09:50:14 -05:00
Louis Dionne
e6a5fb6c23 [libc++][NFC] Use if-else chain instead of match, which is a Python 3.10 construct 2022-11-23 08:49:14 -05:00
Alex Richardson
4559864897 [libc++] Fix __regex_word value when using newlib/picolibc
The ctype mask for newlib/picolibc is fully saturated, so __regex_word
has to overlap with one of the values. This commit uses the same workaround
as bionic did (uint16_t for char_class_type inside regex_traits). It
should be possible to have libc++ provide the default rune table instead,
but that will require a new mechanism to detect newlib inside __config
since the header defining the newlib/picolibc macros has not been included
yet inside __config. Doing it this way also avoids duplicating the ctype
table for newlib, reducing the global data size.

Differential Revision: https://reviews.llvm.org/D138195
2022-11-23 09:04:42 +00:00
David Blaikie
c4c0e7984f [libcxx] Add _LIBCPP_NODEBUG to std::conditional related typedfs
Looks like std::conditional wasn't included in 14d4869209cc8ff9a53aaa5a59d6409fbc1c5f5d
(& maybe other typedefs that should be using this technique either got
missed or have regressed since that change was made)

This was noticed by a 1.4% clang.dwp regression due to
f4fb72e6d4cee1097e6606e66232fe55e793cd86 introducing more instantiations
of std::conditional - this change reduces that regression to 0.6% at
least.

I'm also looking at other instantiations caused by that change that
might be able to be addressed - but a quick grep shows ~200 "type"
typedefs missing _LIBCPP_NODEBUG, so maybe a systematic application of
the typedef might be suitable?

Differential Revision: https://reviews.llvm.org/D131082
2022-11-22 23:37:58 +00:00
Fangrui Song
23023654be [libc++] Replace __ppc64__ with __powerpc64__ and fix is_iec559 for non-ibm128
The lowercase `__ppc64__` is not defined by non-darwin powerpc64 GCC, therefore
it lures users to write code which is not portable to GCC. Migrate to
`__powerpc64__` in preparation for undefining `__ppc64__`. `__powerpc64__` is
much more common than `__PPC64__`.

Update alignment_of.pass.cpp to use 1 unconditionally:
on powerpc-unknown-linux-gnu `alignof(bool) = _Alignof(bool) = __alignof(bool) = 1`.
The value 4 might be derived from an ancient Clang.

Change is_iec559 to true when long double uses uses IEEE 754 quadruple or double
precision (i.e. not ibm128).

Reviewed By: #libc, thesamesam, ldionne

Differential Revision: https://reviews.llvm.org/D137513
2022-11-22 13:33:34 -08:00
Louis Dionne
c1d53fe338 [libc++][NFC] Add missing #ifdef for TEST_HAS_NO_WIDE_CHARACTERS 2022-11-22 16:27:02 -05:00
Nikolas Klauser
b816b52674 [libc++][math.h][NFC] Refactor enable_ifs
Reviewed By: ldionne, Mordante, #libc

Spies: EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D137501
2022-11-22 20:35:58 +01:00
Nikolas Klauser
c702264762 [libc++][math.h] Remove some code duplication
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D137500
2022-11-22 20:35:55 +01:00
Nikolas Klauser
b0a29f6911 [libc++][math.h] Remove __libcpp_<func> functions and instead call builtins directly
Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D137499
2022-11-22 20:35:51 +01:00
Nikolas Klauser
40d8f87809 [libc++] Assume that builtins for math.h functions are available
All supported compilers support the builtins, so this removes dead code and simplifies a lot of the functions through that.

Reviewed By: ldionne, #libc, EricWF

Spies: EricWF, michaelplatings, libcxx-commits

Differential Revision: https://reviews.llvm.org/D135781
2022-11-22 20:35:47 +01:00
Nikolas Klauser
ecef6b1cb1 [libc++] Remove duplication in math_h.pass.cpp and improve coverage
Reviewed By: ldionne, huixie90, #libc

Spies: mstorsjo, EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D136908
2022-11-22 20:35:44 +01:00
Mark de Wever
e948cab07d [libc++][format] Fixes visit_format_arg.
The Standard specifies which types are stored in the basic_format_arg
"variant" and which types are stored as a handle. Libc++ stores
additional types in the "variant". During a reflector discussion
@jwakely mention this is user observable; visit_format_arg uses the type
instead of a handle as argument.

This optimization is useful and will probably be used for other small
types in the future. To be conferment the visitor creates a handle and
uses that as argument. There is a second visitor so the formatter can
still directly access the 128-bit integrals.

The test for the visitor and get has been made public too, there is no
reason not too. The 128-bit integral types are required by the Standard,
when they are available.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D138052
2022-11-22 17:48:33 +01:00
David Spickett
75e09ce9b3 [libcxx] Add BOT_OWNERS.txt
Buildkite doesn't provide a way to list bot owners so currently
we are pinging people on Discord and Phabricator.

Which works ok until that person is on vacation. This file gives us
a place to list multiple people, or group contacts for each bot.

I've stuck to the CODE_OWNERS.txt format because there's no great
reason to change it.

Reviewed By: #libc, EricWF, ldionne

Differential Revision: https://reviews.llvm.org/D138445
2022-11-22 15:41:23 +00:00
Yi Kong
3f65c8fcbe Revert "[libc++] Remove workarounds for systems that used to require __need_XXX macros"
This reverts commit 119cef40d18c48240854edc553dca61c4e9fdf27.

The change broke multiple builders.
2022-11-22 20:46:38 +09:00
Alvin Wong
e07ca2aeeb [libcxx] Fix std::equal not accepting volatile types by refactoring __equal_to
Fixes https://github.com/llvm/llvm-project/issues/59021

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D138268
2022-11-22 16:33:38 +08:00
Christopher Di Bella
ab46648082 [libcxx] adds an include-what-you-use (IWYU) mapping file
This makes it possible for programmers to run IWYU and get more accurate
standard library inclusions. Prior to this commit, the following program
would be transformed thusly:

```cpp
// Before
 #include <algorithm>
 #include <vector>

void f() {
  auto v = std::vector{0, 1};
  std::find(std::ranges::begin(v), std::ranges::end(v), 0);
}
```

```cpp
// After
 #include <__algorithm/find.h>
 #include <__ranges/access.h>
 #include <vector>
...
```

There are two ways to fix this issue: to use [comment pragmas](https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md)
on every private include, or to write a canonical [mapping file](https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUMappings.md)
that provides the tool with a manual on how libc++ is laid out. Due to
the complexity of libc++, this commit opts for the latter, to maximise
correctness and minimise developer burden.

To mimimise developer updates to the file, it makes use of wildcards
that match everything within listed subdirectories. A script has also
been added to ensure that the mapping is always fresh in CI, and makes
the process a single step.

Finally, documentation has been added to inform users that IWYU is
supported, and what they need to do in order to leverage the mapping
file.

Closes #56937.

Differential Revision: https://reviews.llvm.org/D138189
2022-11-22 01:09:49 +00:00
Louis Dionne
3465f02259 [libc++][NFC] Add missing conditionals for the existence of wide characters
Differential Revision: https://reviews.llvm.org/D138435
2022-11-21 18:00:53 -05:00
John Baldwin
26068c6e60 [libc++] <type_traits>: Avoid instantiating a pointer type.
GCC expands the pointer type in this conditional expression even for
template types _Up that are not arrays.  This raises an error when
std::decay<> is used with reference types (as is done in LLVM's
sources).  Using add_pointer<> causes GCC to only instantiate a
pointer type for array types.

Reviewed By: #libc, philnik, ldionne

Differential Revision: https://reviews.llvm.org/D135469
2022-11-21 14:34:08 -08:00
Nikolas Klauser
e1e1cad6fd [libc++][math.h][NFC] Reformat functions
This is just to make to follow-up diffs simpler

Reviewed By: ldionne, #libc, EricWF

Spies: EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D137498
2022-11-21 22:52:21 +01:00
Louis Dionne
4548fca742 [libc++] Don't workaround GCC issue on non-GCC compilers
Differential Revision: https://reviews.llvm.org/D138438
2022-11-21 16:08:50 -05:00
Nikolas Klauser
1323461fe7 [libc++] Add utilites for instantiating functions with multiple types
We currently call a lot of functions with the same list of types. To avoid forgetting any of them, this patch adds type_lists and utilities for it. Specifically, it adds
- `type_list` - This is just a list of types
- `concatenate` - This allows concatenating type_lists
- `for_each` - Iterate over a type_list

Reviewed By: ldionne, #libc

Spies: jloser, EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D137476
2022-11-21 20:35:06 +01:00
Mark de Wever
36ce0c3b1e [libc++][format] Makes format_context copyable.
This was a bug discovered by @jwakely.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D137911
2022-11-21 19:36:57 +01:00
Louis Dionne
f77403be27 [libc++][NFC] Add link to GCC bug report in <limits.h> workaround 2022-11-21 11:01:13 -05:00
Louis Dionne
92487d7c42 [libc++][NFC] Rename folder for char_traits<wchar_t> tests 2022-11-21 09:50:58 -05:00
Louis Dionne
119cef40d1 [libc++] Remove workarounds for systems that used to require __need_XXX macros
Libc++ tried accomodating systems that need to be able to define various
__need_FOO macros before including C library headers, however it does not
appear to be needed anymore in most cases. Indeed, glibc used to use that
system to conditionally provide definitions, however almost all instances
of these macros have been removed from glibc years ago.

I think the next step would be to also fix Clang's own builtin headers
to stop needing these macros.

Differential Revision: https://reviews.llvm.org/D131425
2022-11-21 08:22:09 -05:00
Louis Dionne
20ca119a4d [libc++][NFC] Refactor run-buildbot to make it closer to our buildkite pipeline
Differential Revision: https://reviews.llvm.org/D138380
2022-11-20 13:56:49 -05:00
Louis Dionne
af8c49dc1e [libc++] Introduce a setting to remove fstream from the library
This allows porting the library to platforms that are able to support
<iostream> but that do not have a notion of a filesystem, and where it
hence doesn't make sense to support std::fstream (and never will).

Also, remove reliance on <fstream> in various tests that didn't
actually need it.

Differential Revision: https://reviews.llvm.org/D138327
2022-11-20 10:51:32 -05:00
Louis Dionne
eaa4f041f7 [libc++] Use numeric_limits instead of raw INT_MAX
This allows discard_block_engine to work on platforms that might not
provide a full <limits.h> header.

Differential Revision: https://reviews.llvm.org/D138212
2022-11-18 11:32:14 -05:00
David Spickett
3ae3162cb6 [libcxx] Fix link to Buildbot interface
Reviewed By: #libc, philnik, ldionne

Differential Revision: https://reviews.llvm.org/D138286
2022-11-18 15:47:21 +00:00
Konstantin Varlamov
f51c91532e [libc++][NFC] Add a missing include in pre-C++14 language modes. 2022-11-17 17:15:41 -08:00
Konstantin Varlamov
821513b1e6 [libc++] Fix a missing include in pre-C++17 language modes. 2022-11-17 16:53:05 -08:00
Louis Dionne
3de4689048 [libc++][NFC] Add missing include <cstring> in char_traits.h 2022-11-17 10:46:45 -05:00
Louis Dionne
5d87f60f89 [libc++] Only include_next C library headers when they exist
Some platforms don't provide all C library headers. In practice, libc++
only requires a few C library headers to exist, and only a few functions
on those headers. Missing functions that libc++ doesn't need for its own
implementation are handled properly by the using_if_exists attribute,
however a missing header is currently a hard error when we try to
do #include_next.

This patch should make libc++ more flexible on platforms that do not
provide C headers that libc++ doesn't actually require for its own
implementation. The only downside is that it may move some errors from
the #include_next point to later in the compilation if we actually try
to use something that isn't provided, which could be somewhat confusing.
However, these errors should be caught by folks trying to port libc++
over to a new platform (when running the libc++ test suite), not by end
users.

NOTE: This is a reapplicaton of 226409, which was reverted in 674729813
      because it broke the build. The issue has now been fixed with
      https://reviews.llvm.org/D138062.

Differential Revision: https://reviews.llvm.org/D136683
2022-11-17 10:30:20 -05:00
Louis Dionne
5ed6dc4681 [libc++] Introduce helper functions __make_iter in vector and string
This prepares the terrain for introducing a new type of bounded iterator
that can't be constructed like __wrap_iter. This reverts part of the
changes made to std::vector in 4eab04f84.

Differential Revision: https://reviews.llvm.org/D138036
2022-11-15 16:17:13 -05:00