Commit Graph

7642 Commits

Author SHA1 Message Date
Mark de Wever cfef7c918b [libc++][NFC] Remove _VSTD:: when not needed.
Reviewed By: #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D102133
2021-05-10 18:15:50 +02:00
jasonliu 4677d795b2 [libc++][AIX] Define _LIBCPP_ELAST
The aim is to define _LIBCPP_ELAST for AIX since strerror/strerror_r
can't handle out-of-range errno values.

Differential Revision: https://reviews.llvm.org/D100986
2021-05-10 13:54:30 +00:00
Mark de Wever 6ae15756a5 [libc++][doc] Update the Format library status.
- Move LWG-3218 to the chrono section.
- Mark the several parts 'In progress'.
2021-05-09 17:55:50 +02:00
Louis Dionne 2054474640 [libc++] NFC: Refactor Lit annotations
Annotations for c++03 mode are useless, since we only run these tests
in C++11 and C++14.
2021-05-08 12:16:41 -04:00
Louis Dionne 74d096e558 [libc++] Move handling of the target triple to the DSL
This fixes a long standing issue where the triple is not always set
consistently in all configurations. This change also moves the
back-deployment Lit features to using the proper target triple
instead of using something ad-hoc.

This will be necessary for using from scratch Lit configuration files
in both normal testing and back-deployment testing.

Differential Revision: https://reviews.llvm.org/D102012
2021-05-08 11:10:53 -04:00
Louis Dionne c42007e266 [libc++] Use Xcode's CMake if it's present
This resolves issues when the CMake in use on the host is too old to
configure libc++ properly, but Xcode has a sufficiently recent version.
It is technically possible for the reverse issue to happen, where the
Xcode version would be too old and the user-installed version would be
better, however in the context of our build bots, we use AppleClang on
Apple platforms, and the CMake shipped with Xcode should work with the
AppleClang shipped alongside that Xcode.

Differential Revision: https://reviews.llvm.org/D102083
2021-05-08 07:40:35 -04:00
Louis Dionne 8002c5d65f [libc++][ci] Run longer CI jobs first
Jobs that test with a more recent standard version run more tests, so
they take longer. We'll decrease the average latency by running them
first instead of last.
2021-05-07 13:57:07 -04:00
Arthur O'Dwyer f42355e17c [libc++] [test] Test that unordered_*::swap/move/assign does not invalidate iterators.
And remove the dedicated debug-iterator tests; we want to test this in all modes.
We have a CI step for testing the whole test suite with `--debug_level=1` now.

Part of https://reviews.llvm.org/D102003
2021-05-07 10:04:26 -04:00
Arthur O'Dwyer a1f75bf091 [libc++] [test] Simplify arithmetic in list.special/swap.pass.cpp. NFCI.
Part of https://reviews.llvm.org/D102003
2021-05-07 10:03:52 -04:00
Arthur O'Dwyer 8935c8449b [libc++] [test] Test that list::swap/move/move-assign does not invalidate iterators.
And remove the dedicated debug-iterator test; we want to test this in all modes.
We have a CI step for testing the whole test suite with `--debug_level=1` now.

Part of https://reviews.llvm.org/D102003
2021-05-07 10:03:23 -04:00
Martin Storsjö dafbfb1d1d [libcxx] Fix a case of -Wundef warnings. NFC.
Differential Revision: https://reviews.llvm.org/D101978
2021-05-07 11:16:01 +03:00
Louis Dionne fe0e86e602 [libc++] Rewrite std::to_address to avoid relying on element_type
This is a rough reapplication of the change that fixed std::to_address
to avoid relying on element_type (da456167). It is somewhat different
because the fix to avoid breaking Clang (which caused it to be reverted
in 347f69c55) was a bit more involved.

Differential Revision: https://reviews.llvm.org/D101638
2021-05-06 10:14:11 -04:00
Arthur O'Dwyer 9ea2db2c51 [libc++] [LIBCXX-DEBUG-FIXME] Stop using invalid iterators to insert into sets/maps.
This simply applies Howard's commit 4c80bfbd53 consistently
across all the associative and unordered container tests.

"unord.set/insert_hint_const_lvalue.pass.cpp" failed with `-D_LIBCPP_DEBUG=1`
before this patch; it was the only one that incorrectly reused
invalid iterator `e`. The others already used valid iterators
(generally `c.end()`); I'm just making them all match the same pattern
of usage: "e, then r, then c.end() for the rest."

Differential Revision: https://reviews.llvm.org/D101679
2021-05-05 16:21:09 -04:00
Arthur O'Dwyer 9571b8f238 [libc++] [LIBCXX-DEBUG-FIXME] std::advance shouldn't use ADL `>=` on the _Distance type.
Convert to a primitive type first; then use primitive `>=` on that value.

Differential Revision: https://reviews.llvm.org/D101678
2021-05-05 16:21:09 -04:00
Arthur O'Dwyer 165ad89947 [libc++] [LIBCXX-DEBUG-FIXME] Our `__debug_less` breaks some complexity guarantees.
`__debug_less` ends up running the comparator up-to-twice per comparison,
because whenever `(x < y)` it goes on to verify that `!(y < x)`.
This breaks the strict "Complexity" guarantees of algorithms like
`inplace_merge`, which we test in the test suite. So, just skip the
complexity assertions in debug mode.

Differential Revision: https://reviews.llvm.org/D101677
2021-05-05 16:21:09 -04:00
Arthur O'Dwyer 12dd9cdf1a [libc++] [LIBCXX-DEBUG-FIXME] Iterating a string::iterator "off the end" is UB.
The range of char pointers [data, data+size] is a valid closed range,
but the range [begin, end) is valid only half-open.

Differential Revision: https://reviews.llvm.org/D101676
2021-05-05 16:21:09 -04:00
Arthur O'Dwyer db9425cb06 [libc++] [LIBCXX-DEBUG-FIXME] Fix an iterator-invalidation issue in string::assign.
This appears to be a bug in our string::assign: when assigning into
a longer string, from a shorter snippet of itself, we invalidate
iterators before doing the copy. We should invalidate them afterward.
Also drive-by improve the formatting of a function header.

Differential Revision: https://reviews.llvm.org/D101675
2021-05-05 16:20:53 -04:00
Arthur O'Dwyer 0b10bb7ddd [libc++] Move <__sso_allocator> out of include/ into src/. NFCI.
This allocator is not intended for libc++'s users to use;
it's strictly an implementation detail of `src/locale.cpp`.
So, move it to the `src/include/` directory.

Drive-by const-qualify its comparison operators.

For consistency with `__hidden_allocator` (defined in `src/thread.cpp`),
do *not* remove it from "libcxx/lib/libc++unexp.exp",
"libcxx/utils/symcheck-blacklists/linux_blacklist.txt", etc.

Differential Revision: https://reviews.llvm.org/D101293
2021-05-05 16:20:52 -04:00
Martin Storsjö 9b24ff9cd2 [libcxx] [ci] Add a Windows CI configuration for a statically linked libc++
On Windows, static vs DLL linking affects details in quite a few
cases, so it's good to have coverage for both cases.

Testing with static linking also increases coverage for a number of
cases and individual checks that have had to be waived for the DLL
case, and allows testing libc++experimental, increasing the number
of test cases actually executed by 180 (176 new tests from
libc++experimental and 4 ones that are XFAIL windows-dll).

Also drop the "generic-" prefix from these configuration names, as
they're perhaps not what the "generic" prefix intended originally
in the other generic-posix configurations.

Differential Revision: https://reviews.llvm.org/D101565
2021-05-05 22:28:00 +03:00
Louis Dionne 7fbc7bfdfd [libc++] NFC: Remove stray semicolon in from-scratch config files 2021-05-05 15:06:12 -04:00
zoecarver 6f1b10df91 [libcxx][ranges] Add ranges::ssize CPO.
Based on D101079.

Differential Revision: https://reviews.llvm.org/D101189
2021-05-04 21:50:00 -07:00
zoecarver 600686d75f [libcxx][ranges] Add ranges::size CPO.
The begining of [range.prim].

Differential Revision: https://reviews.llvm.org/D101079
2021-05-04 21:50:00 -07:00
zoecarver 6ffc41b014 [libcxx][ranges] Add `random_access_{iterator,range}`.
Differential Revision: https://reviews.llvm.org/D101316
2021-05-04 21:42:55 -07:00
Louis Dionne 347f69c55f [libc++] Revert the std::to_address change to avoid relying on element_type.
This reverts commit da456167, which broke the Clang build. I'm able to
reproduce it but I want to give myself a bit more time to investigate.

Differential Revision: https://reviews.llvm.org/D101638
2021-05-04 18:50:05 -04:00
Arthur O'Dwyer da456167f5 [libc++] Make sure std::to_address doesn't depend on P::element_type.
Differential Revision: https://reviews.llvm.org/D101638
2021-05-04 16:59:25 -04:00
Louis Dionne 17f2d1cb9b [libc++] Fix QoI bug with construction of std::tuple involving std::any
In std::tuple, we should try to avoid calling std::is_copy_constructible
whenever we can to avoid surprising interactions with (I believe) compiler
builtins. This bug was reported in https://reviews.llvm.org/D96523#2730953.

