Commit Graph

9437 Commits

Author SHA1 Message Date
Mark de Wever e7d1cc923e [libc++][doc] Fixes a broken table entry. 2022-06-27 17:43:51 +02:00
Louis Dionne ac65403a21 [libc++][NFC] Remove trailing whitespace 2022-06-27 09:36:58 -04:00
Louis Dionne d6bfedd8ba [libc++] Remove dummy command in Dockerfile
It turns out that the Docker images on CI instances are not updated
based on what's in this file, but instead when a new image is pushed
to ldionne/libcxx-builder on DockerHub. So this is effectively useless.
2022-06-27 09:17:34 -04:00
Louis Dionne 633d1d0df7 [libc++] Use bounded iterators in std::span when the debug mode is enabled
Previously, we'd use raw pointers when the debug mode was enabled,
which means we wouldn't get out-of-range checking with std::span's
iterators.

This patch introduces a new class called __bounded_iter which can
be used to wrap iterators and make them carry around bounds-related
information. This allows iterators to assert when they are dereferenced
outside of their bounds.

As a fly-by change, this commit removes the _LIBCPP_ABI_SPAN_POINTER_ITERATORS
knob. Indeed, not using a raw pointer as the iterator type is useful to
avoid users depending on properties of raw pointers in their code.

This is an alternative to D127401.

Differential Revision: https://reviews.llvm.org/D127418
2022-06-27 08:34:45 -04:00
Louis Dionne 92df8c2736 [libc++] Improve Lit's buildhost=XXXX feature on a few platforms
Differential Revision: https://reviews.llvm.org/D128455
2022-06-27 08:33:44 -04:00
Nikolas Klauser 31ae52859f [libc++] Simplify type_traits and use more builtins
Reviewed By: ldionne, #libc

Spies: manojgupta, cjdb, ayzhao, alanphipps, libcxx-commits

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

Stuff
2022-06-26 14:57:20 +02:00
Manoj Gupta da0448a361 Revert "[libc++] Simplify type_traits and use more builtins"
This reverts commit 42f8f55798.

Breaks float128 usage, test case provided in D127226.

Differential Revision: https://reviews.llvm.org/D128587
2022-06-25 12:38:05 -07:00
Casey Carter c5ba46ea18 [libcxx][test] MaybePOCCAAllocator should meet the Cpp17Allocator requirements
Implement `rebind`, the rebinding constructor, and rebind-compatible comparison operators.

Differential Revision: https://reviews.llvm.org/D118279
2022-06-25 11:02:42 -07:00
Xing Xue 60f7bdfd03 [libc++][AIX] Make basic_string layout compatible with earlier version
Summary:
Patch D123580 changed to use bit fields for strings in long and short mode. As a result, this changes the layout of these strings on AIX because bit fields on AIX are 4 bytes, which breaks the ABI compatibility with earlier strings before the change on AIX. This patch uses the attribute 'packed' and anonymous structure to make string layout compatible. This patch will also make test cases alignof.compile.pass.cpp and sizeof.compile.pass.cpp introduced in D127672 pass on AIX.

Reviewed by: philnik, Mordante, hubert.reinterpretcast, libc++

Differential Revision: https://reviews.llvm.org/D128285
2022-06-24 17:25:15 -04:00
Casey Carter d3cbcc4e89 [libcxx][test] barrier completion functions must be non-throwing
... per N4910 [thread.barrier.class]/5.
2022-06-24 09:06:47 -07:00
Hui Xie 16719cd011 [libc++] P2321R2 section [tuple.tuple]. Adding C++23 constructors, assignment operators and swaps to `tuple`
1. for constructors that takes cvref variation of tuple<UTypes...>, there
used to be two SFINAE helper _EnableCopyFromOtherTuple,
_EnableMoveFromOtherTuple. And the implementations of these two helpers
seem to slightly differ from the spec. But now, we need 4 variations.
Instead of adding another two, this change refactored it to a single one
_EnableCtrFromUTypesTuple, which directly maps to the spec without
changing the C++11 behaviour. However, we need the helper __copy_cvref_t
to get the type of std::get<i>(cvref tuple<Utypes...>) for different
cvref, so I made __copy_cvref_t to be available in C++11.

2. for constructors that takes variations of std::pair, there used to be
four helpers _EnableExplicitCopyFromPair, _EnableImplicitCopyFromPair,
_EnableImplicitMoveFromPair, _EnableExplicitMoveFromPair. Instead of
adding another four, this change refactored into two helper
_EnableCtrFromPair and _BothImplicitlyConvertible. This also removes the
need to use _nat

3. for const member assignment operator, since the requirement is very
simple, I haven't refactored the old code but instead directly adding
the new c++23 code.

4. for const swap, I pretty much copy pasted the non-const version to make
these overloads look consistent

5. while doing these change, I found two of the old constructors wasn't
marked constexpr for C++20 but they should. fixed them and added unit
tests

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D116621
2022-06-24 07:12:53 +01:00
Casey Carter 9aaba9d9bb [libcxx][test] Suppress complex<int> warnings when testing MSVC 2022-06-23 17:46:54 -07:00
Hui Xie 9dd7ad6fb5 Revert "[libc++] P2321R2 section [tuple.tuple]. Adding C++23 constructors, assignment operators and swaps to `tuple`"
When merging the changes of <type_traits> header with the commits on
this header over the last month, several conflicts were mistaken
resolved and the wrong branch was picked while resolving conflicts,
which leads to CI failure. In order to resolve the conflicts properly
with qualification CI job, this change is reverted.

This reverts commit 95733a55b9.
2022-06-23 21:58:30 +01:00
Hui Xie 95733a55b9 [libc++] P2321R2 section [tuple.tuple]. Adding C++23 constructors, assignment operators and swaps to `tuple`
1. for constructors that takes cvref variation of tuple<UTypes...>, there
used to be two SFINAE helper _EnableCopyFromOtherTuple,
_EnableMoveFromOtherTuple. And the implementations of these two helpers
seem to slightly differ from the spec. But now, we need 4 variations.
Instead of adding another two, this change refactored it to a single one
_EnableCtrFromUTypesTuple, which directly maps to the spec without
changing the C++11 behaviour. However, we need the helper __copy_cvref_t
to get the type of std::get<i>(cvref tuple<Utypes...>) for different
cvref, so I made __copy_cvref_t to be available in C++11.

2. for constructors that takes variations of std::pair, there used to be
four helpers _EnableExplicitCopyFromPair, _EnableImplicitCopyFromPair,
_EnableImplicitMoveFromPair, _EnableExplicitMoveFromPair. Instead of
adding another four, this change refactored into two helper
_EnableCtrFromPair and _BothImplicitlyConvertible. This also removes the
need to use _nat

3. for const member assignment operator, since the requirement is very
simple, I haven't refactored the old code but instead directly adding
the new c++23 code.

4. for const swap, I pretty much copy pasted the non-const version to make
these overloads look consistent

5. while doing these change, I found two of the old constructors wasn't
marked constexpr for C++20 but they should. fixed them and added unit
tests

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D116621
2022-06-23 21:28:57 +01:00
Louis Dionne 23d6cde14d [libc++] Add a test to pin down the set of transitive public includes
A situation that happens fairly often in libc++ is that we remove some
transitive includes in a header (either purposefully or not) and that
ends up breaking users. Of course, we want to be able to remove our
transitive includes, however it's also good to have a grip on that
to know which commit changed what and when. Furthermore, it's good
to accumulate include removals for a couple of releases to avoid
breaking users at every release for this reason.

This commit adds a test that should break whenever we remove an
include. Hence, it should allow us to track which headers include
which other headers transitively, giving us a traceable way to
remove headers.

Differential Revision: https://reviews.llvm.org/D128236
2022-06-23 16:23:34 -04:00
Mark de Wever 9afaa158f5 [libc++][format] Copy code to new location.
This is a helper patch to ease the reviewing of D128139.
The originals will be removed at a later time when all formatters are
converted to the new style. (Floating-point and pointer aren't up for
review yet.)

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D128367
2022-06-23 17:21:37 +02:00
Nikolas Klauser 2c3bbac0c7 [libc++] Implement ranges::move{, _backward}
This patch also adds a new optimization to `std::move`. It unwraps three `reverse_iterator`s if the wrapped iterator is a `contiguous_iterator` and the iterated type is trivially_movable. This allows us to simplify `ranges::move_backward` to a forward to `std::move` without any pessimization.

Reviewed By: var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D126616
2022-06-23 13:52:49 +02:00
Nikolas Klauser 56a33ba3dd [libc++] Implement P0154R1 (Hardware inference size)
`__GCC_CONSTRUCTIVE_SIZE` and `__GCC_DESTRUCTIVE_SIZE` are available since GCC 12. I'm assuming clang will also implement these for compatability with libstdc++.

Reviewed By: ldionne, #libc

Spies: h-vetinari, libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D122276
2022-06-23 01:31:09 +02:00
Nikolas Klauser 758504b8ab [libc++] Simplify the visibility attributes
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D128007
2022-06-23 01:30:32 +02:00
Joe Loser f7d434ef29
[libc++] Clarify std::function release note
Replace "This option it" with "This option" to make the sentence read a bit
clearer.

Differential Revision: https://reviews.llvm.org/D128362
2022-06-22 12:25:31 -06:00
Mark de Wever 21ba9d0b62 [libc++][NFC] Merges unused functions in callers.
This is a follow up based on a request of @jloser in D127594.

As drive-by qualified the function calls in the <bit> header.

Reviewed By: #libc, EricWF

Differential Revision: https://reviews.llvm.org/D127760
2022-06-22 19:46:13 +02:00
Mark de Wever cf927669eb [libc++] Reduces std::to_chars instantiations.
Instead of instantiating all functions called by std::to_chars for the
integral types only instantiate them for 32 and 64 bit integral types.
This results in a smaller binary when using different types.

In an example using the types: signed char, short, int, long, long long,
unsigned char, unsigned short, unsigned int, unsigned long, and
unsigned long long this saved 2792 bytes of code size. For libc++.so.1
is saves 688 bytes of code size (64-bit Linux).

This was discovered while investigating a solution for #52709.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D128215
2022-06-22 18:47:08 +02:00
Mark de Wever 88c279b1d9 [libc++][CI] Use GCC 12 labels. 2022-06-22 18:11:19 +02:00
Mark de Wever 65f44c9218 [libc++] Fixes GCC-12 build. 2022-06-22 17:26:17 +02:00
Hui Xie 20869c5ba0 [libc++] fix views::all hard error on lvalue move only views instead of SFINAE
For an lvalue reference to a move only view x, views::all(x) gives hard error because the expression inside noexcept is not well formed and it is not SFINAE friendly.

Given a move only view type `V`, and a concept

```
template <class R>
concept can_all = requires {
    std::views::all(std::declval<R>());
};
```

The expression `can_all<V&>` returns
libstdc++: false
msvc stl : false
libc++   : error: static_cast from 'V' to 'typename decay<decltype((std::forward<V &>(__t)))>::type' (aka 'V') uses deleted function
      noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))))

The standard spec has its own problem, the spec says it is expression equivalent to `decay-copy(E)` but the spec of `decay-copy` does not have any constraint, which means the expression `decay-copy(declval<V&>())` is well-formed and the concept `can_all<V&>` should return true and should error when instantiating the function body of decay-copy. This is clearly wrong behaviour in the spec and we will probably create an LWG issue. But the libc++'s behaviour is clearly not correct. The `noexcept` is an "extension" in libc++ which is not in the spec, but the expression inside `noexpect` triggers hard error, which is not right.

Reviewed By: #libc, ldionne, var-const

Differential Revision: https://reviews.llvm.org/D128281
2022-06-22 09:50:16 +01:00
Nikolas Klauser 681cde7dd8 [libc++] Complete the implementation of N4190
Fixes #37402

Reviewed By: ldionne

Spies: EricWF, avogelsgesang, libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D124346
2022-06-22 10:13:03 +02:00
Nikolas Klauser c475e31a18 [libc++] Remove std::function in C++03
`std::function` has been deprecated for a few releases now. Remove it with an option to opt-back-in with a note that this option will be removed in LLVM 16.

Reviewed By: ldionne, #libc

Spies: #libc_vendors, EricWF, jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D127908
2022-06-22 10:02:30 +02:00
Mark de Wever 77ad77c071 [libc++][format] Improve string formatters
This changes the implementation of the formatter. Instead of inheriting
from a specialized parser all formatters will use the same generic
parser. This reduces the binary size.

The new parser contains some additional fields only used in the chrono
formatting. Since this doesn't change the size of the parser the fields
are in the generic parser. The parser is designed to fit in 128-bit,
making it cheap to pass by value.

The new format function is a const member function. This isn't required
by the Standard yet, but it will be after LWG-3636 is accepted.
Additionally P2286 adds a formattable concept which requires the member
function to be const qualified in C++23. This paper is likely to be
accepted in the 2022 July plenary.

Depends on D121530

NOTE parts of the code now contains duplicates for the current and new parser.
The intention is to remove the duplication in followup patches. A general
overview of the final code is available in D124620. That review however lacks a
bit of polish.

Most of the new code is based on the same algorithms used in the current code.

The final version of this code reduces the binary size by 17 KB for this example
code
```

int main() {
  {
    std::string_view sv{"hello world"};
    std::format("{}{}|{}{}{}{}{}{}|{}{}{}{}{}{}|{}{}{}|{}{}|{}", true, '*',
                (signed char)(42), (short)(42), (int)(42), (long)(42), (long long)(42), (__int128_t)(42),
                (unsigned char)(42), (unsigned short)(42), (unsigned int)(42), (unsigned long)(42),
                (unsigned long long)(42), (__uint128_t)(42),
                (float)(42), (double)(42), (long double)(42),
                "hello world", sv,
                nullptr);
  }
  {
    std::wstring_view sv{L"hello world"};
    std::format(L"{}{}|{}{}{}{}{}{}|{}{}{}{}{}{}|{}{}{}|{}{}|{}", true, L'*',
                (signed char)(42), (short)(42), (int)(42), (long)(42), (long long)(42), (__int128_t)(42),
                (unsigned char)(42), (unsigned short)(42), (unsigned int)(42), (unsigned long)(42),
                (unsigned long long)(42), (__uint128_t)(42),
                (float)(42), (double)(42), (long double)(42),
                L"hello world", sv,
                nullptr);
  }
}

```

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D125606
2022-06-22 07:40:36 +02:00
Nikolas Klauser 43913357b4 [libc++] Pass -fno-modules to clang-tidy instead of disabling it for the modules build
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D128053
2022-06-21 20:28:27 +02:00
Nikolas Klauser 26ac9cbf00 [libc++][clang-tidy] Enable bugprone-use-after-move and explicitly list all used checks
Reviewed By: #libc, ldionne

Spies: aheejin, libcxx-commits, xazax.hun

Differential Revision: https://reviews.llvm.org/D127896
2022-06-21 20:25:04 +02:00
Mark de Wever eb12ad9d7f [libc++][CI] Updates GCC to version 12.
Reviewed By: ldionne, philnik, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D126667
2022-06-21 18:59:20 +02:00
Mark de Wever 3561ee586e [libc++] Improve charconv base10 algorithm.
This change is a preparation to add the 128-bit integral output.

Before
```
--------------------------------------------------------------
Benchmark                    Time             CPU   Iterations
--------------------------------------------------------------
BM_to_chars_good/2        20.1 ns         20.1 ns     35045000
BM_to_chars_good/3         117 ns          117 ns      5916000
BM_to_chars_good/4        83.7 ns         83.7 ns      8401000
BM_to_chars_good/5        70.6 ns         70.6 ns      9915000
BM_to_chars_good/6        59.9 ns         59.9 ns     11678000
BM_to_chars_good/7        53.9 ns         53.8 ns     12995000
BM_to_chars_good/8        19.0 ns         19.0 ns     37110000
BM_to_chars_good/9        45.9 ns         45.8 ns     15278000
BM_to_chars_good/10       9.24 ns         9.24 ns     75343000
BM_to_chars_good/11       42.6 ns         42.6 ns     16449000
BM_to_chars_good/12       38.8 ns         38.8 ns     18101000
BM_to_chars_good/13       38.8 ns         38.8 ns     17999000
BM_to_chars_good/14       37.7 ns         37.6 ns     18571000
BM_to_chars_good/15       35.8 ns         35.8 ns     19660000
BM_to_chars_good/16       15.4 ns         15.4 ns     46129000
BM_to_chars_good/17       32.3 ns         32.3 ns     21763000
BM_to_chars_good/18       32.8 ns         32.8 ns     21396000
BM_to_chars_good/19       33.4 ns         33.4 ns     21078000
BM_to_chars_good/20       33.3 ns         33.3 ns     21020000
BM_to_chars_good/21       32.3 ns         32.3 ns     21807000
BM_to_chars_good/22       31.6 ns         31.6 ns     22057000
BM_to_chars_good/23       30.7 ns         30.7 ns     22938000
BM_to_chars_good/24       28.3 ns         28.3 ns     24659000
BM_to_chars_good/25       28.2 ns         28.2 ns     24790000
BM_to_chars_good/26       28.4 ns         28.4 ns     24410000
BM_to_chars_good/27       28.7 ns         28.7 ns     24423000
BM_to_chars_good/28       28.9 ns         28.9 ns     24139000
BM_to_chars_good/29       28.9 ns         28.9 ns     24347000
BM_to_chars_good/30       29.2 ns         29.2 ns     24141000
BM_to_chars_good/31       29.6 ns         29.6 ns     23699000
BM_to_chars_good/32       29.5 ns         29.5 ns     23933000
BM_to_chars_good/33       28.9 ns         28.9 ns     24042000
BM_to_chars_good/34       28.7 ns         28.7 ns     24361000
BM_to_chars_good/35       28.3 ns         28.3 ns     24703000
BM_to_chars_good/36       28.1 ns         28.1 ns     24924000
BM_to_chars_bad/2         6.16 ns         6.15 ns    114101000
BM_to_chars_bad/3         14.5 ns         14.5 ns     48244000
BM_to_chars_bad/4         16.9 ns         16.9 ns     41974000
BM_to_chars_bad/5         12.5 ns         12.5 ns     56080000
BM_to_chars_bad/6         10.9 ns         10.9 ns     64036000
BM_to_chars_bad/7         14.5 ns         14.5 ns     47294000
BM_to_chars_bad/8         6.36 ns         6.35 ns    110430000
BM_to_chars_bad/9         12.4 ns         12.4 ns     56448000
BM_to_chars_bad/10        5.13 ns         5.13 ns    137596000
BM_to_chars_bad/11        9.88 ns         9.88 ns     69015000
BM_to_chars_bad/12        10.8 ns         10.8 ns     63990000
BM_to_chars_bad/13        10.7 ns         10.7 ns     65066000
BM_to_chars_bad/14        9.71 ns         9.71 ns     71775000
BM_to_chars_bad/15        9.18 ns         9.18 ns     75267000
BM_to_chars_bad/16        6.12 ns         6.12 ns    115000000
BM_to_chars_bad/17        10.7 ns         10.7 ns     65504000
BM_to_chars_bad/18        10.6 ns         10.6 ns     65685000
BM_to_chars_bad/19        9.98 ns         9.98 ns     69894000
BM_to_chars_bad/20        9.74 ns         9.74 ns     72098000
BM_to_chars_bad/21        9.25 ns         9.25 ns     75184000
BM_to_chars_bad/22        9.10 ns         9.10 ns     75602000
BM_to_chars_bad/23        9.48 ns         9.48 ns     72824000
BM_to_chars_bad/24        9.27 ns         9.27 ns     75112000
BM_to_chars_bad/25        9.61 ns         9.61 ns     72080000
BM_to_chars_bad/26        9.72 ns         9.72 ns     72178000
BM_to_chars_bad/27        10.0 ns         10.0 ns     69733000
BM_to_chars_bad/28        10.3 ns         10.3 ns     67409000
BM_to_chars_bad/29        9.97 ns         9.97 ns     69193000
BM_to_chars_bad/30        10.1 ns         10.1 ns     69007000
BM_to_chars_bad/31        9.68 ns         9.68 ns     72232000
BM_to_chars_bad/32        8.99 ns         8.99 ns     76825000
BM_to_chars_bad/33        8.82 ns         8.82 ns     79293000
BM_to_chars_bad/34        8.64 ns         8.64 ns     80441000
BM_to_chars_bad/35        8.96 ns         8.96 ns     75320000
BM_to_chars_bad/36        8.87 ns         8.87 ns     77293000

```