The issue was that when tuple<_Up...> was the same as tuple<_Tp...>, we
would short-circuit the _Or (because sizeof...(_Tp) != 1) and go evaluate
the following `is_constructible<_Tp, const _Up&>...`. That shouldn't
actually be a problem, but see the analysis in https://reviews.llvm.org/D101770#2736470
for why it is with Clang and GCC.

Instead, after this patch, we check whether the constructed-from tuple
is the same as the current tuple regardless of the number of elements,
since we should always prefer the normal copy constructor in that case
anyway.

Differential Revision: https://reviews.llvm.org/D101770
2021-05-04 16:42:36 -04:00
Martin Storsjö e87fb6d387 [libcxx] Update docs regarding the need for bash/posix tools for tests on Windows. NFC.
After 39bbfb7726, bash is no longer
a hard requirement.

Differential Revision: https://reviews.llvm.org/D101779
2021-05-04 22:13:08 +03:00
Louis Dionne 6da1c46227 [libc++] NFC: Fix typo in Ranges Status 2021-05-04 13:06:58 -04:00
Louis Dionne 75952d6df6 [libc++] Move the Debug iterators check to CI stage 3
It's not a default configuration, so it belongs to stage 3.
2021-05-04 11:10:41 -04:00
Louis Dionne 2021d272ad [libc++] Implement ranges::view
Differential Revision: https://reviews.llvm.org/D101547
2021-05-04 11:05:58 -04:00
Christopher Di Bella 9c5d86aac5 [libcxx][iterator][ranges] adds `bidirectional_iterator` and `bidirectional_range`
Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D100275.

Differential Revision: https://reviews.llvm.org/D100278
2021-05-03 21:21:33 +00:00
Christopher Di Bella fa3e26266c [libcxx][iterator][ranges] adds `forward_iterator` and `forward_range`
Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D100271.

Differential Revision: https://reviews.llvm.org/D100275
2021-05-03 20:46:18 +00:00
Louis Dionne 39bbfb7726 [libc++] Use the internal Lit shell to run the tests
This makes the libc++ tests more portable -- almost all of them should
now work on Windows, except for some tests that assume a shell is
available on the target. We should probably provide a way to exclude
those anyway for the purpose of running tests on embedded targets.

Differential Revision: https://reviews.llvm.org/D89495
2021-05-03 14:44:42 -04:00
Louis Dionne 84f0bb6195 [libc++] Fix template instantiation depth issues with std::tuple
This fixes the issue by implementing _And using the short-circuiting
SFINAE trick that we previously used only in std::tuple. One thing we
could look into is use the naive recursive implementation for disjunctions
with a small number of arguments, and use that trick with larger numbers
of arguments. It might be the case that the constant overhead for setting
up the SFINAE trick makes it only worth doing for larger packs, but that's
left for further work.

This problem was raised in https://reviews.llvm.org/D96523.

Differential Revision: https://reviews.llvm.org/D101661
2021-05-03 14:42:07 -04:00
Louis Dionne 49e7be2e5b [libc++] Disentangle std::pointer_safety
This patch gets rid of technical debt around std::pointer_safety which,
I claim, is entirely unnecessary. I don't think anybody has used
std::pointer_safety in actual code because we do not implement the
underlying garbage collection support. In fact, P2186 even proposes
removing these facilities entirely from a future C++ version. As such,
I think it's entirely fine to get rid of complex workarounds whose goals
were to avoid breaking the ABI back in 2017.

I'm putting this up both to get reviews and to discuss this proposal for
a breaking change. I think we should be comfortable with making these
tiny breaks if we are confident they won't hurt anyone, which I'm fairly
confident is the case here.

Differential Revision: https://reviews.llvm.org/D100410
2021-05-03 14:33:49 -04:00
Marek Kurdej 40f783434b [docs] Automatically update copyright year in libc++. 2021-05-03 18:46:13 +02:00
Marek Kurdej 9d669e859b [docs] Bump the trunk major version to 13 and update copyright year. 2021-05-03 18:44:47 +02:00
Louis Dionne df280d1368 [libc++] Acquire locks on Ranges work
This commit acquires locks on a few elements of Ranges to make sure we don't
duplicate work.

Differential Revision: https://reviews.llvm.org/D101668
2021-05-03 10:39:53 -04:00
Christopher Di Bella f4b5753f88 [libcxx][nfc] removes duplicate test file
`test/std/ranges/range.access/range.access.cbegin/incomplete.compile.verify.cpp`
was accidentally copied (and apparently the author either forgot to
delete it or forgot to commit the deletion).

TEST=`ninja cxx && ninja check-cxx` locally
2021-05-02 17:43:05 +00:00
Mark de Wever 9f99a9faa3 [libc++][doc] Update the Format library status.
- Use the proper review for 'Fix integral conformance'.
- Mark 'Fix integral conformance' as completed.
- Move some tasks to in progress.
2021-05-02 13:13:55 +02:00
Christopher Di Bella 773ae44124 [libcxx][nfc] prefixes test type `input_iterator` with `cpp17_`
C++20 revised the definition of what it means to be an iterator. While
all _Cpp17InputIterators_ satisfy `std::input_iterator`, the reverse
isn't true. D100271 introduces a new test adaptor to accommodate this
new definition (`cpp20_input_iterator`).

In order to help readers immediately distinguish which input iterator
adaptor is _Cpp17InputIterator_, the current `input_iterator` adaptor
has been prefixed with `cpp17_`.

Differential Revision: https://reviews.llvm.org/D101242
2021-05-02 05:02:59 +00:00
Arthur O'Dwyer 9cad090e10 [libc++] [test] Don't nasty-macro `__opt` yet; we actually use that one.
This reverts another of the macros just added in D101613, because it turns out
that the <optional> and <filesystem> headers use the identifier __opt.
2021-05-01 10:11:46 -04:00
Arthur O'Dwyer 8a5e0d9563 [libc++] [test] Don't nasty-macro `__z` yet; we actually use that one.
This reverts one of the macros just added in D101613, because it turns out
that the <utility> header actually uses the identifiers __x, __y, __z.
We probably *shouldn't* use __z if it's reserved on Windows; but since
it's not causing us any active problem even on Windows, I think this is
the safest way to unbreak the test.
2021-05-01 09:09:06 -04:00
Martin Storsjö 8d0dfa0d57 [libcxx] Reenable ranges for clang-cl
This reverts a224bf8ec4 and fixes the
underlying issue.

The underlying issue is simply that MSVC headers contains a define
like "#define __in", where __in is one macro in the MSVC Source
Code Annotation Language, defined in sal.h

Just use a different variable name than "__in"
__indirectly_readable_impl, and add "__in" to nasty_macros.h just
like the existing __out. (Also adding a couple more potentially
conflicting ones.)

Differential Revision: https://reviews.llvm.org/D101613
2021-05-01 11:15:38 +03:00
Martin Storsjö 0e8f5e4a68 [libcxx] [test] Skip alloc counter checks for operations within the libc++ DLL
If libc++ is built as a DLL, calls to operator new within the DLL aren't
overridden if a user provides their own operator in calling code.
Therefore, the alloc counter doesn't pick up on allocations done within
std::string, so skip that check if running on windows. (Technically,
we could keep the checks if running on windows when not built as a DLL,
but trying to keep the conditionals simple.)

Differential Revision: https://reviews.llvm.org/D100219
2021-05-01 09:26:23 +03:00
Arthur O'Dwyer 6946f0ecca [libc++] [LIBCXX-DEBUG-FIXME] <span>, like <string_view>, has no use for debug iterators.
A span has no idea what container (if any) "owns" its iterators, nor
under what circumstances they might become invalidated.

However, continue to use `__wrap_iter<T*>` instead of raw `T*` outside
of debug mode, because we've been shipping `std::span` since Clang 7
and ldionne doesn't want to break ABI. (Namely, the mangling of functions
taking `span::iterator` as a parameter.) Permit using raw `T*` there,
but only under an ABI macro: `_LIBCPP_ABI_SPAN_POINTER_ITERATORS`.

Differential Revision: https://reviews.llvm.org/D101003
2021-04-30 23:06:45 -04:00
Arthur O'Dwyer 7e9cf2075a [libc++] s/begin.h/access.h/ in comments. NFCI. 2021-04-30 20:07:00 -04:00
Christopher Di Bella c05d1eed35 [libcxx][iterator][ranges] adds `input_iterator` and `input_range`
Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D100269.

Differential Revision: https://reviews.llvm.org/D100271
2021-04-30 22:49:06 +00:00
Arthur O'Dwyer 86d1f590c2 [libc++] [test] Add a debug-mode CI.
To run llvm-lit manually from the command line:

    ./bin/llvm-lit -sv --param std=c++2b --param cxx_under_test=`pwd`/bin/clang \
        --param debug_level=1 ../libcxx/test/