After
```
--------------------------------------------------------------
Benchmark                    Time             CPU   Iterations
--------------------------------------------------------------
BM_to_chars_good/2        14.7 ns         14.7 ns     47583000
BM_to_chars_good/3         101 ns          101 ns      6901000
BM_to_chars_good/4        68.4 ns         68.4 ns     10088000
BM_to_chars_good/5        58.2 ns         58.2 ns     12007000
BM_to_chars_good/6        51.1 ns         51.1 ns     13687000
BM_to_chars_good/7        45.6 ns         45.6 ns     15323000
BM_to_chars_good/8        14.6 ns         14.6 ns     47795000
BM_to_chars_good/9        40.7 ns         40.7 ns     17371000
BM_to_chars_good/10       7.48 ns         7.48 ns     90931000
BM_to_chars_good/11       37.6 ns         37.6 ns     18542000
BM_to_chars_good/12       35.2 ns         35.2 ns     19922000
BM_to_chars_good/13       34.9 ns         34.9 ns     20105000
BM_to_chars_good/14       33.5 ns         33.5 ns     20863000
BM_to_chars_good/15       31.9 ns         31.9 ns     22014000
BM_to_chars_good/16       11.7 ns         11.7 ns     60012000
BM_to_chars_good/17       28.9 ns         28.9 ns     24148000
BM_to_chars_good/18       29.0 ns         29.0 ns     24317000
BM_to_chars_good/19       28.7 ns         28.7 ns     24363000
BM_to_chars_good/20       28.1 ns         28.1 ns     24899000
BM_to_chars_good/21       27.5 ns         27.5 ns     25499000
BM_to_chars_good/22       26.9 ns         26.9 ns     25929000
BM_to_chars_good/23       26.2 ns         26.2 ns     26828000
BM_to_chars_good/24       25.1 ns         25.1 ns     27742000
BM_to_chars_good/25       25.3 ns         25.3 ns     27720000
BM_to_chars_good/26       25.2 ns         25.2 ns     27789000
BM_to_chars_good/27       25.3 ns         25.3 ns     27777000
BM_to_chars_good/28       25.3 ns         25.3 ns     27643000
BM_to_chars_good/29       25.3 ns         25.3 ns     27750000
BM_to_chars_good/30       25.4 ns         25.4 ns     27566000
BM_to_chars_good/31       25.4 ns         25.4 ns     27611000
BM_to_chars_good/32       25.8 ns         25.8 ns     27218000
BM_to_chars_good/33       25.7 ns         25.7 ns     27070000
BM_to_chars_good/34       26.1 ns         26.1 ns     26693000
BM_to_chars_good/35       26.4 ns         26.4 ns     26486000
BM_to_chars_good/36       26.3 ns         26.3 ns     26619000
BM_to_chars_bad/2         5.99 ns         5.99 ns    118787000
BM_to_chars_bad/3         14.3 ns         14.3 ns     48567000
BM_to_chars_bad/4         16.0 ns         16.0 ns     43239000
BM_to_chars_bad/5         12.6 ns         12.6 ns     55354000
BM_to_chars_bad/6         10.7 ns         10.7 ns     65491000
BM_to_chars_bad/7         14.4 ns         14.4 ns     48723000
BM_to_chars_bad/8         6.50 ns         6.50 ns    104967000
BM_to_chars_bad/9         12.0 ns         12.0 ns     56552000
BM_to_chars_bad/10        5.16 ns         5.16 ns    136380000
BM_to_chars_bad/11        10.5 ns         10.5 ns     66764000
BM_to_chars_bad/12        10.7 ns         10.7 ns     65534000
BM_to_chars_bad/13        11.0 ns         11.0 ns     63426000
BM_to_chars_bad/14        9.90 ns         9.90 ns     68575000
BM_to_chars_bad/15        9.52 ns         9.52 ns     70932000
BM_to_chars_bad/16        6.14 ns         6.14 ns    111762000
BM_to_chars_bad/17        10.6 ns         10.6 ns     65883000
BM_to_chars_bad/18        10.5 ns         10.5 ns     67606000
BM_to_chars_bad/19        9.96 ns         9.96 ns     68898000
BM_to_chars_bad/20        9.40 ns         9.41 ns     73116000
BM_to_chars_bad/21        9.12 ns         9.12 ns     78647000
BM_to_chars_bad/22        8.95 ns         8.95 ns     80211000
BM_to_chars_bad/23        9.50 ns         9.49 ns     73571000
BM_to_chars_bad/24        9.29 ns         9.29 ns     74690000
BM_to_chars_bad/25        9.65 ns         9.65 ns     72877000
BM_to_chars_bad/26        9.78 ns         9.78 ns     70171000
BM_to_chars_bad/27        10.1 ns         10.1 ns     69543000
BM_to_chars_bad/28        10.4 ns         10.4 ns     67582000
BM_to_chars_bad/29       10.00 ns        10.00 ns     70806000
BM_to_chars_bad/30        9.99 ns         9.99 ns     70340000
BM_to_chars_bad/31        9.56 ns         9.56 ns     74159000
BM_to_chars_bad/32        8.97 ns         8.97 ns     78052000
BM_to_chars_bad/33        8.86 ns         8.86 ns     78586000
BM_to_chars_bad/34        8.81 ns         8.81 ns     78562000
BM_to_chars_bad/35        8.90 ns         8.90 ns     77384000
BM_to_chars_bad/36        9.04 ns         9.04 ns     77263000

```

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D127764
2022-06-21 17:45:40 +02:00
Mark de Wever 5517bc6c4a [libc++][format] Improves the handle test.
A formatter using a handle only needs to satisfy the BasicFormatter
requirements. The current test allowed more than that minimum. Changed
it to the minimum to make sure it works.

This was due to a post-commit review comment of @vitaut in D121530.

Reviewed By: ldionne, vitaut, #libc

Differential Revision: https://reviews.llvm.org/D127767
2022-06-21 17:24:57 +02:00
Nikolas Klauser 2fcf99d703 [libc++] Implement P0174R2 (Deprecating Vestigial Library Parts in C++17)
Reviewed By: ldionne, Mordante, #libc

Spies: jwakely, libcxx-commits

Differential Revision: https://reviews.llvm.org/D127387
2022-06-21 08:22:44 +02:00
Nikolas Klauser 3766992291 [libc++] Add Implemented Papers section
Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D127674
2022-06-18 17:29:31 +02:00
Nikolas Klauser 55cb62f34a [libc++] Enable -Wweak-vtables
This makes Clang scream at us if there is a class without a key function.

Reviewed By: ldionne, #libc

Spies: libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D127900
2022-06-18 17:27:33 +02:00
Konstantin Varlamov d417710c3a [libc++][ranges][NFC] Fix a format error on the ranges status page. 2022-06-18 02:22:26 -07:00
Louis Dionne 8da8b61430 [libc++] Make sure we install libc++abi headers on Apple
Differential Revision: https://reviews.llvm.org/D127526
2022-06-17 17:35:05 -04:00
Louis Dionne 303c4c37ea [libc++] Don't force -O2 when building the benchmarks
The optimization level used when building the benchmarks should
match the optimization level of the current build. Otherwise, we
can end up mixing an -O3 or -O0 optimized dylib with benchmarks
built with -O2, which is really misleading.

Differential Revision: https://reviews.llvm.org/D127987
2022-06-17 17:34:02 -04:00
Nikolas Klauser db1978b674 [libc++] Mark standard-mandated includes as such
Reviewed By: ldionne, Mordante, #libc, saugustine

Spies: saugustine, MaskRay, arichardson, mstorsjo, jloser, libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D127953
2022-06-17 20:43:33 +02:00
Nikolas Klauser 971e9c80e9 [libc++] Implement std::boyer_moore{, _horspool}_searcher
This mostly copys the `<experimental/functional>` stuff and updates the code to current libc++ style.

Reviewed By: ldionne, #libc

Spies: nlopes, adamdebreceni, arichardson, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D121074
2022-06-17 19:09:40 +02:00
Nikolas Klauser fb3477a4da [libc++] Unwrap reverse_iterator<reverse_iterator<Iter>> in __unwrap_iter
Simplify the implementation of `std::copy` and `std::move` by using `__unwrap_iter` and `__rewrap_iter` to unwrap and rewrap `reverse_iterator<reverse_iterator<Iter>>` instead of specializing `__copy_impl` and `__move_impl`.

Reviewed By: ldionne, #libc

Spies: wenlei, libcxx-commits

Differential Revision: https://reviews.llvm.org/D127049
2022-06-17 18:47:18 +02:00
Nikolas Klauser 929d5de22c [libc++] Simplify __config a bit
Simplify logic in `__config` by assuming that we are using Clang in C++03 mode. Also, use standardized feature-test macros instead of compiler-specific checks (like `__has_feature`) in a couple of places.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D127606
2022-06-17 15:54:31 +02:00
Konstantin Varlamov ff3989e6ae [libc++][ranges] Implement `ranges::sort`.
Differential Revision: https://reviews.llvm.org/D127557
2022-06-16 15:21:06 -07:00
Louis Dionne eea1531ba4 [libc++] Remove now-unused experimental/filesystem config file 2022-06-16 15:34:43 -04:00
Mark de Wever 3433f78c40 [libc++][doc] Update formatting status. 2022-06-16 19:37:49 +02:00
Nikolas Klauser c5312fe3be Revert "[libc++] Test the size of basic_string"
This reverts commit 147f74b6ee.
2022-06-16 18:01:22 +02:00
Nikolas Klauser a4c805600e [libc++] Robust against C++20-hostile iterators
Reviewed By: ldionne, #libc, EricWF

Spies: EricWF, libcxx-commits, mgrang

Differential Revision: https://reviews.llvm.org/D127669
2022-06-16 13:26:53 +02:00
Nikolas Klauser 147f74b6ee [libc++] Test the size of basic_string
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D127672
2022-06-16 10:43:01 +02:00
Nikolas Klauser afd5a4f2dc [libc++] Implement ranges::lexicographical_compare
Reviewed By: var-const, Mordante, #libc

Spies: H-G-Hristov, sstefan1, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D127130
2022-06-15 22:29:21 +02:00
Mark de Wever 4cd04d1687 [libc++] Removes unneeded <iterator> includes.
Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D127675
2022-06-15 18:14:05 +02:00
Ilya Biryukov 374f938fe8 [libcxx] Fix allocator<void>::pointer in C++20 with removed members
When compiled with `-D_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS`
uses of `allocator<void>::pointer` resulted in compiler errors after D104323.
If we instantiate the primary template, `allocator<void>::reference` produces
an error 'cannot form references to void'.

To workaround this, allow to bring back the `allocator<void>` specialization by defining the new `_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION` macro.

To make sure the code that uses `allocator<void>` and the removed members does not break,
both `_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS` and `_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS` have to be defined.

Reviewed By: ldionne, #libc, philnik

Differential Revision: https://reviews.llvm.org/D126210
2022-06-15 10:55:56 +02:00
owenca 462b49f18c [libcxx] Remove extraneous '---' lines in .clang-format files 2022-06-15 01:34:37 -07:00
Joe Loser cb48ed38b8
[libc++][NFCI] span: replace enable_if with concepts
Several span constructors use `enable_if` which is verbose. Replace these with
concepts or requires expressions.
2022-06-14 21:25:50 -06:00
Nikolas Klauser e7c72d69ac [libc++] Find a clang-format everybody is happy with
We decided that we want to use clang-format for libc++ but we haven't decided yet how the code should be formatted. We should probably discuss things on discord. This PR is mostly to show how the clang-format would look like and to commit to one once we decided on it. I'll remove the `<string>` diff when I commit this PR.

Reviewed By: ldionne

Spies: EricWF, dschuff, krytarowski, fedor.sergeev, aheejin, mstorsjo, phosek, abrachet, libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D124789
2022-06-14 20:12:33 +02:00
Alex Brachet 93c46e9632 [libc++] Use explicit module cache path in tests
For reference, this test creates about 1.5G in the cache
directory. By default this will go to ~/.cache/clang/
which can fill up quick. This changes the test to put the
cache path in lit temp directories. Size considerations
aside it makes sense for tests to be hermetic and not
touch global system state.

Differential revision: https://reviews.llvm.org/D127587
2022-06-14 18:06:59 +00:00
David Tenty 73c273c97a [NFC][libcxx] Check def of __LONG_DOUBLE_IEEE128__
Follow on to https://reviews.llvm.org/D108352, also check for the
definition of __LONG_DOUBLE_128__ before using it (because AIX doesn't
enable it by default).

Reviewed By: xingxue

Differential Revision: https://reviews.llvm.org/D127002
2022-06-14 13:41:31 -04:00
Jake Egan 3af7aa5202 [libcxx][AIX] Enable ABI list checking for XCOFF
The existing nm extractors can't dump the loader symbol table information we need to do the ABI checks for XCOFF, so provide an implementation using the system dump utility. We match the symbol name, whether it's defined, it's import/export status, and its storage mapping class.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D124165
2022-06-14 13:16:00 -04:00
Louis Dionne ee78181f34 [libc++] Remove macros for IBM compiler
It's not tested or used anymore -- instead a Clang-based compiler is
used on IBM nowadays.

Differential Revision: https://reviews.llvm.org/D127650
2022-06-14 09:15:41 -04:00
Nikolas Klauser ac251726f8 [libc++][NFC] clang-format <__config>
It's not perfect, but it's a lot better than the status quo.

Reviewed By: ldionne, #libc

Spies: EricWF, aheejin, libcxx-commits, dschuff, krytarowski, fedor.sergeev, mstorsjo, phosek, abrachet

Differential Revision: https://reviews.llvm.org/D127644
2022-06-14 06:47:38 +02:00
Jake Egan 1cf4113952 [libcxx][AIX] Switch build compiler to clang
This patch switches the build compiler for AIX from ibm-clang to clang. ibm-clang++_r has `-pthread` by default, but clang for AIX doesn't, so `-pthread` had to be added to the test config. A bunch of tests now pass, so the `XFAIL` was removed. This patch also switch the build to use the visibility support available in clang-15 to control symbols exported by the shared library (AIX traditionally uses explicit export lists for this purpose).

Reviewed By: #libc, #libc_abi, daltenty, #libunwind, ldionne

Differential Revision: https://reviews.llvm.org/D127470
2022-06-13 21:45:18 -04:00
Nikolas Klauser 993a22ecca [libc++] Simplify the char_traits specializations
Reviewed By: ldionne, #libc

Spies: mgorny, EricWF, mclow.lists, libcxx-commits

Differential Revision: https://reviews.llvm.org/D127159
2022-06-13 21:38:13 +02:00
Nikolas Klauser 3abaefe64c [libc++] Granularize some more of <type_traits>
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D127631
2022-06-13 21:37:26 +02:00
Mark de Wever 23b10a4a66 [libc++][NFC] Use concepts in <bit>.
All supported compilers have concepts support so use that in the C++20
functions in <bit>.

s/_LIBCPP_INLINE_VISIBILITY/_LIBCPP_HIDE_FROM_ABI/ as drive-by fix.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D127594
2022-06-13 18:17:48 +02:00
Mark de Wever c36870c8e7 [libc++] Removes unneeded includes.
This removes all "TODO: remove these headers" comments from our headers.

Note there seem to be more headers that can be removed, that will be
done in separate commits.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D127592
2022-06-13 17:56:50 +02:00
Mark de Wever 26465c8337 [libc++] Removes a GCC bug work-around.
Based on the comments in [1] this should be fixed in GCC-11.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37804

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D127590
2022-06-13 17:55:43 +02:00
Mark de Wever 883dd770d7 [libc++][test] Remove support old compiler support.
The compilers clang-11, clang-12, and apple-clang-12 are no longer
supported, so remove their annotations in the tests.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D127588
2022-06-13 17:54:27 +02:00
Louis Dionne 5b386ac912 [libc++] Do not yield from __sp_mut::lock()
Instead of trying to be clever and design our own locking primitive,
simply rely on the OS-provided implementation to do the right thing.

Indeed, manually yielding to the OS does not provide the necessary
information for it to make good prioritization decisions. For example,
if a thread with higher priority yields while waiting for a lock held
by a thread with lower priority but the system is contended, it is
possible for the thread with lower priority to not run until the higher
priority thread has yielded 16 times and goes for __libcpp_mutex_lock().
Once that happens, the OS can bump the priority of the thread that
currently holds the lock to unblock everyone. So instead, we might as
well give the system all the information from the start so it can make
appropriate decisions.

As a fly-by change, also increase the number of locks in the table.
The size increase is modest, but has the potential to half the amount
of contention on those locks.

rdar://93598606

Differential Revision: https://reviews.llvm.org/D126882
2022-06-13 11:48:13 -04:00
Nikolas Klauser 988682a389 [libc++] Fix std::lower_bound with C++20-hostile iterators
Reviewed By: EricWF, #libc

Spies: sstefan1, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D127577
2022-06-13 12:19:28 +02:00
Petr Hosek 186a13f647 [CMake][libcxx] Use target_include_directories for libc++ headers
This is the idiomatic way to handle include directories in CMake.

Differential Revision: https://reviews.llvm.org/D122614
2022-06-12 22:17:50 +00:00
Nikolas Klauser 0d108f7908 [libc++] Use unsigned char in basic_string::__short again
D125496 changed the string layout on windows. Change `__is_long_` and `__size_` back to using `unsigned char` to fix the issue.

Reviewed By: Mordante, #libc

Spies: jloser, libcxx-commits, ayzhao

Differential Revision: https://reviews.llvm.org/D127566
2022-06-12 21:06:46 +02:00
Joe Loser c115e760c2
[libc++][test] Add tuple trivial destructor test
There is only compile-time tests in `dtor.pass.cpp`, so it could be made a
`dtor.compile.pass.cpp`. Instead, add a runtime test for testing the trivial
destructor behavior for `tuple`.

Differential Revision: https://reviews.llvm.org/D109298
2022-06-11 18:11:04 -06:00
Joe Loser ae2ae84ffe
[libc++][test] Refactor SmallBasicString uses in range.lazy.split tests
The tests for `std::ranges::lazy_split_view` heavily use a wrapper class around
`std::string` because `std::string` was not `constexpr` until recently. Where
possible, remove the wrapper class and extra functionality no longer needed.
Remove `libcxx/test/std/ranges/range.adaptors/range.lazy.split/small_string.h`
and inline its one use remaining in
`libcxx/test/std/ranges/range.adaptors/range.lazy.split/general.pass.cpp`.

Differential Revision: https://reviews.llvm.org/D126663
2022-06-11 13:10:02 -06:00
Nikolas Klauser ee397722cc [libc++][NFC] Update ranges algorithms status page 2022-06-11 16:21:34 +02:00
Mark de Wever aed5ddf8d0 [libc++][format] Implement format-string.
Implements the compile-time checking of the formatting arguments.

Completes:
- P2216 std::format improvements

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D121530
2022-06-11 15:25:56 +02:00
Nikolas Klauser 6f27eb6ece [libc++] Use the same implementation of invoke for C++03 and C++11
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D127489
2022-06-10 23:18:20 +02:00
Nikolas Klauser 3cd4531b9b [libc++] Granularize <iterator> includes
Reviewed By: ldionne, #libc

Spies: libcxx-commits, wenlei