Tests that currently fail with `debug_level=1` are marked `LIBCXX-DEBUG-FIXME`,
but my intent is to deal with all of them and leave no such annotations in
the codebase within the next couple weeks. (I have patches for all of them
in my local checkout.)

Differential Revision: https://reviews.llvm.org/D100866
2021-04-30 18:08:09 -04:00
Arthur O'Dwyer 680c5d5de2 [libc++] Remove the line of stdout output from this generator. NFCI.
This line was confusing some people: it's not supposed to indicate
any kind of problem with the script, and I can't see any way it could
even help with troubleshooting. So, just silence it.
2021-04-30 18:08:00 -04:00
Louis Dionne ef89e8ca1c [libc++] Fix constexpr-ness of std::tuple's constructor
Mentioned in https://reviews.llvm.org/D96523.
2021-04-30 15:55:10 -04:00
Arthur O'Dwyer c92cdb4878 [libc++] [test] Recommit the unsetting of LC_COLLATE in the builder script.
This re-reverts one piece of 1b88557332,
reapplying one piece of D101437 (but not the "service"-queue piece of it).

It turns out that the behavior of `grep [^ -~]`, or even `grep [A-Z]`,
depends on locale, specifically `LC_COLLATE`. So we want to make sure
we're not in any weird locale, no matter what machine we're running on.
Yes, "en_US.UTF-8" counts as weird!
https://stackoverflow.com/questions/67320156/misbehavior-of-gnu-grep-when-grepping-for-ignores-spaces
https://stackoverflow.com/questions/6799872/how-to-make-grep-a-z-independent-of-locale
2021-04-30 14:49:10 -04:00
Petr Hosek dcbfb6f873 [libcxx] Use joined format for include flag on Windows
Without this, CMake deduplicates the /I flag breaking the build. See
https://cmake.org/cmake/help/v3.13/command/target_compile_options.html
for more details on why this is needed.

Differential Revision: https://reviews.llvm.org/D101550
2021-04-30 11:40:30 -07:00
Louis Dionne 1b88557332 [libc++] Revert the change that runs clang-format and generated-output in the service queue
This reverts commit 6712534ebc.

Differential Revision: https://reviews.llvm.org/D101437
2021-04-30 14:07:08 -04:00
Christopher Di Bella 7c17731596 [libcxx][ranges] adds `ranges::range`, `ranges::common_range`, and range aliases
* `std::ranges::range`
* `std::ranges::sentinel_t`
* `std::ranges::range_difference_t`
* `std::ranges::range_value_t`
* `std::ranges::range_reference_t`
* `std::ranges::range_rvalue_reference_t`
* `std::ranges::common_range`

`range_size_t` depends on `sized_range` and will be added alongside it.

Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D100255.

Differential Revision: https://reviews.llvm.org/D100269
2021-04-30 16:56:42 +00:00
Christopher Di Bella 5a3309f825 [libcxx][ranges] adds `range` access CPOs
* `std::ranges::begin`
* `std::ranges::cbegin`
* `std::ranges::end`
* `std::ranges::cend`
* `std::ranges::iterator` (required for `end`)

Implements parts of:
    * P0896R4 The One Ranges Proposal`

Co-author: @zoecarver

Depends on D90999, D100160.

Differential Revision: https://reviews.llvm.org/D100255
2021-04-30 16:56:42 +00:00
Arthur O'Dwyer 6712534ebc [libc++] [test] Run the clang-format and generated-output checks on the "service" queue
As these jobs only run in a couple seconds, and block starting of
other jobs, they can run on the "service" queue which doesn't get
blocked by other long-running jobs.

Differential Revision: https://reviews.llvm.org/D101437
2021-04-30 08:57:03 -04:00
Arthur O'Dwyer 5f51fb3421 [libc++] Minor cleanups in <iterator>. NFCI. 2021-04-30 08:52:58 -04:00
zoecarver 3aaac01aab [libcxx][ranges] Fix tests for stdlib types that conform to sized_sentinel_for.
Differential Revision: https://reviews.llvm.org/D101371
2021-04-29 14:44:16 -07:00
Mark de Wever 9393060f90 [libc++] Fixes std::to_chars for bases != 10.
While working on D70631, Microsoft's unit tests discovered an issue.
Our `std::to_chars` implementation for bases != 10 uses the range
`[first,last)` as temporary buffer. This violates the contract for
to_chars:
[charconv.to.chars]/1 http://eel.is/c++draft/charconv#to.chars-1
`to_chars_result to_chars(char* first, char* last, see below value, int base = 10);`
"If the member ec of the return value is such that the value is equal to
the value of a value-initialized errc, the conversion was successful and
the member ptr is the one-past-the-end pointer of the characters
written."

Our implementation modifies the range `[member ptr, last)`, which causes
Microsoft's test to fail. Their test verifies the buffer
`[member ptr, last)` is unchanged. (The test is only done when the
conversion is successful.)

While looking at the code I noticed the performance for bases != 10 also
is suboptimal. This is tracked in D97705.

This patch fixes the issue and adds a benchmark. This benchmark will be
used as baseline for D97705.

Reviewed By: #libc, Quuxplusone, zoecarver

Differential Revision: https://reviews.llvm.org/D100722
2021-04-29 19:56:28 +02:00
Martin Storsjö 203096adfc [libcxx] [test] Include more libraries that normally are linked automatically
As the libcxx tests link with -nostdlib, libraries that normally
are added by default by the compiler driver has to be added
manually.

The "oldnames" library is automatically added when driving linking
with clang-cl. When linking with the plain clang driver, as the
libcxx tests do, the clang driver does the same but only since Clang
12.0). But when linking with -nostdlib, like the libcxx tests do,
the driver defaults aren't added at all, and we need to specify the
defaults manually.

This allows removing a TODO from the Windows CI setup; it turns out
that upgrading to Clang 12.0 didn't help here as expected, sorry about
that mixup.

Differential Revision: https://reviews.llvm.org/D101434
2021-04-29 19:54:07 +03:00
Petr Hosek ea12d779bc [libc++] Support per-target __config_site in per-target runtime build
When using the per-target runtime build, it may be desirable to have
different __config_site headers for each target where all targets cannot
share a single configuration.

The layout used for libc++ headers after this change is:

```
include/
  c++/
    v1/
      <libc++ headers except for __config_site>
  <target1>/
    c++/
      v1/
        __config_site
  <target2>/
    c++/
      v1/
        __config_site
  <other targets>