Differential Revision: https://reviews.llvm.org/D127445
2022-06-10 22:43:57 +02:00
Nikolas Klauser 42f8f55798 [libc++] Simplify type_traits and use more builtins
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D127226
2022-06-10 22:41:40 +02:00
Louis Dionne d00e035a42 [libc++] Make sure we install the modulemap file with install-cxx-headers 2022-06-10 15:15:35 -04:00
Nikolas Klauser 13558334f3 [libc++] Remove uses of __two in type_traits
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D127483
2022-06-10 19:56:59 +02:00
Louis Dionne 959a9923de [libc++][NFC] Fix indentation of some #if directives 2022-06-10 10:11:24 -04:00
Nikolas Klauser 1972d1e86a [libc++] Granularize even more of type_traits
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D126593
2022-06-10 11:56:38 +02:00
Nikolas Klauser ff6d5dee71 [libc++] Implement ranges::replace{, _if}
Reviewed By: var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D126283
2022-06-10 11:54:46 +02:00
Mark de Wever 075990236f [libc++] Fixes CI after Jammy update.
Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D127419
2022-06-09 21:57:07 +02:00
Louis Dionne 353324eb14 [libc++] Mark GDB pretty printers as unsupported on GCC 11.2 to make CI green 2022-06-09 15:51:02 -04:00
Martin Storsjö 8ab2c384b8 [libcxx] [doc] Add a release note for distributors about MinGW builds and dllimport
This allows distributors to simplify how libc++ is built in MinGW
configurations.

Differential Revision: https://reviews.llvm.org/D127151
2022-06-09 22:26:22 +03:00
Nikolas Klauser 976f37050d [libc++] Granularize __string
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D127156
2022-06-09 21:04:18 +02:00
Florian Mayer 4110c2c657 [NFC] change error message wording. 2022-06-09 08:49:03 -07:00
Florian Mayer d7e438c016 [libcxx] improve LIBCXX_ABI_NAMESPACE error message
include the invalid LIBCXX_ABI_NAMESPACE to ease debugging.

Reviewed By: #libc, jloser, ldionne

Differential Revision: https://reviews.llvm.org/D127257
2022-06-09 08:47:51 -07:00
Mark de Wever a7bd1ab776 [libc++][CI] Updates Docker image.
- Updates the image to use Ubuntu Jammy.
- Installs GCC-12 as preparation to migrate to that GCC version.

NOTE: This is a re-application of f2f0dba818, which was reverted
in 2b5e3ef83c due to an issue with the CI nodes. The CI nodes have
since then been updated and this appears to be fine.

Differential Revision: https://reviews.llvm.org/D126666
2022-06-09 08:53:20 -04:00
Louis Dionne 2ae52326da [libc++] Towards a simpler extern template story in libc++
The flexibility around extern template instantiation declarations in
libc++ result in a very complicated model, especially when support for
slightly different configurations (like the debug mode or assertions
in the dylib) are taken into account. That results in unexpected bugs
like http://llvm.org/PR50534 (and there have been multiple similar
bugs in the past, notably around the debug mode).

This patch gets rid of the _LIBCPP_DISABLE_EXTERN_TEMPLATE knob, which
I don't think is fundamental. Indeed, the motivation for that knob was to
avoid taking a dependency on the library, however that can be done better
by linking against the static library instead. And in fact, some parts of
the headers will always depend on things defined in the library, which
defeats the original goal of _LIBCPP_DISABLE_EXTERN_TEMPLATE.

Differential Revision: https://reviews.llvm.org/D103960
2022-06-08 22:05:07 -04:00
Louis Dionne 0e9a01dcac [libc++] Fix modules builds when features are removed
When some headers are not available because we removed features like
localization or threads, the compiler should not try to include these
headers when building modules. To avoid that from happening, add a
requires-declaration that is never satisfied when the configuration
in use doesn't support a header.

rdar://93777687

Differential Revision: https://reviews.llvm.org/D127127
2022-06-08 18:48:25 -04:00
Mark de Wever 2b5e3ef83c Revert "[libc++][CI] Updates Docker image."
This reverts commit f2f0dba818.

This Docker file doesn't work on the CI. It fails to clone the checkout.
This seems like an issue with a newer glibc on an older Docker where the
clone3() call fails.

This needs further investigation before relanding.
2022-06-08 19:18:35 +02:00
Louis Dionne 0392d425bb [libc++][NFC] Add missing 'return 0' 2022-06-08 12:56:20 -04:00
Louis Dionne 7611eb4869 [libc++][NFC] Simplify enable_if for std::copy optimization
Get rid of the __is_trivially_copy_assignable_unwrapped helper, which
is only used in one place, and use __iter_value_type instead of
iterator_traits<T>::value_type.

Differential Revision: https://reviews.llvm.org/D127230
2022-06-08 12:46:08 -04:00
Louis Dionne 90668adf68 [libc++] Make sure we add /llvm to the list of safe directories
With the new version of Git in Ubuntu Jammy (which is now what we use in
our Docker image), we need to add `/llvm` to the list of safe directories
to avoid failures.
2022-06-08 12:26:17 -04:00
Nikolas Klauser 916e9052ba [libc++] Implement ranges::adjacent_find
Reviewed By: Mordante, var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D126610
2022-06-08 12:15:03 +02:00
Joe Loser b2aec7e6ed
Revert "[libc++][test] Mark ranges.transform.pass.cpp UNSUPPORTED for AIX"
This reverts commit 3583826bb5.

Instead of marking the test unsupported for AIX, the choice is to bump the
timeout for CI as done in 76c7e1f2a8 and
222bd83d50

Differential Revision: https://reviews.llvm.org/D127242
2022-06-07 19:00:56 -06:00
Louis Dionne f3966eaf86 [libc++] Make the Debug mode a configuration-time only option
The debug mode has been broken pretty much ever since it was shipped
because it was possible to enable the debug mode in user code without
actually enabling it in the dylib, leading to ODR violations that
caused various kinds of failures.

This commit makes the debug mode a knob that is configured when
building the library and which can't be changed afterwards. This is
less flexible for users, however it will actually work as intended
and it will allow us, in the future, to add various kinds of checks
that do not assume the same ABI as the normal library. Furthermore,
this will make the debug mode more robust, which means that vendors
might be more tempted to support it properly, which hasn't been the
case with the current debug mode.

This patch shouldn't break any user code, except folks who are building
against a library that doesn't have the debug mode enabled and who try
to enable the debug mode in their code. Such users will get a compile-time
error explaining that this configuration isn't supported anymore.

In the future, we should further increase the granularity of the debug
mode checks so that we can cherry-pick which checks to enable, like we
do for unspecified behavior randomization.

Differential Revision: https://reviews.llvm.org/D122941
2022-06-07 16:33:53 -04:00
Mark de Wever b968c3452b [libc++] Removes _LIBCPP_AVAILABILITY_TO_CHARS.
After moving the std::to_chars base 10 implementation from the dylib to
the header the integral overloads of std::to_chars are available on all
platforms.

Remove the _LIBCPP_AVAILABILITY_TO_CHARS availability macro and update
the tests.

Depends on D125704

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D125745
2022-06-07 18:59:19 +02:00
Mark de Wever f2f0dba818 [libc++][CI] Updates Docker image.
- Updates the image to use Ubuntu Jammy.
- Installs GCC-12 as preparation to migrate to that GCC version.

Reviewed By: ldionne, #libc, jloser

Differential Revision: https://reviews.llvm.org/D126666
2022-06-07 18:52:31 +02:00
Mark de Wever dea7a8e616 [libc++] Don't use static constexpr in headers.
This was noticed in the review of D125704. In that commit only the new
table has been adapted. This adapts the existing tables.

Note since libc++'s charconv is backported to C++11 it's not possible to
use inline constexpr variables. The were introduced in C++17.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D126887
2022-06-07 18:47:44 +02:00
Louis Dionne 222bd83d50 [libc++] Forgot to bump the CI timeout everywhere 2022-06-07 10:01:01 -04:00
Louis Dionne 76c7e1f2a8 [libc++] Bump timeout to avoid spurious failures on AIX 2022-06-07 10:00:32 -04:00
Nikolas Klauser b79b2b6772 [libc++] Implement ranges::find_first_of
Reviewed By: Mordante, var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D126529
2022-06-06 22:29:02 +02:00
Martin Storsjö dfa88927ae [libcxx] Omit dllimport in public headers in MinGW mode
In MinGW environments, thanks to slightly different code generation
and linker tricks, it's possible to link against a DLL C++ standard
library without dllimport attributes.

This allows using one single set of headers for linking against
either the DLL or a static library, leaving the decision entirely
up to the linking stage (where it can be switched with options like
-static-libstdc++).

This matches how libstdc++ headers work; there's no dllimport attributes
by default (unless the user has defined _GLIBCXX_DLL when including
headers).

This allows using one single set of headers while linking against
either a DLL or a static library, just like on Unix platforms.

This matches how libc++ has been used in MinGW configurations for
years (by first building the DLL, then configuring a static-only
build and installing on top, overwriting the libc++ config file
with one for static linking) by multiple MinGW toolchains, making
the dllimport-less use the de-facto tested configuration in the wild.

This also allows building all of libc++ in one single CMake
configuration, instead of having to do two separate builds on top of
each other.

(Linking against a DLL without dllimport can break if e.g. templates
use inconsistent visibility attributes - in cases where it still
works when using explicit dllimport; such a case was fixed in
948dd664c3 / D99932. With this as the
default configuration, we can catch such issues in CI.)

Differential Revision: https://reviews.llvm.org/D125924
2022-06-06 23:19:22 +03:00
Martin Storsjö 4940caaebb [libcxx] [test] Don't use header defines for detecting linking against a DLL
In clang-cl/MSVC environments, linking against a DLL C++ standard
library requires having dllimport attributes in the headers; this
has been used for detecting whether the tests link against a DLL,
by looking at the libc++ specific define
_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS.

In mingw environments, thanks to slightly different code generation
and a couple linker tricks, it's possible to link against a DLL C++
standard library without dllimport attributes. Therefore, don't
rely on the libc++ specific header define for the detection.

Replace the detection with a runtime test.

Differential Revision: https://reviews.llvm.org/D125922
2022-06-06 23:19:22 +03:00
Louis Dionne a8cf78c739 [libc++][NFC] Move span tests under views.span 2022-06-06 14:06:05 -04:00
Louis Dionne 2453c515ac [libc++][NFC] Fix outdated comment in span test 2022-06-06 14:06:05 -04:00
Louis Dionne eebbfbcd50 [libc++][NFC] Add missing includes 2022-06-06 12:58:23 -04:00
Louis Dionne b8f6f9e741 [libc++] Avoid creating temporaries in unary expressions involving valarray
Currently, unary expressions involving valarray will create a temporary.
This leads to dangling references in expressions like `-a * b`, because
`-a` is a temporary and the resulting expression will refer to it. This
patch fixes the problem by creating a lazy expression to perform the unary
operation instead of eagerly creating a temporary valarray. This is
permitted by the Standard, which does not specify the exact type of
most expressions involving valarrays.

This is technically an ABI break, however I believe the actual potential
for breakage is very low.

rdar://90152242

Differential Revision: https://reviews.llvm.org/D125019
2022-06-06 12:58:23 -04:00
Louis Dionne 4eab04f849 [libc++] Remove a bunch of conditionals on _LIBCPP_DEBUG_LEVEL
Instead of providing two different constructors for iterators that
support the debug mode, provide a single constructor but leave the
container parameter unused when the debug mode is not enabled.

This allows simplifying all the call sites to unconditionally pass
the container, which removes a bunch of duplication in the container's
implementation.

Note that this patch does add some complexity to std::span, however
that is only because std::span has the ability to use raw pointers
as iterators instead of __wrap_iter. In retrospect, I believe it was
a mistake to provide that capability, and so it will be removed in a
future patch, along with the complexity added by this patch.

Differential Revision: https://reviews.llvm.org/D126993
2022-06-06 09:54:26 -04:00
Nikolas Klauser 8171586176 [libc++][ranges] Implement ranges::binary_search and ranges::{lower, upper}_bound
Reviewed By: Mordante, var-const, ldionne, #libc

Spies: sstefan1, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D121964
2022-06-06 13:33:18 +02:00
David Spickett c8db406127 Revert "[libcxx] Temporarily skip Arm configs"
This reverts commit d4220af527.

Linaro bots are back online.
2022-06-06 08:25:51 +00:00
Joe Loser 3583826bb5
[libc++][test] Mark ranges.transform.pass.cpp UNSUPPORTED for AIX
The `ranges.transform.pass.cpp` often times out on CI for AIX (32-bit and 64-bit)
only. Mark the test as `UNSUPPORTED` for `AIX` for now. It should be looked into in
the future.

Differential Revision: https://reviews.llvm.org/D127051
2022-06-05 13:45:29 -06:00
varconst 7c63cc198b [libc++][ranges][NFC] Fix a patch link in ranges status. 2022-06-03 20:39:00 -07:00
varconst faf43ad7ae [libc++][ranges][NFC] Mark range algorithms that are in progress. 2022-06-03 20:02:46 -07:00
Joe Loser 4fc502368a
[libc++][test] Skip string_view tests for other vendors on older modes
`string_view` is supported all the way back to C++03 as an extension in
`libc++`, and so many of the tests run in all standards modes for all vendors.
This is unlikely desired by other standard library vendors using our test suite.
So, disable the tests for vendors other than `libc++` in these older standards
modes.

Differential Revision: https://reviews.llvm.org/D126850
2022-06-03 13:51:49 -06:00
Nikolas Klauser ef8e918261 [libc++] Forward more often to memmove in copy
In D122982 I accidentally disabled the memmove optimization. This re-enables it and adds more cases where copy forwards to memmove.
Fixes https://github.com/llvm/llvm-project/issues/33687

Reviewed By: var-const, #libc, ldionne

Spies: pkasting, ayzhao, dcheng, xbolva00, libcxx-commits

Differential Revision: https://reviews.llvm.org/D124328
2022-06-03 20:29:18 +02:00
Nikolas Klauser a29a1a33ac [libc++] Fix conjunction/disjunction and mark a few LWG issues as complete
Fixes #54803
Fixes #53133

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D125221
2022-06-03 10:31:42 +02:00
Joe Loser 4be36dc77f
[libc++][test] Fix unused variable warning in string_view tests
In 6423a9f0ec, I accidentally thought this was
getting tested, but these variables are unused. Just remove the lines instead of
leaving them commented out.

Differential Revision: https://reviews.llvm.org/D126901
2022-06-02 13:33:37 -06:00
Will Hawkins 7b291b6f50 [libc++] Fix typo in comment at __optional_storage_base
Small typo fix(es) for struct definition of __optional_storage_base for
a reference type.

Reviewed By: #libc, jloser, philnik

Differential Revision: https://reviews.llvm.org/D126621
2022-06-02 19:46:04 +02:00
Mark de Wever 89818f2dc0 [libc++] Lets to_chars use header implementation.
This removes the duplicated code from the dylib. Instead the dylib will
call the new functions in the header. Since this code is unneeded it's
removed from the unstable ABI.

Depends on D125704

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D125761
2022-06-02 17:11:32 +02:00
Joe Loser 6423a9f0ec
[libc++][test] Enable some more string_view tests
Some test cases for `ends_with.ptr.pass` and `starts_with.ptr.pass` for
`string_view` are commented out, but work just fine. Uncomment them.

Differential Revision: https://reviews.llvm.org/D126849
2022-06-02 08:56:02 -06:00
Xing Xue dfaee3c9cf [libunwind][ci][AIX] Add libunwind to buildbot CI
Summary:
This patch changes scripts to add libunwind CI on AIX. Test config file ibm-libunwind-shared.cfg.in is introduced for testing on AIX.

Reviewed by: ldionne, MaskRay, libunwind, ibc++abi

Differential Revision: https://reviews.llvm.org/D126017
2022-06-02 09:03:10 -04:00
Mark de Wever b3d1142d09 [libc++][doc] Fixes unwanted list nesting. 2022-06-02 08:02:19 +02:00
Mark de Wever a15ae4139c [libc++] Make to_chars base 10 header only.
The functions to_chars and from_chars should offer 128-bit support. This
is the first step to implement 128-bit version of to_chars. Before
implementing 128-bit support the current code will be polished.

This moves the code from the dylib to the header in prepartion of

P2291 "Add Constexpr Modifiers to Functions to_chars and from_chars for
Integral Types in <charconv> Header"

Note some more cleanups will be done in follow-up commits
- Remove the _LIBCPP_AVAILABILITY_TO_CHARS from to_chars. With all code
  in the header the availablilty macro is no longer needed. This
  requires enabling the unit tests for additional platforms.
- The code in the dylib can switch to using the header implementation.
  This allows removing the code duplicated in the header and the dylib.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D125704
2022-06-02 08:00:31 +02:00
Joe Loser 93a375a15c
[libc++][test] Enable constexpr string comparison tests
Some tests in `string.view.comparison` are not enabled due to previous lack of
support for `constexpr std::string`. Now that it is implemented, we can enable
these tests.

Differential Revision: https://reviews.llvm.org/D126737
2022-06-01 19:26:20 -06:00
Mark de Wever 10c4eec278 [NFC][libc++][format] Improves naming.
Based on review comments in D110499.

Depends on D110499

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D125610
2022-06-01 21:05:31 +02:00
Mark de Wever 04a3146caa [libc++][format] Fixes string-literal formatting.
Formatting a string-literal had an off-by-one issue where the NUL
terminator became part of the formatted output.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D126665
2022-06-01 17:49:09 +02:00
David Spickett d4220af527 [libcxx] Temporarily skip Arm configs
The machine hosting these agents will be down
for maintenance June 2nd.

We (Linaro) will remove this once the agents are back online.

Differential Revision: https://reviews.llvm.org/D126688
2022-06-01 08:37:32 +00:00
zhijian 44d5221adb [libc++][CI] AIX does not have alternative for time_put_byname
Reviewers: David Tenty, Mark de Wever

Differential Revision: https://reviews.llvm.org/D126376
2022-05-31 14:20:34 -04:00
zhijian fa958c3a94 [libc++][CI] fixed "LOCALE_fr_FR_UTF_8" for my_facet for AIX
SUMMARY:

fixed "LOCALE_fr_FR_UTF_8" for my_facet for AIX

Reviewers: David Tenty, Mark de Wever

Differential Revision: https://reviews.llvm.org/D125927
2022-05-31 14:12:01 -04:00
zhijian 248287fe0a [libc++][CI] fixed convert_thousands_sep_ru_RU for Russian in the libcxx/test/support/locale_helpers.h for AIX
Reviewers: David Tenty, Mark de Wever

Differential Revision: https://reviews.llvm.org/D125923
2022-05-31 13:55:59 -04:00
zhijian 9d1b260fae [libc++][CI][AIX] change grouping() return value of std::moneypunct_byname for en_US.UTF-8
Reviewers: David Tenty, Mark de Wever
Differential Revision: https://reviews.llvm.org/D126474
2022-05-31 13:20:31 -04:00
Mark de Wever 9e5c293492 [libc++] Removes __cpp_lib_monadic_optional.
P0798R8 "Monadic operations for std::optional" has been implemented, so
this LWG issue can be adopted.

During review it was discovered another paper bumped the macro. The
part affecting optional of this paper is done, the variant isn't. The
status page is updated to reflect the current state.

Implements
- LWG 3621 Remove feature-test macro __cpp_lib_monadic_optional

Updates status of
- P2231R1 Missing constexpr in std::optional and std::variant

Reviewed By: #libc, philnik, ldionne

Differential Revision: https://reviews.llvm.org/D125813
2022-05-31 19:18:34 +02:00
Joe Loser 40e52d3033
[libc++][test] Enable some ADL robust algorithm tests
Some algorithm ADL robustness tests are commented out, but work as is. Uncomment
them.