```

This is the most optimal layout since it avoids duplication, the only
headers that's per-target is __config_site, all other headers are
shared across targets. This also means that we no need two
-isystem flags: one for the target-agnostic headers and one for
the target specific headers.

Differential Revision: https://reviews.llvm.org/D89013
2021-04-28 14:27:16 -07:00
Louis Dionne 3b1325cbd3 [libc++][NFC] Remove stray whitespace
This might have helped align static_asserts originally, but it doesn't
anymore since we use LIBCPP_STATIC_ASSERT.
2021-04-28 15:34:38 -04:00
Martin Storsjö 36418c3d14 [libcxx] Stop hardcoding the bash path in the Windows CI
The buildbots now have bash available in the path from the start.

Differential Revision: https://reviews.llvm.org/D101436
2021-04-28 22:02:49 +03:00
Mark de Wever bf72f6bacc [libc++][CI] Fix check-generated-output.
Before the script detected non-ASCII characters but let them pass. This
fixes the issue. I had a way to solve the issue, during review @Quuxplusone
suggested a better alternative. The patch has been changed to use this alternative.

Intended failed builds:
- Not updated generated files https://buildkite.com/llvm-project/libcxx-ci/builds/2822
- Not updated generated files and non-ASCII usage https://buildkite.com/llvm-project/libcxx-ci/builds/2835
- Non-ASCII usage https://buildkite.com/llvm-project/libcxx-ci/builds/2836

Reviewed By: #libc, Quuxplusone, curdeius

Differential Revision: https://reviews.llvm.org/D101303
2021-04-28 19:13:53 +02:00
Arthur O'Dwyer 045781a5ce [libc++] [test] Don't assume iterators are class types.
In particular, `span<int>::iterator` may be a raw pointer type
and thus have no nested typedef `iterator::value_type`. However,
we already know that the value_type we expect for `span<int>` is just `int`.
Fix up all other iterator_concept_conformance tests in the same way.

Differential Revision: https://reviews.llvm.org/D101420
2021-04-28 10:14:14 -04:00
Petr Hosek eea5cbc858 [libcxx] Fix the libc++abi header path
This addresses an issue introduced in 775e55462a.
2021-04-27 23:30:53 -07:00
Petr Hosek 36430d44ed [Driver] Use normalized triples for per-target runtimes
This is a partial revert of b4537c3f51
based on the discussion in https://reviews.llvm.org/D101194. Rather
than using the getMultiarchTriple, we use the getTripleString.
2021-04-27 22:31:36 -07:00
Martin Storsjö 4ebb01cbcb [libcxx] [test] Convert a couple of LIBCXX-WINDOWS-FIXME into XFAIL: windows-dll for known bugs
These are caused due to inconsistencies regarding always inline in
combination with dllimport. A bug report reference is added next to
each XFAIL line.

Differential Revision: https://reviews.llvm.org/D100789
2021-04-27 17:16:04 +03:00
Martin Storsjö 53b3c1c5e7 [libcxx] [test] Add a separate 'windows-dll' feature to check for
This allows distinguishing failures in tests that only fail when libcxx
is linked as a DLL, allowing narrowing down XFAILs (avoiding XPASS errors
if not built as a DLL).

If both enable_shared and enable_static are set, the tests link and use
the shared version of the lib.

Differential Revision: https://reviews.llvm.org/D100221
2021-04-27 17:14:59 +03:00
Marek Kurdej 7f98209da6 [libc++] Fix set-but-not-used warning. NFC. 2021-04-27 12:22:56 +02:00
Petr Hosek b4537c3f51 [Driver] Push multiarch path setup to individual drivers
Different platforms use different rules for multiarch triples so
it's difficult to provide a single method for all platforms. We
instead move the getMultiarchTriple to the ToolChain class and let
individual platforms override it and provide their custom logic.

Differential Revision: https://reviews.llvm.org/D101194
2021-04-26 22:17:26 -07:00
zoecarver bdd6835790 [libc++][ranges] iterator.concept.sizedsentinel: sized_sentinel_for and disable_sized_sentinel_for.
Based on D100160.

Reviewed By: cjdb, ldionne, Quuxplusone, #libc, miscco

Differential Revision: https://reviews.llvm.org/D100587
2021-04-26 15:06:19 -07:00
Sterling Augustine fe15556077 Support leak sanitizer in libcxx.
Support leak sanitizer in libcxx.

Simple addition for leak checking when running the libcxx testsuite.

Differential Revision: https://reviews.llvm.org/D100775
2021-04-26 14:19:34 -07:00
Sterling Augustine 0e83780325 Don't fail the shared_ptr test if libc++ has insufficient debug info.
Don't fail the shared_ptr test if libc++ has insufficient debug info.

This addresses https://bugs.llvm.org/show_bug.cgi?id=48937

Differential Revision: https://reviews.llvm.org/D100610
2021-04-26 14:19:34 -07:00
Arthur O'Dwyer 0fcb898f10 [libc++] [test] Fix a Python warning.
params.py:106: SyntaxWarning: "is" with a literal. Did you mean "=="?
2021-04-26 16:22:43 -04:00
Arthur O'Dwyer 036b80fcbb [libc++] [test] Improve test_exceptions() in each string.modifiers test.
When checking the strong exception guarantee, also check that
iterators haven't been invalidated.

Reviewed as part of https://reviews.llvm.org/D98573
2021-04-26 16:22:43 -04:00
Arthur O'Dwyer e87479b00f [libc++] Remove the special logic for "noexcept iterators" in basic_string.
This reverts a large chunk of http://reviews.llvm.org/D15862 ,
and also fixes bugs in `insert`, `append`, and `assign`, which are now regression-tested.
(Thanks to Tim Song for pointing out the bug in `append`!)

Before this patch, we did a special dance in `append`, `assign`, and `insert`
(but not `replace`). All of these require the strong exception guarantee,
even when the user-provided InputIterator might have throwing operations.

The naive way to accomplish this is to construct a temporary string and
then append/assign/insert from the temporary; i.e., finish all the potentially
throwing and self-inspecting InputIterator operations *before* starting to
modify self. But this is slow, so we'd like to skip it when possible.

The old code (D15682) attempted to check that specific iterator operations
were nothrow: it assumed that if the iterator operations didn't throw, then
it was safe to iterate the input range multiple times and therefore it was
safe to use the fast-path non-naive version. This was wrong for two reasons:
(1) the old code checked the wrong operations (e.g. checked noexceptness of `==`,
but the code that ran used `!=`), and (2) the conversion of value_type to char
could still throw, or inspect the contents of self.

The new code is much simpler, although still much more complicated than it
really could be. We'll likely revisit this codepath at some point, but for now
this patch suffices to get it passing all the new regression tests.

The added tests all fail before this patch, and succeed afterward.
See https://quuxplusone.github.io/blog/2021/04/17/pathological-string-appends/

Differential Revision: https://reviews.llvm.org/D98573
2021-04-26 16:22:43 -04:00
Arthur O'Dwyer 70d94c3f2c [libc++] __bit_iterator mustn't rely on deprecated SMF generation.
This allows us to turn -Wdeprecated-copy back on. We turned it off
in 3b71de41cc because Clang's implementation became more stringent
and started diagnosing the old code here.

Differential Revision: https://reviews.llvm.org/D101183
2021-04-26 16:22:42 -04:00
Mark de Wever 18b03b0085 [libc++][NFC] Remove non-ASCII from comment.
Seems our check-generated-output doesn't work as intended. Will
investigate it further.
2021-04-26 17:53:20 +02:00
Mark de Wever a354fd56c5 [libc++] Adds __utility/to_underlying.h.
During the review of D97115 it was mentioned adding the `<utility>`
header for `__to_underlying` was a bit unfortunate. Nowadays we tend to
implement smaller headers, so a good reason to move `std::to_underlying`
to its own header and adjust `<charconv>` to use the new header.

Differential Revision: https://reviews.llvm.org/D101233
2021-04-25 13:27:19 +02:00
Christopher Di Bella 38225d6921 [libcxx][iterator] adds `std::input_or_output_iterator` and `std::sentinel_for`
Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D100080

Differential Revision: https://reviews.llvm.org/D100160
2021-04-24 15:49:21 +00:00
Mark de Wever ca177dcda3 [libc++][doc] Adds a Format library status page.
A status page for libc++'s Format library. The page is inspired by
@zoecarver's Ranges status page.

Differential Revision: https://reviews.llvm.org/D101085
2021-04-24 16:38:18 +02:00
Shu Tian 7402ec8f38 [libc++] Remove if-else to make branch predictor happy
Reviewed By: #libc, ldionne, Quuxplusone, Mordante

Differential Revision: https://reviews.llvm.org/D100828
2021-04-24 16:09:52 +02:00
Christopher Di Bella 2205286095 [libcxx][iterator] adds `std::weakly_incrementable` and `std::incrementable`
Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D100073.

Reviewed By: ldionne, zoecarver, #libc

Differential Revision: https://reviews.llvm.org/D100080
2021-04-23 22:25:37 -07:00
Christopher Di Bella a224bf8ec4 [libcxx] disables ranges for clang-cl
clang-cl doesn't properly handle concepts right now and is failing CI.

Differential Revision: https://reviews.llvm.org/D101205
2021-04-23 18:21:33 -07:00
Arthur O'Dwyer bbc6893b11 Implement N3644 "Null Forward Pointers" in _LIBCPP_DEBUG mode.
This functionality is tested in std/containers/sequences/vector/iterators.pass.cpp
(and similarly for all containers, but vector is the only one to be tested that
uses debug iterators).

Differential Revision: https://reviews.llvm.org/D100881
2021-04-23 18:20:39 -04:00
zoecarver d7bd62a64e [libcxx][nfc] Add license to `pointer_comparison_test_helper.h` 2021-04-23 12:37:47 -07:00
Louis Dionne a3ab5120fd [libc++] Rewrite the tuple constructors to be strictly Standards conforming
This nasty patch rewrites the tuple constructors to match those defined
by the Standard. We were previously providing several extensions in those
constructors - those extensions are removed by this patch.

The issue with those extensions is that we've had numerous bugs filed
against us over the years for problems essentially caused by them. As a
result, people are unable to use tuple in ways that are blessed by the
Standard, all that for the perceived benefit of providing them extensions
that they never asked for.

Since this is an API break, I communicated it in the release notes.
I do not foresee major issues with this break because I don't think the
extensions are too widely relied upon, but we can ship it and see if we
get complaints before the next LLVM release - that will give us some
amount of information regarding how much use these extensions have.

Differential Revision: https://reviews.llvm.org/D96523
2021-04-23 12:46:37 -04:00
Dávid Bolvanský 3b71de41cc [libcxx] Fixed build break on buildbots with -Werror 2021-04-23 18:16:38 +02:00
zoecarver 879cbac08b [libc++][ranges] Add range.cmp: equal_to, not_equal_to, less, etc.
Adds the six new concept constrained comparisons.

Differential Revision: https://reviews.llvm.org/D100429
2021-04-22 17:33:04 -07:00
Arthur O'Dwyer 5dfbcc5ae9 [libc++] [test] Fix nodiscard_extensions.pass.cpp in _LIBCPP_DEBUG mode.
`std::clamp(2, 1, 3, std::greater<int>())` has UB because (1 > 3) is false.
Swap the operands to fix the _LIBCPP_ASSERT failure in this test.
2021-04-22 12:17:32 -04:00
Arthur O'Dwyer b98b6d99c5 [libc++] Eliminate macro _LIBCPP_UNUSED_VAR. NFCI.
Reviewed as part of https://reviews.llvm.org/D100737
2021-04-22 12:02:22 -04:00
Arthur O'Dwyer e6972024c8 [libc++] Fix some typos and remove unused macros. NFCI.
Reviewed as part of https://reviews.llvm.org/D100737
2021-04-22 12:02:22 -04:00
Louis Dionne 57ebf3d008 [libc++] Re-apply `std::indirectly_readable` and `std::indirectly_writable`
That was originally committed in 04733181b5 and then reverted in
a9f11cc0d9 because it broke several people.

The problem was a missing include of __iterator/concepts.h, which has now
been fixed.

Differential Revision: https://reviews.llvm.org/D100073
2021-04-22 11:24:04 -04:00
David Zarzycki a9f11cc0d9 Revert "[libcxx][iterator] adds `std::indirectly_readable` and `std::indirectly_writable`"
This reverts commit 04733181b5 which was
failing for multiple people.
2021-04-22 09:49:54 -04:00
Martin Storsjö cfec0a3e9e [libcxx] [test] Fix testing on windows with c++experimental enabled
The straightforward `AddLinkFlag('-lc++experimental')` approach doesn't
work on e.g. MSVC. For linking to libc++ itself, a more convoluted logic
is used (see configure_link_flags_cxx_library).

Differential Revision: https://reviews.llvm.org/D99177
2021-04-22 10:26:00 +03:00
Petr Hosek f749550cfe [libcxx] Stop using use c++ subdirectory for libc++ library
The new layout more closely matches the layout used by other compilers.
This is only used when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is enabled.

Differential Revision: https://reviews.llvm.org/D100869
2021-04-21 15:39:03 -07:00
Louis Dionne 3d8f2059b9 [libc++] Move the debug_level feature to the DSL 2021-04-21 17:57:16 -04:00
Louis Dionne ac8b71227c [libc++] Move macOS testing out of the 2nd CI stage
It's too slow, which delays the posting of CI results to Phabricator
when another step in the same stage fails.
2021-04-21 17:12:43 -04:00
Mark de Wever f2ff3b91ec [libc++][doc] Improve Phabricator links.
Removes the "reviews." part of the links as suggested by @ldionne in
D100707.
2021-04-21 20:12:03 +02:00
Christopher Di Bella 04733181b5 [libcxx][iterator] adds `std::indirectly_readable` and `std::indirectly_writable`
Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D99873.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D100073
2021-04-21 17:14:28 +00:00
Arthur O'Dwyer 5c40c994c3 [libc++] s/_LIBCPP_NO_HAS_CHAR8_T/_LIBCPP_HAS_NO_CHAR8_T/g
This was raised in D94511.

Differential Revision: https://reviews.llvm.org/D100736
2021-04-21 12:49:07 -04:00
Arthur O'Dwyer e9d876159e [libc++] [test] Remove epicyclic workarounds for vector/span; use T[] or std::array.
Simplify the test code, and drive-by also test that these algorithms
return the right iterator as their return value.

Differential Revision: https://reviews.llvm.org/D100876
2021-04-21 12:41:45 -04:00
Louis Dionne 97e383aa06 [libc++] Add std::ranges::iter_move and std::iter_rvalue_reference_t
Original patch by @cjdb, modified by @ldionne.

Differential Revision: https://reviews.llvm.org/D99873
2021-04-21 11:32:00 -04:00
Christopher Di Bella 9816d43cff [libcxx] adds `iter_difference_t` and `iter_value_t`
Implements parts of:
    * P0896R4 The One Ranges Proposal

Depends on D99855.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D99863
2021-04-20 19:02:07 +00:00
Kristina Bessonova 4a292eda25 [libcxx][test] Construct non-empty containers in iterator's debug mode tests
The debug mode tests for map/set's iterators construct empty
containers, making the code after the first increment meaningless.
It's never executed since the tests exit earlier.

It doesn't seem to be intentional, so the patch makes the tests
to construct containers that include at least one element.

Reviewed By: curdeius, Quuxplusone

Differential Revision: https://reviews.llvm.org/D100029
2021-04-20 19:51:55 +02:00
Sterling Augustine 55b7061116 Tolerate missing debug info in the shared_ptr pretty printer.
Certain fields of shared ptr have virtual functions and therefore
have their debug info homed in libc++. But if libc++ wasn't built
with debug info, the pretty printer would fail.

This patch makes the pretty printer tolerate such conditions and
updates the test harness.

This patch significantly reworks a previous attempt.

This addresses https://bugs.llvm.org/show_bug.cgi?id=48937

Differential Revision: https://reviews.llvm.org/D100610
2021-04-20 09:52:46 -07:00
Mark de Wever 0c8fab9af7 [libcxx][doc] Use Phabricator links.
Use a link to the Phabricator review in the patch column.

Reviewed By: zoecarver, cjdb, #libc

Differential Revision: https://reviews.llvm.org/D100707
2021-04-20 18:41:04 +02:00
Louis Dionne 4cd6ca102a [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
zoecarver 120fa8293e [libc++][nfc] Move iterator_traits and related into __iterator/iterator_traits.h.
Based on D100682 and D99855.

(Note: I originally was going to just make this part of D99855, but I decided not to because this patch moves lots of unrelated code around, and I didn't want to make D99855 harder to review because of unrelated code-changes/moves.)

Differential Revision: https://reviews.llvm.org/D100686
2021-04-20 08:31:34 -07:00
zoecarver 9f01ac3b32 [libcxx] makes `iterator_traits` C++20-aware
* adds `iterator_traits` specialisation that supports all expected
  member aliases except for `pointer`
* adds `iterator_traits` specialisations for iterators that meet the
  legacy iterator requirements but might lack multiple member aliases
* makes pointer `iterator_traits` specialisation require objects

Depends on D99854.

Differential Revision: https://reviews.llvm.org/D99855
2021-04-20 11:30:08 -04:00
Louis Dionne 2704d0a701 [libc++][ci] Re-split the CI pipeline to try and reduce load on more builders 2021-04-20 08:37:52 -04:00
Kristina Bessonova 90248f2daa [libcxx][test] Split off debug mode tests
This continues the work started by @ldionne in 2908eb20ba.

The debug mode tests from

- libcxx/containers/sequences/vector/
- libcxx/strings/basic.string/string.access/
- libcxx/strings/basic.string/string.iterators/

similarly contain two tests in every file making the second test never
run. The patch splits the tests into separate files.

Reviewed By: Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D100592
2021-04-20 11:59:36 +02:00
Kamlesh Kumar 36c3918ec5 [libc++] [C++20] [P0586] Implement safe integral comparisons
* https://wg21.link/P0586

Reviewed By: #libc, curdeius, Quuxplusone

Differential Revision: https://reviews.llvm.org/D94511
2021-04-20 04:52:59 +05:30
zoecarver 2218f5998b [libc++][gardening] Replace instances of `\x{AD}`.
This is a NFC.

Differential Revision: https://reviews.llvm.org/D100799
2021-04-19 14:59:46 -07:00
Martin Storsjö f9ddb81d79 [libcxx] [test] Ifdef out tests that rely on perms::none on directories for triggering errors
On Windows, one can't use perms::none on a directory to trigger
failures to read the directory entries.

These remaining tests can't use GetWindowsInaccessibleDir() sensibly,
e.g. for tests that rely on toggling accessibility back and forth during
the test, or where the semantics of the dir provided by
GetWindowsInaccessibleDir() doesn't allow for running the ifdeffed tests
meaningfully.

Differential Revision: https://reviews.llvm.org/D97538
2021-04-19 23:03:12 +03:00
Martin Storsjö 6c5b0d6bea [libcxx] Base MSVC autolinking on _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
Previously the decision of which library to try to autolink was
based on _DLL, however the _DLL define (which is set by the compiler)
is tied to whether using a dynamically linked CRT or not, and the choice
of dynamic or static CRT is entirely orthogonal to whether libc++ is
linked dynamically or statically.

If _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS isn't defined, then all
declarations are decorated with dllimport, and there's no doubt that
the DLL version of the library is what must be linked.

_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS is defined if building with
LIBCXX_ENABLE_SHARED disabled, and thus the static library is what
should be linked.

If defining _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS manually but wanting
to link against the DLL version of the library, that's not a canonical
configuration, and then it's probably reasonable to manually define
_LIBCPP_NO_AUTO_LINK too, and manually link against the desired
library.

This fixes, among other issues, running tests for the library if
built with LIBCXX_ENABLE_STATIC disabled.

Differential Revision: https://reviews.llvm.org/D100539
2021-04-19 22:42:33 +03:00
zoecarver e0adf7e06a [libc++][NFC] Move incrementable_traits and indirectly_readable_traits into separate headers.
Differential Revision: https://reviews.llvm.org/D100682
2021-04-19 14:31:30 -04:00
Arthur O'Dwyer 5e7367d3e4 Add a missing debug assertion in <list>.
This came up in D100595.

Differential Revision: https://reviews.llvm.org/D100728
2021-04-18 19:40:17 -04:00
Arthur O'Dwyer e880c19c6a [libc++] [CI] Fail if the headers contain cyclic dependencies.
Since we have a tool to detect cycles now; and since we're entering
a phase where people can easily introduce cycles by accident (D100682)
or by request (D90999), I think it's increasingly important to shift
the burden of detecting these cycles onto the buildbot instead of
the poor human reviewer.

Also, grep for non-ASCII characters (such as U+200B and U+00AD)
and hard tabs; don't let those get checked in.

Differential Review: https://reviews.llvm.org/D100703
2021-04-18 12:58:04 -04:00
Mark de Wever 01ace074fc [libc++] Implements ranges::enable_borrowed_range
This is the initial patch to implement ranges in libc++.

Implements parts of:
- P0896R4 One Ranges Proposal
- P1870 forwarding-range is too subtle
- LWG3379 in several library names is misleading

Reviewed By: ldionne, #libc, cjdb, zoecarver, Quuxplusone

Differential Revision: https://reviews.llvm.org/D90999
2021-04-18 13:35:08 +02:00
Arthur O'Dwyer 863d5c4e4d [libc++] Remove hard tabs, U+00AD, and U+200B from all libc++ headers. NFCI. 2021-04-17 17:03:20 -04:00
Jennifer Chukwu 21bef4e11e [NFC] Fixed Typos
Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D100705
2021-04-17 22:02:23 +05:30
Mark de Wever f8f60297d7 [libcxx][doc] Fixes typos. 2021-04-17 18:01:32 +02:00
Louis Dionne 1f8a6dcf12 [libc++] Fix LWG 2874: Constructor shared_ptr::shared_ptr(Y*) should be constrained.
This patch fixes LWG2874. It is based on the original patch by Zoe Carver
originally uploaded at D81417.

Differential Revision: https://reviews.llvm.org/D81417
2021-04-16 09:54:20 -04:00
Petr Hosek 9ac988f6a8 [libcxx] Make the GDB pretty printer test less strict
This is a workaround for PR48937. GDB can sometimes print additional
warnings which currently fails the test. Use re.search instead of
re.match to ignore this additional output.

Differential Revision: https://reviews.llvm.org/D99532
2021-04-15 23:33:22 -07:00
Christopher Di Bella 0148b65372 [libcxx] adds `cpp17-.*iterator` concepts for iterator_traits
The `iterator_traits` patch became too large for a concise review, so
the "bloat" —as it were— was moved into this patch. Also tests most
C++[98,17] iterator types to confirm backwards compatibility is
successful (regex iterators are intentionally not present, but directory
iterators are due to a peculiar error encountered while patching
`iterator_traits`).

Depends on D99461.

Differential Revision: https://reviews.llvm.org/D99854
2021-04-16 03:14:42 +00:00
Christopher Di Bella f280505aa0 [libcxx] adds `std::indirectly_readable_traits` to <iterator>
Implements parts of:
    * P0896R4 The One Ranges Proposal
    * LWG3446 `indirectly_readable_traits` ambiguity for types with both `value_type` and `element_type`

Depends on D99141.

Differential Revision: https://reviews.llvm.org/D99461
2021-04-15 23:59:02 +00:00
Christopher Di Bella 6f3bce911e [libcxx][NFC] removes IndentRequires from .clang-format
IndentRequires is apparently breaking CI because it uses an older clang-format.

Partially rolls back 2e3a78b8ca.
2021-04-15 19:28:45 +00:00
Louis Dionne 9178fb73e1 [libc++] NFC: Use ASSERT_SAME_TYPE consistently in string.h and wchar.h tests 2021-04-15 13:06:06 -04:00
Louis Dionne 44e24d8f99 [libc++] Remove test suite workarounds on Apple with old Clangs
In 5fd17ab, we worked around the Apple system headers not providing
const-correct overloads for some <string.h> functions. However, that
required an attribute that was only present in recent Clangs at the
time. We can now assume that all supported Clang versions on Apple
platforms do support that attribute.

Differential Revision: https://reviews.llvm.org/D100477
2021-04-15 13:06:06 -04:00
Christopher Di Bella ff0ada4e16 [libcxx][NFC] removes BreakBeforeConceptDeclarations from .clang-format
BreakBeforeConceptDeclarations is apparently breaking CI.

Partially rolls back 2e3a78b8ca.
2021-04-15 15:29:07 +00:00
Christopher Di Bella 2e3a78b8ca [libcxx][NFC] adjusts formatting rules
This will reduce the amount of noisy feedback during reviews.

Differential Revision: https://reviews.llvm.org/D99691
2021-04-15 02:46:44 +00:00
zoecarver b12f3ce47f [libcxx][nfc] Assign [ranges.primitives] in "RangesStatus." 2021-04-14 16:09:45 -07:00
Louis Dionne 207d58bf31 [libc++] Move guards against std::auto_ptr outside of auto_ptr.h
This makes it clear that headers like <memory> which include auto_ptr
only do that when compiling under an older Standard, or when the removed
feature is explicitly requested.
2021-04-14 14:06:55 -04:00
Louis Dionne e98060fa72 [libc++] Move __memory/utilities.h to __memory/allocation_guard.h
This matches the granularity of other headers that were split off of <__memory>.
2021-04-14 14:00:48 -04:00
Louis Dionne f992cfba71 [libc++] Split up __memory/base.h into meaningful headers 2021-04-14 13:59:03 -04:00
Mark de Wever b15c54ad68 [NFC][libc++] Fixes a documentation typo. 2021-04-14 19:33:03 +02:00
Mark de Wever ac08e2bb98 [libc++] Make chars_format a bitmask type.
Some of Microsoft's unit tests in D70631 fail because libc++'s
implementation of std::chars_format isn't a proper bitmask type. Adding
the required functions to make std::chars_format a proper bitmask type.

Implements parts of P0067: Elementary string conversions

Differential Revision: https://reviews.llvm.org/D97115
2021-04-14 18:17:38 +02:00
Zoe Carver 0f0149b8d3 [libc++][docs] Add status docs for ranges.
The added documents have two tables: 1 containing links to issues and papers related to ranges. And the other contains most of the sections from the One Ranges Proposal, with their dependencies linked. This will allow us to assign work that can be done in parallel.

Differential Revision: https://reviews.llvm.org/D100393
2021-04-13 17:59:42 -07:00
Marek Kurdej 3fca07d7b9 [libc++] [P0458] Add map::contains and set::contains for heterogenous lookup missed in a17b1aed.
Commit rGa17b1aed added `bool contains(const key_type& x) const;` methods to associative containers, but didn't add `template<class K> bool contains(const K& x) const;` for heterogenous lookup.

Reviewed By: #libc, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D100369
2021-04-13 17:15:58 +02:00
Louis Dionne 7f1963dc8e [libc++] Move pointer safety related utilities out of <memory>
Differential Revision: https://reviews.llvm.org/D100318
2021-04-13 08:21:46 -04:00
Louis Dionne 916fecb499 [libc++] Split std::shared_ptr & friends out of <memory>
Differential Revision: https://reviews.llvm.org/D100318
2021-04-13 08:21:44 -04:00
Louis Dionne 21d6636d83 [libc++] Split std::unique_ptr out of <memory>
Differential Revision: https://reviews.llvm.org/D100318
2021-04-13 08:21:40 -04:00
Louis Dionne 4f9b2469f3 [libc++] Split the memory-related algorithms out of <memory>
Differential Revision: https://reviews.llvm.org/D100318
2021-04-13 08:21:38 -04:00
Louis Dionne be54341cd2 [libc++] Split std::raw_storage_iterator out of <memory>
Differential Revision: https://reviews.llvm.org/D100318
2021-04-13 08:21:35 -04:00
Louis Dionne 9b0a3388eb [libc++] Split __compressed_pair out of <memory>
Differential Revision: https://reviews.llvm.org/D100318
2021-04-13 08:21:31 -04:00
Marek Kurdej cd854e686f [libc++] Fix test synopses and remove unused includes. 2021-04-13 10:32:35 +02:00
Christopher Di Bella 0fcea41920 [libcxx][NFC] tweaks `incrementable_traits` per review
One suggestion was missed and is being patched now.
2021-04-13 05:20:55 +00:00
Christopher Di Bella fe31f11cc8 [libcxx] adds `std::incrementable_traits` to <iterator>
Implements parts of:
    - P0896R4 The One Ranges Proposal

Depends on D99041

Differential Revision: https://reviews.llvm.org/D99141
2021-04-13 05:01:45 +00:00
jasonliu 52e9d80d5d [libc++] add `inline` for __open's definition in ifstream and ofstream
Summary:

When building with gcc on AIX, it seems that gcc does not like the
`always_inline` without the `inline` keyword.
So adding the inline keywords in for __open in ifstream and ofstream.
That will also make it consistent with __open in basic_filebuf
(it seems we added `inline` there before for gcc build as well).

Differential Revision: https://reviews.llvm.org/D99422
2021-04-12 19:25:49 +00:00
Mara Sophie Grosch 8deaa4a147 [libc++] Move checks for newlib to actually work
The checks did not work in __config, since no header defining
`_NEWLIB_VERSION` was included before. This patch moves the two
checks for newlib to the headers that actually need it - and after
they already include relevant headers.

Differential Revision: https://reviews.llvm.org/D79888
2021-04-12 14:20:36 -04:00
Arthur O'Dwyer 4b7bad9eae [libc++] Implement D2351R0 "Mark all library static cast wrappers as [[nodiscard]]"
These [[nodiscard]] annotations are added as a conforming extension;
it's unclear whether the paper will actually be adopted and make them
mandatory, but they do seem like good ideas regardless.

https://isocpp.org/files/papers/D2351R0.pdf

This patch implements the paper's effect on:
- std::to_integer, std::to_underlying
- std::forward, std::move, std::move_if_noexcept
- std::as_const
- std::identity

The paper also affects (but libc++ does not yet have an implementation of):
- std::bit_cast

Differential Revision: https://reviews.llvm.org/D99895
2021-04-12 12:29:15 -04:00
Arthur O'Dwyer d7eb797ea5 [libc++] [test] Detect an improperly noexcept'ed __decay_copy.
`__decay_copy` is used by `std::thread`'s constructor to copy its arguments
into the new thread. If `__decay_copy` claims to be noexcept, but then
copying the argument does actually throw, we'd call std::terminate instead
of passing this test. (And I've verified that adding an unconditional `noexcept`
to `__decay_copy` does indeed fail this test.)

Differential Revision: https://reviews.llvm.org/D100277
2021-04-12 12:28:01 -04:00
Louis Dionne 8508b1c133 [libc++] Divorce the std Lit feature from the -std=XXX compiler flag
After this patch, we can use `--param std=c++20` even if the compiler only
supports -std=c++2a. The test suite will handle that for us. The only Lit
feature that isn't fully baked will always be the "in development" one,
since we don't know exactly what year the standard will be ratified in.

This is another take on https://reviews.llvm.org/D99789.

Differential Revision: https://reviews.llvm.org/D100210
2021-04-12 11:55:39 -04:00
Louis Dionne 344d381d9f [libc++] NFC: Remove duplicate synopsis from <__string> 2021-04-12 11:49:43 -04:00
Louis Dionne 6a1ac88fc1 [libc++] Split std::get_temporary_buffer out of <memory>
Differential Revision: https://reviews.llvm.org/D100216
2021-04-12 11:46:31 -04:00
Louis Dionne 0b439e4cc9 [libc++] Split std::allocator out of <memory>
Differential Revision: https://reviews.llvm.org/D100216
2021-04-12 11:46:29 -04:00
Louis Dionne 26beecfe47 [libc++] Split auto_ptr out of <memory>
Differential Revision: https://reviews.llvm.org/D100216
2021-04-12 11:46:25 -04:00
Mark de Wever ae103003b2 [libc++] [CI] Validate the output of the generated scripts.
This adds a CI job validating that the output of
utils/generate_feature_test_macro_components.py,
libcxx/utils/generate_header_inclusion_tests.py, and
utils/generate_header_tests.py are up to date.

The validation method has been copied from the Format job.

Differential Revision: https://reviews.llvm.org/D99862
2021-04-11 15:35:23 +02:00
Louis Dionne b125392259 [libc++] NFC: Move unused include of <limits> to allocator_traits.h
The include should have been moved when I split allocator_traits.h out
of memory.
2021-04-09 15:31:55 -04:00
Martin Storsjö 1e5f68d80a [libcxx] [test] Add more tests for renaming directories in fs.op.rename
This was requested during the review of D98640.

Differential Revision: https://reviews.llvm.org/D99982
2021-04-09 21:24:34 +03:00
Martin Storsjö 1f1f8e239b [libcxx] [test] Use GetWindowsInaccessibleDir() in a couple more tests
Differential Revision: https://reviews.llvm.org/D98443
2021-04-09 21:24:34 +03:00
Martin Storsjö b166441bbe [libcxx] [test] Use GetWindowsInaccessibleDir() instead of dirs with perms::none in fs.op.is_*
Differential Revision: https://reviews.llvm.org/D98442
2021-04-09 21:24:34 +03:00
jasonliu f3d7536b24 [libc++] Fix abs and div overload issue for compilers on AIX
Summary:
AIX system's stdlib.h provide different overload of abs and div
depending on compiler versions.

For example, std::div(long, long) and std::abs(long) are not available
from OS's stdlib.h when building with clang, but they are available
when building with xlclang compiler.

Therefore, we need to provide those extra overloads in libc++'s stdlib.h
when OS's stdlib.h does not.

Differential Revision: https://reviews.llvm.org/D99767
2021-04-09 14:47:13 +00:00
zoecarver 097d77d611 [libcxx] Allow shared_ptr's unique_ptr converting constructor to support array types.
Refs: https://bugs.llvm.org/show_bug.cgi?id=32147

Differential Revision: https://reviews.llvm.org/D80882
2021-04-08 22:04:57 -07:00
Mark de Wever 48fa06f70b [libc++] Update contributor documentation.
The document has the following updates:
- Rename 'feature test' to 'feature-test', the latter is the spelling
  used in the Standard.
- Add information how an ABI list can be downloaded from Buildkite.

Differential Revision: https://reviews.llvm.org/D99290
2021-04-07 18:33:27 +02:00
Christopher Di Bella 920c0f7e09 [libcxx] adds __cpp_lib_concepts feature-test macro
Also adjusts C++20 status paper to indicate full concepts support.

Depends on D96477, D99817.

Differential Revision: https://reviews.llvm.org/D99805
2021-04-07 16:14:45 +00:00
Christopher Di Bella c7ad020099 [libcxx] adds remaining callable concepts
* `std::predicate`
* `std::relation`
* `std::equivalence_relation`
* `std::strict_weak_order`

Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Differential Revision: https://reviews.llvm.org/D96477
2021-04-07 16:14:45 +00:00
Christopher Di Bella cedd07df51 [libcxx] fixes `common_reference` requirement for `swappable_with`
LWG3175 identifies that the `common_reference` requirement for
`swappable_with` is over-constraining and doesn't need to concern itself
with cv- or reference qualifiers.

Differential Revision: https://reviews.llvm.org/D99817
2021-04-07 05:51:36 +00:00
Louis Dionne 69190f95b1 [libc++] NFCI: Fix test pinning down RTTI implementation on Apple platforms
The test didn't handle arm64 correctly.
2021-04-06 16:15:48 -04:00
Arthur O'Dwyer 2d0f1fa472 [libc++] Header inclusion tests.
As mandated by the Standard's various synopses, e.g. [iterator.synopsis].
Searching the TeX source for '#include' is a good way to find all of these
mandates.

The new tests are all autogenerated by utils/generate_header_inclusion_tests.py.
I was SHOCKED by how many mandates there are, and how many of them
libc++ wasn't conforming with.

Differential Revision: https://reviews.llvm.org/D99309
2021-04-06 15:31:56 -04:00
Arthur O'Dwyer ae318beb35 [libc++] Post-commit review on D99928.
The "user-defined conversion by implicit constructor" codepath is already
handled by `B(int)`; we don't need to test `A(const A&)` a second time
via `DA` (nor the isomorphic case with `DB`).
We don't need `&` anywhere in this test.
Generally, `operator()` should be const; this test needn't be special.
(No functional change in test coverage.)
2021-04-06 15:31:55 -04:00
Martin Storsjö a9a7498b3f [libcxx] [test] Allow C:\System Volume Information to be missing
If running in a Windows Container, there is no such directory at all.

If running from within bash on Windows Server, the directory seems to
be fully accessible. (The mechanics of this isn't fully understood, and
it doesn't seem to happen on desktop versions.)

If the directory isn't available with the expected behaviour, mark those
individual tests as unsupported. (The test as a whole is considered to
pass, but the unsupported test is mentioned in a test summary printed on
stdout.)

Differential Revision: https://reviews.llvm.org/D98960
2021-04-06 20:55:18 +03:00
Martin Storsjö 948dd664c3 [libcxx] Fix the type attribute for a couple templates
Use `_LIBCPP_TEMPLATE_VIS` instead of `_LIBCPP_TYPE_VIS` for a template
class.

This fixes the nodiscard_extensions.pass.cpp and a couple
func.search.default test cases when built in MSVC/DLL configurations.

Differential Revision: https://reviews.llvm.org/D99932
2021-04-06 19:54:34 +03:00
Martin Storsjö 91d6debbb9 [libcxx] [test] Use dedicated types for the invocable concept tests for multiple overloads
This should be clearer, instead of relying on rules for implicit
conversions regarding built in float/integer types.

Differential Revision: https://reviews.llvm.org/D99928
2021-04-06 19:54:34 +03:00
Christopher Di Bella 96dbdd753a [libcxx] adds remaining callable concepts
* `std::predicate`
* `std::relation`
* `std::equivalence_relation`
* `std::strict_weak_order`

Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Differential Revision: https://reviews.llvm.org/D96477
2021-04-06 16:35:57 +00:00
Zbigniew Sarbinowski 916093f49f [SystemZ][z/OS] correct rc and errno within nanosleep()
This patch fixes rc and errno within nanosleep(). It also updates __rem parameter as well it introduces cast to handle conversions from long into unsigned int to avoid warnings.

Reviewed By: Mordante

Differential Revision: https://reviews.llvm.org/D99373
2021-04-06 15:36:58 +00:00
Christopher Di Bella c25c22d5f9 [libcxx] moves `std::invoke` into `__functional_base`
Including `<concepts>` in other standard library headers (such as
`<iterator>`) creates circular dependencies due to `<functional>`.
Since `<concepts>` only needs `std::invoke` from `<functional>`, the
easiest, fastest, and cleanest way to eliminate the circular dep is to
move `std::invoke` into `__functional_base`.

This has the added advantage of `<concepts>` not transitively importing
`<functional>`.

Differential Revision: https://reviews.llvm.org/D99041
2021-04-06 01:25:15 +00:00
Martin Storsjö 740e349762 [libcxx] [ci] Add a Windows CI buildkite configuration
Differential Revision: https://reviews.llvm.org/D99093
2021-04-06 00:09:16 +03:00
Arthur O'Dwyer 9abff04e50 [libc++] Fix test_macros.h in the same way as commit 49e5a896 fixed __config.
Since D99515, this header triggers -Wundef on Mac OSX older than 10.15.
This is now fixed.
2021-04-04 18:08:19 -04:00
Arthur O'Dwyer 27e5bffbf6 [libc++] Fix the header guard from _LIBCPP_STEAMBUF to _LIBCPP_STREAMBUF. 2021-04-04 17:39:50 -04:00
Mark de Wever c2c68a5940 [libc++] Improve generate_feature_test_macro_components.py.
This improves the naming of the fields `depends`/`internal_depends`. It
also adds the documentation for this script. The changes are based on
D99290 and its review comments.

Differential Revision: https://reviews.llvm.org/D99615
2021-04-04 20:08:32 +02:00
Martin Storsjö f619783882 [libcxx] [test] Link against msvcprt as C++ ABI library in tests
This matches what we link the library itself against (set in
CMakeLists.txt). When testing a static library version of libc++,
this is needed for essentially every test due to libc++ object files
requiring it.

Also with libc++ built as a DLL, some tests directly call functions that
are provided by msvcprt (such as std::set_new_handler), thus this fixes
a number of tests in that configuration too.

Differential Revision: https://reviews.llvm.org/D99263
2021-04-04 19:18:32 +03:00
Nico Weber d3b74dc1e4 Restore 8954fd436c after c06a8f9caa
Else, just-built clang can't build programs that include libc++ headers
on macOS if you build via the 'all' target.
2021-04-02 09:19:36 -04:00
Marek Kurdej 49e5a896d1 [libc++] Fix build on macOS older than 10.15.
* This was introduced in D99515 that added -Wundef flag. CI run on macOS 10.15 and this problem wasn't caught before.
2021-04-02 10:32:54 +02:00
Martin Storsjö 28ea218417 [libcxx] [test] Fix invocable tests on Windows
MSVC had a bug regarding preferring intergral conversions over
floating conversions. This is fixed in MSVC 19.28 and newer. Clang in
MSVC mode so far only mimics the old, buggy behaviour, but will
hopefully soon be fixed to comply with the new behaviour too
(see https://reviews.llvm.org/D99663).

Make the negative test to use a distinctly different type,
leaving checks for compiler specific bugs out of the libcxx test.

Differential Revision: https://reviews.llvm.org/D99641
2021-04-02 10:49:27 +03:00
Martin Storsjö f8013a35b6 [libcxx] [test] Make the condvar wait_for tests a bit more understandable. NFC.
This was requested in the review of D99175; rename the "runs"
variable to clarify what it means wrt the test, and move updating of
it to the main function to clarify its behaviour wrt the two runs
further.

Differential Revision: https://reviews.llvm.org/D99768
2021-04-02 10:46:15 +03:00
Christopher Di Bella 7959d59028 [libcxx] adds concepts `std::totally_ordered` and `std::totally_ordered_with`
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Reviewed By: Mordante

Differential Revision: https://reviews.llvm.org/D98983
2021-04-02 06:00:21 +00:00
Louis Dionne 17095dc861 [libc++][NFC] Increase readability of typeinfo comparison of ARM64
We wasted a good deal of time trying to figure out whether our implementation
was correct. In the end, it was, but it wasn't so easy to determine. This
patch dumbs down the implementation and improves the documentation to make
it easier to validate.

See https://lists.llvm.org/pipermail/libcxx-dev/2020-December/001060.html.

Differential Revision: https://reviews.llvm.org/D97802
2021-04-01 16:38:34 -04:00
Martin Storsjö 01aa9e1f6e [libcxx] [test] Make the condvar wait_for tests less brittle
These seem to fail occasionally (they are marked as possibly requiring
a retry).

When doing a condvar wait_for(), it can wake up before the timeout
as a spurious wakeup. In these cases, the wait_for() method returns that
the timeout wasn't hit, and the test reruns another wait_for().

On Windows, it seems like the wait_for() operation often can end up
returning slightly before the intended deadline - when intending to
wait for 250 milliseconds, it can return after e.g. 235 milliseconds.
In these cases, the wait_for() doesn't indicate a timeout.

Previously, the test then reran a new wait_for() for a full 250
milliseconds each time. So for N consecutive wakeups slightly too early,
we'd wait for (N+1)*250 milliseconds. Now it only reruns wait_for() for
the remaining intended wait duration.

Differential Revision: https://reviews.llvm.org/D99175
2021-04-01 21:42:11 +03:00
Martin Storsjö 46e992f905 [libcxx] [test] Remove XFAIL LIBCXX-WINDOWS-FIXME from time.clock.file/now.pass.cpp
This doesn't fail when _LIBCPP_HAS_NO_INT128 is defined consistently
in both CMAKE_CXX_FLAGS and LIBCXX_TEST_COMPILER_FLAGS; the XFAIL was
added based on early CI testruns where that flag was missing in
LIBCXX_TEST_COMPILER_FLAGS.

Differential Revision: https://reviews.llvm.org/D99705
2021-04-01 21:25:41 +03:00
Louis Dionne 8f7c1b2272 [libc++] NFC: Add a simple test to make sure we destroy elements in std::list
Differential Revision: https://reviews.llvm.org/D99672
2021-04-01 13:46:33 -04:00
Louis Dionne e93c95dea1 [libc++] Print the CMake version before generating CMake 2021-04-01 13:42:22 -04:00
Louis Dionne 232d3a3e47 [libc++] Fix codesigning in run.py
Without this patch, we'd always try to codesign the first argument in
the command line, which in some cases is not something we can codesign
(e.g. `bash` for some .sh.cpp tests).

Note that this "hack" is the same thing we do in `ssh.py` - we might need
to admit that it's not a hack after all in the future, but I'm not ready
for that yet.

Differential Revision: https://reviews.llvm.org/D99726
2021-04-01 13:39:49 -04:00
Petr Hosek 96d8c6b571 [CMake] Remove {LIBCXX,LIBCXXABI,LIBUNWIND}_INSTALL_PREFIX
These variables were introduced during early work on the runtimes build
but were obsoleted by {LIBCXX,LIBCXXABI,LIBUNWIND}_INSTALL_LIBRARY_DIR.

Differential Revision: https://reviews.llvm.org/D99697
2021-04-01 10:13:07 -07:00
Marek Kurdej 5c703f0fd8 [libc++] Build and test with -Wundef warning. NFC.
This will avoid typos like `_LIBCPP_STD_VERS` (<future>) or using `#if TEST_STD_VER > 17` without including "test_macros.h".

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D99515
2021-04-01 08:32:56 +02:00
Arthur O'Dwyer 3bdd674fbf [libc++] Mark convert_copy.pass.cpp as UNSUPPORTED on clang-13 (i.e. trunk).
Because the constexpr-time codepath triggers a Clang bug. It seems
that Clang compiles it okay in release mode, but when Clang itself
is compiled in debug mode (with assertions turned on), this input
triggers an assertion failure in Clang itself. See comments on D96385
and Clang bug report https://bugs.llvm.org/show_bug.cgi?id=45879

This commit should get the debug-mode buildbots back to green.
2021-03-31 10:22:11 -04:00
Joerg Sonnenberger 9f4022ffeb [libc++] Avoid <climits> dependency in <thread>
The standard guarantees sleep durations of 2^63-1 nanoseconds to work.
Instead of depending on INT64_MAX or ULONGLONG_MAX to exist via the
header pollution, fold the constant directly. That has the additional
positive side effect that it avoids long double arithmetic bugs in GCC.

Differential Revision: https://reviews.llvm.org/D99516
2021-03-31 15:28:16 +02:00