Differential Revision: https://reviews.llvm.org/D126670
2022-05-30 17:50:08 -06:00
Louis Dionne fe7cd1d199 [libc++][NFC] Improve comment about vector and string base class ABI flags 2022-05-30 16:26:49 -04:00
Louis Dionne f8239eec8d [libc++] Reduce the verbosity when running the libc++ Lit configuration
We print the same information as before, however we do it with less
verbosity unless `--debug` is used.
2022-05-30 12:03:24 -04:00
Joe Loser 7f1e048041
[libc++][test] Remove Clang <= 3.7 workaround in is_default_constructible test
Clang 3.7 and below is not actively used or supported in the test suite now, so
remove the workaround in the test.

Differential Revision: https://reviews.llvm.org/D126603
2022-05-29 11:57:06 -06:00
Mark de Wever 773c6e4358 [libc++][doc] Clarify wording on the status page.
Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D125630
2022-05-29 15:33:26 +02:00
Mark de Wever 4cb184ce1c [libc++] Adds __format_string as nasty macro.
Both D121530 and D125606 had issues with this macro.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D125629
2022-05-29 15:32:11 +02:00
Nikolas Klauser 7e69bd9bf0 [libc++] Use __enable_if_t and is_integral in cstddef
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D126469
2022-05-29 12:05:02 +02:00
Mark de Wever ebb6f3ce37 [libc++] Adds missing includes.
This fixes the broken Apple builds. This has been tested in D121530
(https://buildkite.com/llvm-project/libcxx-ci/builds/11113)
2022-05-29 11:11:32 +02:00
Sam Clegg b86771a2f7 [libc++] Minor emscripten changes from downstream
Differential Revision: https://reviews.llvm.org/D126583
2022-05-28 06:44:27 -07:00
Nikolas Klauser 30c37fb89c [libc++] Granularize more of <type_traits>
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D126244
2022-05-28 10:13:48 +02:00
Nikolas Klauser 34f73804ed [libc++] Remove unused __functional includes
Reviewed By: ldionne, #libc

Spies: arichardson, smeenai, libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D126098
2022-05-28 10:12:39 +02:00
Louis Dionne a7f9895cc1 [runtimes] Rename various libcpp-has-no-XYZ Lit features to just no-XYZ
Since those features are general properties of the environment, it makes
sense to use them from libc++abi too, and so the name libcpp-has-no-xxx
doesn't make sense.

Differential Revision: https://reviews.llvm.org/D126482
2022-05-27 15:24:45 -04:00
Nikolas Klauser eb1c50378e [libc++][NFC] Rename rand.dis to rand.dist
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgrang, mstorsjo

Differential Revision: https://reviews.llvm.org/D126221
2022-05-27 21:22:20 +02:00
Louis Dionne 719bf2d9d9 [runtimes] Officially deprecate the legacy testing configuration system
Add a warning and tweak the release note to explain that the deprecation
targets libc++, libc++abi and libuwnind as well.

Also, as a fly-by, ensure that our CI runs the legacy testing configuration
for libc++, libc++abi and libunwind. This doesn't matter too much since
it's deprecated, but we might as well test it properly.

Differential Revision: https://reviews.llvm.org/D126478
2022-05-27 13:15:48 -04:00
Louis Dionne c358d98b99 [libc++] Add various missing _LIBCPP_HIDE_FROM_ABI
Those were spotted when a project unintentionally started exporting
these symbols from its ABI just by using the libc++ headers.

Differential Revision: https://reviews.llvm.org/D126496
2022-05-27 13:14:57 -04:00
Hans Wennborg 865ad6bd21 [libc++] Use __libcpp_clz for a tighter __log2i function
While looking at D113413 I noticed that __log2i could perhaps be
improved to be both slightly smaller and faster.

projects/libcxx/benchmarks/sort.libcxx.out --benchmark_filter=BM_Sort_uint32_QuickSortAdversary*
suggests this is performance neutral, but it shaves a few bytes off the
benchmark binary, and even more off a Chromium build.

Differential revision: https://reviews.llvm.org/D125958
2022-05-27 18:53:59 +02:00
Nikolas Klauser 3606da5fba [libc++] Enable ranges_robust_against* and niebloid tests for implemented ranges algorithms
Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D126477
2022-05-27 10:40:01 +02:00
Nikolas Klauser 11e3ad299f [libc++] Implement ranges::is_sorted{, _until}
Reviewed By: Mordante, var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D125608
2022-05-27 10:28:44 +02:00
Louis Dionne eb1b1f2411 [libc++][NFC] Fix whitespace 2022-05-26 16:52:23 -04:00
Louis Dionne 92bbcfaa97 [libunwind] Tidy-up the testing configuration for libunwind
Start testing Apple backdeployment with older libunwinds, and stop
explicitly specifying the libunwind testing config, since it is
already selected correctly by default.

Differential Revision: https://reviews.llvm.org/D126470
2022-05-26 15:29:39 -04:00
Louis Dionne 3bba72e653 [libc++] Time tests during CI 2022-05-26 14:58:29 -04:00
Nikolas Klauser 0e3dc1a52f [libc++] Implement ranges::{all, any, none}_of
Reviewed By: ldionne, var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D123016
2022-05-26 16:50:08 +02:00
Louis Dionne f8c8bda965 [libc++] Remove temporary workaround for existing CMake caches
If you are broken by this change, you should remove your CMake cache and
re-run the CMake generation step.
2022-05-26 09:36:15 -04:00
Nikolas Klauser 569d663020 [libc++] Implement ranges::equal
Reviewed By: var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D123681
2022-05-26 10:46:54 +02:00
Joe Loser 5a2dbe49be
[libc++][test] Verify std::ranges::rbegin, crbegin, rend, crend are CPOs
Uncomment the tests to ensure `std::ranges::rbegin` and friends are indeed
customization points objects.

Differential Revision: https://reviews.llvm.org/D126325
2022-05-25 08:48:22 -06:00
Louis Dionne 8383351d45 [libc++] Remove conditional include 2022-05-25 10:04:54 -04:00
Louis Dionne d8afac7a2b [libc++] Use Python subprocess instead of libc++'s own utilities
Once we move off entirely from the legacy testing framework, this will
allow removing a bunch of code.

Differential Revision: https://reviews.llvm.org/D126303
2022-05-25 09:33:22 -04:00
Nikolas Klauser 7af89a379c [libc++] Implement ranges::fill{, _n}
Reviewed By: var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D123462
2022-05-25 10:27:13 +02:00
Louis Dionne 643df8fa8e [libc++] Make sure that all headers can be included with modules enabled
This commit ensures that we can include all libc++ headers with modules
enabled. It adds a test to ensure that this doesn't regress, which is
necessary because our modules CI job does not build in all Standard modes.

Differential Revision: https://reviews.llvm.org/D125331
2022-05-25 03:44:48 -04:00
Konstantin Varlamov b06049bc3b [libc++][NFC] Add more tests to `move_{iterator,sentinel}`.
More test coverage for the parts added by the One Ranges Proposal.

Differential Revision: https://reviews.llvm.org/D124906
2022-05-24 19:56:12 -07:00
Louis Dionne 6325184049 [libc++][NFC] Whitespace refactoring of string.cpp for consistency and legibility 2022-05-24 11:32:00 -04:00
Louis Dionne dc8a9a03ec [libc++][NFC] Move definitions around in string.cpp to reduce _LIBCPP_HAS_NO_WIDE_CHARACTERS blocks 2022-05-24 11:32:00 -04:00
Hans Wennborg ebe2e4f5b7 [libcxx] Add sort.bench.cpp to libcxx/benchmarks/CMakeLists.txt
It was forgotten in D124740.

Differential revision: https://reviews.llvm.org/D126297
2022-05-24 16:39:02 +02:00
Louis Dionne a9a6e20012 [libc++] Rename the generic-singlethreaded CI job to generic-no-threads for consistency 2022-05-24 09:58:57 -04:00
Nikolas Klauser 1d1a191edc [libc++] Implement ranges::reverse
Reviewed By: var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D125752
2022-05-24 10:33:57 +02:00
Laramie Leavitt b07880454b [libc++] Replace modulus operations in std::seed_seq::generate with conditional checks.
Abseil benchmarks suggest that the conditional checks result in faster code (4-5x)
as they are compiled into conditional move instructions (cmov on x86).

Reviewed By: #libc, philnik, Mordante

Spies: pengfei, Mordante, philnik, libcxx-commits

Differential Revision: https://reviews.llvm.org/D125329
2022-05-24 10:29:25 +02:00
Aaron Jacobs c3a2488290 [libc++] type_traits: use __is_core_convertible in __invokable_r.
This fixes incorrect handling of non-moveable types, adding tests for this case.
See [issue 55346](https://github.com/llvm/llvm-project/issues/55346).

The current implementation is based on is_convertible, which is
[defined](https://timsong-cpp.github.io/cppwp/n4659/meta.rel#5) in terms of
validity of the following function:

```
To test() {
  return declval<From>();
}
```

But this doesn't work if To and From are both some non-moveable type, which the
[definition](https://timsong-cpp.github.io/cppwp/n4659/conv#3) of implicit
conversions says should work due to guaranteed copy elision:

```
To to = E;  // E has type From
```

It is this latter definition that is used in the
[definition](https://timsong-cpp.github.io/cppwp/n4659/function.objects#func.require-2)
of INVOKE<R>. Make __invokable_r use __is_core_convertible, which
captures the ability to use guaranteed copy elision, making the
definition correct for non-moveable types.

Fixes llvm/llvm-project#55346.

Reviewed By: #libc, philnik, EricWF

Spies: EricWF, jloser, ldionne, philnik, libcxx-commits

Differential Revision: https://reviews.llvm.org/D125300
2022-05-24 10:22:40 +02:00
Louis Dionne 6cb3fdc278 [libc++] Remove duplicate tests for callable concepts
This is essentially a revert of c7ad02009. Indeed, it seems that both
96dbdd75 and c7ad02009 were committed, but c7ad02009 seems to be only
an older version of 96dbdd75's tests.
2022-05-23 15:38:49 -04:00
Nikolas Klauser 40f7fca3d9 [libc++] Add ranges::max_element to the synopsis and ADL-proof the __min_element_impl calls
Reviewed By: ldionne, #libc

Spies: sstefan1, libcxx-commits

Differential Revision: https://reviews.llvm.org/D126167
2022-05-23 20:50:04 +02:00
Nikolas Klauser 19e21d91bc [libc++] Add auto to the list of required extensions in C++03
We use `auto` in C++03, so we shouldn't say that we aren't.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D126165
2022-05-23 20:48:53 +02:00
Nikolas Klauser 5703905805 [libc++] Assume that push_macro and pop_macro are available
All compilers that libc++ supports support `push_macro` and `pop_macro`. So let's remove it.

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D126073
2022-05-23 20:47:44 +02:00
Nikolas Klauser b177a90ce7 [libc++] Always enable the ranges concepts
The ranges concepts were already available in libc++13, so we shouldn't guard them with `_LIBCPP_HAS_NO_INCOMPLETE_RANGES`.
Fixes https://github.com/llvm/llvm-project/issues/54765

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D124011
2022-05-23 20:44:34 +02:00
Nikolas Klauser eebc1fb772 [libc++] Granularize parts of <type_traits>
`<type_traits>` is quite a large header, so I'll granularize it in a few steps.

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D124755
2022-05-23 20:43:27 +02:00
Louis Dionne 1c4b31c38b [libc++] Improve error messages for disabled modes
We should not surface CMake-level options like LIBCXX_ENABLE_FILESYSTEM
to our users, since they don't know what it means. Instead, use a slightly
more general wording.

Also, add an error in <ios> to improve the quality of errors for people
trying to use <iostream> when localization is disabled.

Differential Revision: https://reviews.llvm.org/D125910
2022-05-20 09:36:55 -04:00
Louis Dionne 422ec52438 [libunwind] Introduce a cmake-bridge.cfg.in file to reduce test config duplication
Differential Revision: https://reviews.llvm.org/D125981
2022-05-20 09:36:29 -04:00
Louis Dionne 4431e8c84e [libc++] Override the value of LIBCXX_CXX_ABI in the cache
This will allow us to remove this entirely once the commit has propagated
through all CI and hence changed the value in the cache.
2022-05-19 11:21:09 -04:00
Louis Dionne fa7ce8e685 [runtimes] Fix the build of merged ABI/unwinder libraries
Also, add a CI job that tests this configuration. The exact configuration
is that we build a shared libc++ and merge objects for the ABI library
and the unwinder library into it.

Differential Revision: https://reviews.llvm.org/D125903
2022-05-19 10:49:36 -04:00
Nikolas Klauser f94a447679 [libc++] Granularize algorithm benchmarks
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny, mgrang

Differential Revision: https://reviews.llvm.org/D124740
2022-05-19 16:13:52 +02:00
Nikolas Klauser 06cf0ce90a [libc++] Enable move semantics for vector in C++03
We require move semantics in C++03 anyways, so let's enable them for the containers.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D123802
2022-05-19 16:11:56 +02:00
zhijian 4ac0589122 [libc++][CI] fixed a return curr_symbol() for Russian in the libcxx/test/support/locale_helpers.h for AIX
Summary:

fixed a return curr_symbol() for Russian in the libcxx/test/support/locale_helpers.h for AIX

Reviewers:  David Tenty,Mark de Wever
Differential Revision: https://reviews.llvm.org/D125801
2022-05-18 15:46:52 -04:00
Mark de Wever f0c06c0420 [libc++][format][5/6] Improve format_to_n.
Use a specialized buffer wrapper to limit the number of insertions in the
buffer. After the limit has been reached the buffer only needs to count
the number of insertions to return the buffer size required to store the
entire output.

Depends on D110498

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D110499
2022-05-18 20:14:32 +02:00
Mark de Wever 4d8268fbf4 [libc++][format] Improve format-arg-store.
This optimizes the __format_arg_store type to allow a more efficient
storage of the basic_format_args.

It stores the data in two arrays:
- A struct with the tag of the exposition only variant's type and the
  offset of the element in the data array. Since this array only depends
  on the type information it's calculated at compile time and can be
  shared by different instances of this class.
- The arguments converted to the types used in the exposition only
  variant of basic_format_arg. This means the packed data can be
  directly copied to an element of this variant.

The new code uses rvalue reference arguments in preparation for P2418.
The handle class also has some changes to prepare for P2418. The real
changed for P2418 will be done separately, but these parts make it
easier to implement that paper.

Some parts of existing test code are removed since they were no longer
valid after the changes, but new tests have been added.

Implements parts of:
- P2418 Add support for std::generator-like types to std::format

Completes:
- LWG3473 Normative encouragement in non-normative note

Depends on D121138

Reviewed By: #libc, vitaut, Mordante

Differential Revision: https://reviews.llvm.org/D121514
2022-05-18 20:11:36 +02:00
Mark de Wever f0e6102950 [libc++][format] Adds formatter<charT[N], charT>.
This formatter isn't in the list of required formatters in

[format.formatter.spec]/2.2
  For each charT, the string type specializations
   template<> struct formatter<charT*, charT>;
  template<> struct formatter<const charT*, charT>;
  template<size_t N> struct formatter<const charT[N], charT>;
  template<class traits, class Allocator>
    struct formatter<basic_string<charT, traits, Allocator>, charT>;
  template<class traits>
    struct formatter<basic_string_view<charT, traits>, charT>;

Since remove_cvref_t<const charT[N]> is charT[N] the formatter is
required by

[format.functions]/25
  Preconditions: formatter<remove_cvref_t<Ti>, charT> meets the
  BasicFormatter requirements ([formatter.requirements]) for each Ti in
  Args.

Depends on D120921

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D121138
2022-05-18 20:10:16 +02:00
Mark de Wever 15c809e8e7 [libc++][format] Adds a formattable concept.
The concept is based on P2286R2 Formatting Ranges. It will be used to
optimise the storage of __format_arg_store as required by LWG-3473.

Depends on D120916

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D120921
2022-05-18 20:02:08 +02:00
Martin Storsjö bedf657d0f [runtimes] Default LIB*_HERMETIC_STATIC_LIBRARY to ON on Windows
(In the case of libunwind, the cmake option is called
LIBUNWIND_HIDE_SYMBOLS, but it has the same effect as
LIBCXX_HERMETIC_STATIC_LIBRARY and
LIBCXXABI_HERMETIC_STATIC_LIBRARY.)

Previously, the same issue was dealt with by setting a project wide
define (_LIBUNWIND_HIDE_SYMBOLS,
_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS and
_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) if only building a static
library.  If building both static and shared at the same time, this
wasn't set, and the static library would contain dllexport directives.

The LIB*_HERMETIC_STATIC_LIBRARY and LIBUNWIND_HIDE_SYMBOLS cmake
options only apply the defines to the static library in the build,
even if building both static and shared at the same time.

(This could only be done use after the object libraries were
enabled, as a shared libcxx needs libcxxabi object files built
with dllexports included.)

This allows removing inelegant code for deciding how to build the
libcxxabi static library and a TODO comment that suggested that
users should need to start setting an option, which they shouldn't
need to. Finally, this gets rid of two XFAILs in tests.

Differential Revision: https://reviews.llvm.org/D125715
2022-05-18 20:31:51 +03:00
Jonathan Wakely 46d9a6ebd6 [libcxx] [test] Include header for strverscmp
Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122570
2022-05-18 14:36:23 +02:00
Jonathan Wakely 89cacb9ee7 [libcxx] [test] Add missing header for std::numeric_limits
Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122571
2022-05-18 14:36:02 +02:00
Louis Dionne 6de59ca417 [libc++] Introduce LIBCXX_LIBRARY_VERSION
This allows controlling the current_version linker property on Apple
platforms.

Differential Revision: https://reviews.llvm.org/D125686
2022-05-17 08:36:19 -04:00
Louis Dionne 193f458c30 [libc++] Remove overly conservative error in <stdatomic.h>
As mentionned in D97044, it is fine if users include <atomic> and then
include <stdatomic.h> -- we don't need to error out for that case.

Differential Revision: https://reviews.llvm.org/D125579
2022-05-16 15:30:01 -04:00
Louis Dionne efcee4b06d [libc++] Remove the legacy LIBCXX_LIBCPPABI_VERSION option
I think this notion of libc++abi's version was relevant a long time ago
on Apple platforms when we were using a Xcode project to build the library.
As part of moving Apple's build to CMake, D59489 made it possible to
specify the "ABI version" of libc++abi in use. However, it's not possible
to build libc++abi with that old ABI anymore and we don't need the ability
to link against that version from libc++ anymore.

Hence, we can clean this up and stop falsely pretending that libc++abi
has more than one ABI version.

Differential Revision: https://reviews.llvm.org/D125687
2022-05-16 15:23:43 -04:00
Louis Dionne aa656f6c2d [runtimes] Introduce object libraries
This is a variant of D116689 rebased on top of the new (proposed) ABI
refactoring in D120727. It should conserve the basic properties of the
original patch by @phosek, except it also allows cleaning up the merging
of libc++abi into libc++ from the libc++ side.

Differential Revision: https://reviews.llvm.org/D125393
2022-05-16 08:41:16 -04:00
Joe Loser 496e135b03
[libc++][test] Verify std::views::drop and std::views::join are CPOs
`std::views::drops` and `std::views::join` have been implemented, but the tests
verifying the CPOs for them are still commented out. Uncomment the tests.

Differential Revision: https://reviews.llvm.org/D125618
2022-05-14 22:11:36 -06:00
varconst 44ae09d75f [libc++][ranges][NFC] Mark completed issues related to the One Ranges Proposal.
Quite a few C++20 LWG issues/papers related to the One Ranges Proposal
were already effectively implemented (or contain semantic-only wording
changes that don't affect the implementation), mark them as such.

Differential Revision: https://reviews.llvm.org/D125065
2022-05-14 13:08:51 -07:00
Nikolas Klauser 5d55ffe94d [libc++] Simplify the string structures a bit more
This simplifies the string structs a bit more and the normal layout should not contain any undefined behaviour anymore. I don't think there is a way to achieve this in the alternate string mode without breaking the ABI.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D125496
2022-05-14 22:07:50 +02:00