Commit Graph

7767 Commits

Author SHA1 Message Date
Louis Dionne 859c924c5f [libc++] Remove unnecessary header in enable_view.h (which caused a cycle) 2021-06-10 16:35:30 -04:00
Christopher Di Bella bbb3d03f93 [libcxx][ranges][nfc] moves view concepts into `__ranges/concepts.h` 2021-06-10 19:35:00 +00:00
Louis Dionne a0ae3b0789 [libc++abi] Remove the LIBCXXABI_ENABLE_PIC option
Instead, people should be using CMAKE_POSITION_INDEPENDENT_CODE to control
whether they want to use PIC or not. We should try to avoid reinventing
the wheel whenever CMake natively supports something.

This makes libc++abi consistent with libc++ and libunwind.

Differential Revision: https://reviews.llvm.org/D103973
2021-06-10 12:26:31 -04:00
Christopher Di Bella 546449938a [libcxx][optional] adds missing constexpr operations
Makes the following operations constexpr:
  * `std::swap(optional, optional)`
  * `optional(optional<U> const&)`
  * `optional(optional<U>&&)`
  * `~optional()`
  * `operator=(nullopt_t)`
  * `operator=(U&&)`
  * `operator=(optional<U> const&)`
  * `operator=(optional<U>&&)`
  * `emplace(Args&&...)`
  * `emplace(initializer_list<U>, Args&&...)`
  * `swap(optional&)`
  * `reset()`

P2231 has been accepted by plenary, with the committee recommending
implementers retroactively apply to C++20. It's necessary for us to
implement _`semiregular-box`_ and _`non-propagating-cache`_, both of
which are required for ranges (otherwise we'll need to reimplement
`std::optional` with these members `constexpr`ified).

Differential Revision: https://reviews.llvm.org/D102119
2021-06-10 05:52:47 +00:00
Mark de Wever e7c621a607 [libc++][nfc] Test std::unique_ptr self move assignment.
The post-conditions for the self move assignment of `std::unique_ptr`
were changed. This requires no implementation changes. A test was added
to validate the new post-conditions.

Addresses
- LWG-3455: Incorrect Postconditions on `unique_ptr` move assignment

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D103764
2021-06-09 20:43:12 +02:00
Louis Dionne b648c611ed [libc++] Fix libc++ build with assertions enabled
This fixes http://llvm.org/PR50534. This is another take on D103960
which is less disruptive.

Differential Revision: https://reviews.llvm.org/D103964
2021-06-09 12:58:53 -04:00
Christopher Di Bella cdb9d242de [libcxx][ci] enables assertions for runtimes-build
This will catch nasty Clang bugs like
https://bugs.llvm.org/show_bug.cgi?id=50592 before we merge stuff into
libc++ main.

Differential Revision: https://reviews.llvm.org/D103863
2021-06-09 15:38:26 +00:00
Louis Dionne 12933ba9ea [libc++] NFC: Rewrite the documentation for the debug mode 2021-06-08 16:50:12 -04:00
Daniel McIntosh ee2a92c29d [libcxx] Remove VLA from libcxx locale header
The buffer size (`__nbuf`) in `num_put::do_put` is currently not an
integral/core constant expression. As a result, `__nar` is a Variable Length
Array (VLA). VLAs are a GNU extension and not part of the base C++ standard, so
unless there is good reason to do so they probably shouldn't be used in any of
the standard library headers. The call to `__iob.flags()` is the only thing
keeping `__nbuf` from being a compile time constant, so the solution here is to
simply err on the side of caution and always allocate a buffer large enough to
fit the base prefix.

Note that, while the base prefix for hex (`0x`) is slightly longer than the
base prefix for octal (`0`), this isn't a concern. The difference in the space
needed for the value portion of the string is enough to make up for this.
(Unless we're working with small, oddly sized types such as a hypothetical
`uint9_t`, the space needed for the value portion in octal is at least 1 more
than the space needed for the value portion in hex).

This PR also adds `constexpr` to `__nbuf` to enforce compile time const-ness
going forward.

Reviewed By: Mordante, #libc, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D103558
2021-06-08 13:59:34 -04:00
Louis Dionne 4d680b06c9 [libc++] Add a CI configuration for the modular build
Differential Revision: https://reviews.llvm.org/D103559
2021-06-08 13:32:08 -04:00
Louis Dionne d2eccf9bb7 [libc++] NFC: Add regression tests for some <tuple> PRs that have been fixed 2021-06-08 12:17:10 -04:00
Louis Dionne 491d045957 [libc++] Remove the old HTML documentation
This commit finishes moving the <atomic> design documents to the RST
documentation and removes the old documentation. https://libcxx.llvm.org
is already pointing to the new documentation only now, so the removal of
the old documentation is really a NFC.

I went over the old documentation and I don't think we're leaving anything
important behind - I think everything important was mentionned in the RST
documentation anyway.
2021-06-08 11:18:12 -04:00
Petr Hosek 692d7166f7 Revert "[libcxx][gardening] Move all algorithms into their own headers."
This reverts commit 7ed7d4ccb8 as it
uncovered a Clang bug PR50592.
2021-06-07 17:15:20 -07:00
Petr Hosek d9633f229c Revert "[libcxx][module-map] creates submodules for private headers"
This reverts commit f1417eb9b1 as it
uncovered a Clang bug PR50592.
2021-06-07 17:10:05 -07:00
Louis Dionne 85966df3aa [libc++] Rename 'and' to '&&' 2021-06-07 13:48:51 -04:00
Louis Dionne fb4e464618 [libc++] Simplify a few macros in __config
Several macros were guarded with a check along the lines of:

 #ifndef MACRO
 #  define MACRO ...
 #endif

However, some of these macros are never intended to be defined by users,
so it's pointless to make this check (i.e. the first #ifndef is always
true). This commit removes those checks.

The motivation for doing this cleanup is to remove the impression that
arbitrary configurations macros can be defined by users when including
libc++ headers, which doesn't work reliably and leads to macro spaghetti.
If one needs to be able to override a knob in the __config, that's fine,
but the proper way to do that is to document the macro as being a public
facing knob in the documentation, and most likely to migrate that macro
to __config_site (depending on the nature of the macro).

Differential Revision: https://reviews.llvm.org/D103705
2021-06-07 12:45:59 -04:00
Arthur O'Dwyer 11e0882e8d [libc++] graph_header_deps.py: Update the computing of "root" (public) headers.
The "root nodes" of the graph are displayed in bold. My intent here
was to bold just the public-API headers, e.g. <vector> and
<experimental/coroutine> and <stdlib.h>, but not helper headers
such as <__functional_base> and <__iterator/next.h>. However,
the recent mass helper-header-ification has exposed defects in
this logic: all the new helpers were ending up bolded! Fix this.
Also, add <__undef_macros> to the list of headers we don't display
by default (like <__config>); it's not interesting to see those edges.

Also, add a sample `dot` command line to the `--help` text.
2021-06-05 12:47:30 -04:00
Arthur O'Dwyer 469d18c064 [libc++] Fix result-type and value_type computation in <valarray>.
The `operator[]` of `_UnaryOp` and `_BinaryOp` returns the result of
calling `__op_`, so its return type should be `__result_type`, not
e.g. `_A0::value_type`. However, `_UnaryOp::value_type` also should
never have been `_A0::value_type`; it needs to be the correct type
for the result of the unary op, e.g. `bool` when the op is `logical_not`.

This turns out to matter when multiple operators are nested, e.g.
`+(v == v)` needs to have a `value_type` of `bool`, not `int`,
even when `v` is of type `valarray<int>`.

Differential Revision: https://reviews.llvm.org/D103416
2021-06-05 12:29:36 -04:00
Mark de Wever fbe4c839e8 [libc++][doc] Update Format status.
The first part of the <format> header patch series is now complete for
review. This updates the status document.
2021-06-05 13:58:38 +02:00
zoecarver 89599e8b20 [libcxx][ranges] Add concepts in range.utility.helpers.
There are no changes to public APIs.

Differential Revision: https://reviews.llvm.org/D103493
2021-06-04 09:56:31 -07:00
zoecarver d31a2e7554 [libcxx][ranges] Add `ranges::empty_view`.
Differential Revision: https://reviews.llvm.org/D103208
2021-06-04 09:38:49 -07:00
zoecarver 7ed7d4ccb8 [libcxx][gardening] Move all algorithms into their own headers.
This is a fairly mechanical change, it just moves each algorithm into its own header. This is a NFC.

Note: during this change, I burned down all the includes, so this follows "include only and exactly what you use."

Differential Revision: https://reviews.llvm.org/D103583
2021-06-04 09:37:12 -07:00
Louis Dionne a9c9183ca4 [libc++] Use the using_if_exists attribute when provided
As discussed on cfe-dev [1], use the using_if_exists Clang attribute when
the compiler supports it. This makes it easier to port libc++ on top of
new platforms that don't fully support the C Standard library.

Previously, libc++ would fail to build when trying to import a missing
declaration in a <cXXXX> header. With the attribute, the declaration will
simply not be imported into namespace std, and hence it won't be available
for libc++ to use. In many cases, the declarations were *not* actually
required for libc++ to work (they were only surfaced for users to use
them as std::XXXX), so not importing them into namespace std is acceptable.

The same thing could be achieved by conscious usage of `#ifdef` along
with platform detection, however that quickly creates a maintenance
problem as libc++ is ported to new platforms. Furthermore, this problem
is exacerbated when mixed with vendor internal-only platforms, which can
lead to difficulties maintaining a downstream fork of the library.

For the time being, we only use the using_if_exists attribute when it
is supported. At some point in the future, we will start removing #ifdef
paths that are unnecessary when the attribute is supported, and folks
who need those #ifdef paths will be required to use a compiler that
supports the attribute.

[1]: http://lists.llvm.org/pipermail/cfe-dev/2020-June/066038.html

Differential Revision: https://reviews.llvm.org/D90257
2021-06-04 09:55:21 -04:00
Martin Storsjö b0cc7b53a5 [libcxx] Don't use an undefined '+' in unsigned/octal/hexal print formats
If building code like this:

    unsigned long val = 1000;
    snprintf(buf, sizeof(buf), "%+lu", val);

with clang, clang warns

    warning: flag '+' results in undefined behavior with 'u' conversion specifier [-Wformat]

Therefore, don't construct such undefined format strings. (There's
no compiler warnings here, as the compiler can't inspect dynamically
assembled format strings.)

This fixes number formatting in mingw-w64 if built with
`__USE_MINGW_ANSI_STDIO` defined (there, the '+' flag causes a
leading plus to be printed when formatting unsigned numbers too,
while the '+' flag doesn't cause any extra leading plus in other
stdio implementations).

Differential Revision: https://reviews.llvm.org/D103444
2021-06-04 12:07:30 +03:00
Louis Dionne d515a52a3a [libc++] Simplify apple-install-libcxx since we always use the same CMake cache 2021-06-03 18:26:38 -04:00
Louis Dionne db757ba7c5 [libc++] Define _LIBCPP_NO_NATIVE_SEMAPHORES even outside of pthread
<semaphore> needs to know about whether native semaphores are supported
or not, even if we're not using the pthread API.
2021-06-03 18:18:42 -04:00
Louis Dionne 56b6e4e2df [libc++] Also build the static library in the Apple cache 2021-06-03 18:15:20 -04:00
Louis Dionne e4d3a993c2 [libc++] Implement LWG3435 (constraints on reverse_iterator and move_iterator) 2021-06-03 15:49:41 -04:00
Louis Dionne 10d3869952 [libc++] NFC: Tidy up the reverse_iterator tests
Incidentally, that fixes an error with the modules build.
2021-06-03 15:00:13 -04:00
Christopher Di Bella f1417eb9b1 [libcxx][module-map] creates submodules for private headers
Most of our private headers need to be treated as submodules so that
Clang modules can export things correctly. Previous commits that split
monolithic headers into smaller chunks were unaware of this requirement,
and so this is being addressed in one fell swoop. Moving forward, most
new headers will need to have their own submodule (anything that's
conditionally included is exempt from this rule, which means `__support`
headers aren't made into submodules).

This hasn't been marked NFC, since I'm not 100% sure that's the case.

Differential Revision: https://reviews.llvm.org/D103551
2021-06-03 18:18:30 +00:00
Mark de Wever fd3a526085 [libc++][nfc] Add more nasty macros.
D101613 added some macros used by Microsofts SAL. D103425 uses `__pre`
and `__post`. They are also used by SAL and cause issues when used on
Windows. Add them to the blacklist making it easier to figure out what
the issue is.

Differential Revision: https://reviews.llvm.org/D103541
2021-06-03 18:22:52 +02:00
Louis Dionne 2cf78d4ead [libc++] Remove unused variable warnings
Since D100581, Clang started flagging this variable which is set but
never read. Based on comparing this function with __match_at_start_posix_nosubs
(which is very similar), I am pretty confident that `__j` was simply left
behind as an oversight in Howard's 6afe8b0a23.

Also workaround some unused variable warnings in the <random> tests.
It's pretty lame that we're not asserting the skew and kurtosis of
the binomial and negative binomial distributions, but that should be
tackled separately.

Differential Revision: https://reviews.llvm.org/D103533
2021-06-03 09:43:08 -04:00
Louis Dionne 875ff8e059 [libc++] Enable tests for the experimental library by default
This matches the fact that we build the experimental library by default.
Otherwise, by default we'd be building the library but not testing it,
which is inconsistent.

Differential Revision: https://reviews.llvm.org/D102109
2021-06-02 18:39:27 -04:00
Louis Dionne 05d164b25c Revert "[libc++] NFC: Move unwrap_iter to its own header"
This reverts commit 924ea3bb53 *again*, this time because it broke the
LLDB build with modules. We need to figure out what's up with the libc++
modules build once and for all.

Differential Revision: https://reviews.llvm.org/D103369
2021-06-02 15:58:27 -04:00
Daniel McIntosh 06e047227d [libcxx][NFC] Tidy up calculation of __nbuf in num_put::do_put, and add comments
In 07ef8e6796 and 3ed9f6ebde, `__nbuf` started to diverge from the amount
of space that was actually needed for the buffer. For 32-bit longs for example,
we allocate a buffer that is one larger than needed. Moreover, it is no longer
clear exactly where the extra +1 or +2 comes from - they're just numbers pulled
from thin air. This PR cleans up how `__nbuf` is calculated, and adds comments
to further clarify where each part comes from.

Specifically, it corrects the underestimation of the max size buffer needed
that the above two commits had to compensate for. The root cause looks to be
the use of signed type parameters to numeric_limits<>::digits. Since digits
only counts non-sign bits, the calculation was acting as though (for a signed
64-bit type) the longest value we would print was 2^63 in octal. However,
printing in octal treats values as unsigned, so it is actually 2^64. Thus,
using unsigned types and changing the final +2 to a +1 is probably a better
option.

Reviewed By: #libc, ldionne, Mordante

Differential Revision: https://reviews.llvm.org/D103339
2021-06-02 11:46:17 -04:00
Louis Dionne ae4dad2b73 [libc++] Add a CI job to test libc++ when building for 32 bit
Differential Revision: https://reviews.llvm.org/D92508
2021-06-01 22:07:43 -04:00
Louis Dionne 924ea3bb53 [libc++] NFC: Move unwrap_iter to its own header
This re-applies 9968896cd6, which was reverted in b13edf6e90 because
it broke the build.

Differential Revision: https://reviews.llvm.org/D103369
2021-06-01 21:46:59 -04:00
zoecarver 065cf3f9d7 [libcxx][ranges] Add `default_sentinel` and `default_sentinel_t`.
Refs https://eel.is/c++draft/default.sentinel and https://eel.is/c++draft/iterator.synopsis

Differential Revision: https://reviews.llvm.org/D103487
2021-06-01 14:03:54 -07:00
Louis Dionne ba95fa03ce [libc++] Fix the std_include.sh.cpp test that has been failing since c9385297ce
The compiler used on Apple bots doesn't know about -std=c++20 yet, so
we can't use that just yet.

Differential Revision: https://reviews.llvm.org/D103475
2021-06-01 16:31:51 -04:00
zoecarver 5671ff20d9 [libcxx] Implement view.interface.
This will unblock work on ranges::view. Based on D101396.

Refs http://eel.is/c++draft/view.interface.

Differential Revision: https://reviews.llvm.org/D101737
2021-06-01 12:34:47 -07:00
Louis Dionne 95cb06d234 [libc++] Temporary hack to unbreak CI
Until I figure out what the issue is with this test on AppleClang (and
in particular which change caused it), I want to avoid all CI being broken.
2021-06-01 13:49:55 -04:00
Martin Storsjö 41d7909368 [libcxx] [test] Fix the _supportsVerify check on Windows by fixing quoting
The pipes.quote function quotes using single quotes, the same goes
for the newer shlex.quote (which is the preferred form in Python 3).
This isn't suitable for quoting in command lines on Windows (and the
documentation for shlex.quote even says it's only usable for Unix
shells).

In general, the python subprocess.list2cmdline function should do
proper quoting for the platform's current shell. However, it doesn't
quote the ';' char, which we pass within some arguments to run.py.
Therefore use the custom reimplementation from lit.TestRunner which
is amended to quote ';' too.

The fact that arguemnts were quoted with single quotes didn't matter
for command lines that were executed by either bash or the lit internal
shell, but if executing things directly using subprocess.call, as in
_supportsVerify, the quoted path to %{cxx} fails to be resolved by the
Windows shell.

This unlocks 114 tests that previously were skipped on Windows.

Differential Revision: https://reviews.llvm.org/D103310
2021-06-01 09:51:41 +03:00
Martin Storsjö 23f7f56cec [libcxx] [test] Fix the include_as_c.sh.cpp test in MSVC configurations
Avoid including a header that is known not to work with clang in MSVC
mode when compiling as C.

(Alternatively, this could be something like "XFAIL: clang && msvc",
but I think it's more useful to actually check the rest of the test
instead of expecting the whole test to fail.)

Differential Revision: https://reviews.llvm.org/D103400
2021-05-31 22:13:22 +03:00
Martin Storsjö be34d5f74a [libcxx] [test] Remove an incorrect TEST_HAS_ALIGNED_ALLOC define from test_macros.h
This was added inconsistently in
19fd9039ca242f408493b5c662f9d908eab8555e; Windows doesn't have the
aligned_alloc function (neither MSVC nor MinGW toolchains) and we don't
define _LIBCPP_HAS_ALIGNED_ALLOC while building libcxx.

Differential Revision: https://reviews.llvm.org/D103399
2021-05-31 22:13:22 +03:00
Martin Storsjö c8644ae1e9 [libcxx] Define LIBCPP_HAS_TIMESPEC_GET for MSVC configurations
This define was out of sync with the corresponding define in tests, it
was added inconsistently in 171c77b7da.

Modern MSVC environments do have these typedefs and functions.

Differential Revision: https://reviews.llvm.org/D103398
2021-05-31 22:13:22 +03:00
Martin Storsjö b48a256e9c [libcxx] [test] Don't look for the literal spelling __mbstate_t in warnings
While the code uses the type name `std::mbstate_t`, the warning message
mentions the original underlying type, which is a C library internal
type name.

On Windows this type is called `_Mbstatet` instead of `__mbstate_t`. Use
expect-warning-re to avoid spelling out the literal name of the type.

Due to issues with the detection of the clang-verify feature, these
tests have been skipped in the Windows CI configuration so far.

Differential Revision: https://reviews.llvm.org/D103309
2021-05-31 22:13:21 +03:00
Christopher Di Bella bf92bdad77 [libcxx][nfc] moves std `advance`, `next`, and `prev` into their headers
Differential Revision: https://reviews.llvm.org/D103329
2021-05-31 17:14:52 +00:00
Harald van Dijk 73cdc7599b [libc++] [test] Fix a few tests for 32-bit x86
Fixes bug https://llvm.org/PR48939.

Differential Revision: https://reviews.llvm.org/D102359
2021-05-31 12:38:43 -04:00
Louis Dionne 41bdf64d3e [libc++] Update all the pre-defined iterator types for C++20
Make sure we provide the correct It::difference_type member and update
the tests and synopses to be accurate.

Supersedes D102657 and D103101 (thanks to the original authors).

Differential Revision: https://reviews.llvm.org/D103273
2021-05-31 11:59:40 -04:00
Arthur O'Dwyer d39f5c3cb9 [libc++] Avoid `result_type` and `unary/binary_function` in <valarray>.
Give each of the relevant functional operators a `__result_type`
instead, so that we can keep using those typedefs in <valarray>
even when the public binder typedefs are removed in C++20.

Differential Revision: https://reviews.llvm.org/D103371
2021-05-31 11:29:16 -04:00
Martin Storsjö 7d7b72bad7 [libcxx] [test] Add UNSUPPORTED: msvc in a couple verify.cpp tests
Due to issues with the detection of the clang-verify feature, these
tests have been skipped in the Windows CI configuration so far.

Differential Revision: https://reviews.llvm.org/D103308
2021-05-31 10:58:32 +03:00
Arthur O'Dwyer bfbd73f87d [libc++] Alphabetize and include-what-you-use. NFCI.
Differential Revision: https://reviews.llvm.org/D102781
2021-05-29 19:54:48 -04:00
Arthur O'Dwyer c9385297ce [libc++] [modules] Add __threading_support to the modulemap.
It looks to me as if *every* helper header needs to be added to the modulemap,
actually; which is unfortunate since we keep proliferating them at such a
rapid pace.
2021-05-29 19:54:38 -04:00
Arthur O'Dwyer 5cc55fdb57 [libc++] [test] Update "test_compare.h" users to avoid removed-in-C++20 members. NFCI.
Drive-by minor improvements to a couple of uses of min_pointer.

Differential Revision: https://reviews.llvm.org/D103366
2021-05-29 16:54:24 -04:00
Mark de Wever b13edf6e90 Revert "[libc++] NFC: Move unwrap_iter to its own header"
This reverts commit 9968896cd6.

This commit seems to cause the build failures of main.
2021-05-29 09:50:26 +02:00
Arthur O'Dwyer 8a5f0d8838 [libc++] [test] Constexpr-ify a couple of insert-iterator tests.
This should have been done in D96385; thanks ldionne for the catch!
Also, make the back/front inserter behavior tests a little more thorough,
which incidentally caught a cut-and-paste-bug in `nasty_list`, so fix that.

Differential Revision: https://reviews.llvm.org/D103318
2021-05-28 15:15:50 -04:00
Louis Dionne 9968896cd6 [libc++] NFC: Move unwrap_iter to its own header 2021-05-28 12:42:07 -04:00
Louis Dionne 58b29a4efc [libc++] Add all indirect callable concepts and projected
Differential Revision: https://reviews.llvm.org/D101277
2021-05-28 10:10:44 -04:00
Martin Storsjö b3ceffdf35 [libcxx] [test] Convert an XFAIL LIBCXX-WINDOWS-FIXME into UNSUPPORTED with explanation
Differential Revision: https://reviews.llvm.org/D103149
2021-05-27 23:51:24 +03:00
Louis Dionne aad878f112 [libc++] NFC: Make it easier for vendors to extend the run-buildbot script 2021-05-27 16:51:47 -04:00
Louis Dionne 8d7d7f340e [libc++] NFC: Refactor raw_storage_iterator test to use UNSUPPORTED markup
The test would previously disable itself using `#if TEST_STD_VER` instead
of using UNSUPPORTED markup.
2021-05-27 14:23:32 -04:00
Louis Dionne b6399e85d8 Revert "[libc++] NFC: Parenthesize expression to satisfy GCC 11"
That fix was actually incorrect and caused tests to start failing.
2021-05-27 13:42:39 -04:00
Louis Dionne 73099e786a [libc++] NFC: Parenthesize expression to satisfy GCC 11
Otherwise it issues a -Werror=parentheses suggesting parentheses.
2021-05-27 11:41:29 -04:00
Louis Dionne 1055cb91b4 [libc++] Deprecate std::iterator and remove it as a base class
C++17 deprecated std::iterator and removed it as a base class for all
iterator adaptors. We implement that change, but we still provide a way
to inherit from std::iterator in the few cases where doing otherwise
would be an ABI break.

Supersedes D101729 and the std::iterator base parts of D103101 and D102657.

Differential Revision: https://reviews.llvm.org/D103171
2021-05-27 11:34:04 -04:00
Christopher Di Bella 0dc7fd1bc1 [libcxx][iterator] adds `std::ranges::prev`
Implements part of P0896 'The One Ranges Proposal'.
Implements [range.iter.op.prev].

Depends on D102563.

Differential Revision: https://reviews.llvm.org/D102564
2021-05-27 04:41:27 +00:00
Christopher Di Bella 857fa7b7b1 [libcxx][iterator] adds `std::ranges::next`
Implements part of P0896 'The One Ranges Proposal'.
Implements [range.iter.op.next].

Depends on D101922.

Differential Revision: https://reviews.llvm.org/D102563
2021-05-27 04:41:26 +00:00
zoecarver 52123c96c0 [libcxx][nfc] Fix the ASAN bots: update expected.pass.cpp.
Ensures that `get_return_object`'s return type is the same as the return type for the function calling `co_return`. Otherwise, we try to construct an object, then free it, then return it.

Differential Revision: https://reviews.llvm.org/D103196
2021-05-26 14:06:25 -07:00
zoecarver 367cb9fbd6 [libcxx][docs] Take mutex for common_iterator, common_view, and empty_view. 2021-05-26 13:29:16 -07:00
Louis Dionne cc622aee30 [libc++] Add a job testing on GCC 11
I'm adding the job as a soft-fail for now, but once all the tests have
been fixed to work on it, we'll switch over from GCC 10 to GCC 11 and
remove the soft-fail.

Differential Revision: https://reviews.llvm.org/D103116
2021-05-26 15:48:33 -04:00
Mark de Wever 963495f0d4 [libc++][format] Adds availability macros for std::format.
This prevents std::format to be available until there's an ABI stable
version. (This only impacts the Apple platform.)

Depends on D102703

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D102705
2021-05-26 17:54:33 +02:00
Mark de Wever de9df3f5b9 [libc++][NFC] Move basic_format_parse_context to its own header.
This is a preparation to split the format header in smaller parts for the
upcoming patches.

Depends on D101723

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D102703
2021-05-26 17:50:09 +02:00
Mark de Wever 16342e3994 [libc++][NFC] Move format_error to its own header.
Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D101723
2021-05-26 17:43:23 +02:00
Louis Dionne 31191e15b6 [libc++] Fix concepts tests with GCC 2021-05-26 11:21:55 -04:00
Christopher Di Bella 36d0fdf9ac [libcxx][iterator] adds `std::ranges::advance`
Implements part of P0896 'The One Ranges Proposal'.
Implements [range.iter.op.advance].

Differential Revision: https://reviews.llvm.org/D101922
2021-05-26 04:27:30 +00:00
Louis Dionne 66781efd0a [libc++] Install GCC 11 on CI builders 2021-05-25 17:35:08 -04:00
Arthur O'Dwyer d42d9e10b6 [libc++] [P0619] Hide not1 and not2 under _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS.
This also provides some of the scaffolding needed by D102992 and D101729, and mops up after D101730 etc.

Differential Revision: https://reviews.llvm.org/D103055
2021-05-25 16:57:16 -04:00
Martin Storsjö 68e4596253 [libcxx] Fix the function name in exceptions from create_directories
If the nested create_directory call fails, we'd still want to
re-report the errors with the create_directories function name,
which is what the caller called.

This fixes one aspect from MS STL's tests for std::filesystem.

Differential Revision: https://reviews.llvm.org/D102365
2021-05-25 23:48:50 +03:00
Martin Storsjö ec402f1d5d [libcxx] [test] Explain an XFAIL LIBCXX-WINDOWS-FIXME and convert into UNSUPPORTED
This particular test relies on internal details from the libc++
filesystem implementation header, and those details are structured
differently in the implementation for Windows.

Differential Revision: https://reviews.llvm.org/D102357
2021-05-25 22:59:55 +03:00
Martin Storsjö 3a6be27978 [libcxx] Make the visibility attributes consistent for __narrow_to_utf8/__widen_from_utf8
Use the same visiblity attributes as for all other template
specializations in the same file; declare the specialization itself
using _LIBCPP_TYPE_VIS, and don't use _LIBCPP_EXPORTED_FROM_ABI on
the destructor. Methods that are excluded from the ABI are marked
with _LIBCPP_INLINE_VISIBILITY.

This makes the vtable exported from DLL builds of libc++. Practically,
it doesn't make any difference for the CI configuration, but it
can make a difference in mingw setups.

Differential Revision: https://reviews.llvm.org/D102717
2021-05-25 22:57:16 +03:00
Louis Dionne d95a4b950d [libc++] Try to fix the oss-fuzz failure 2021-05-25 12:52:22 -04:00
Arthur O'Dwyer bb523cc82b [libc++] [test] Make iter_difference_t.pass.cpp into a .compile.pass.cpp. NFCI. 2021-05-25 11:12:42 -04:00
Arthur O'Dwyer 148c19a5b5 [libc++] [test] Format some C++20 iterator_traits tests. NFCI.
cxx20_iterator_traits.compile.pass.cpp actually depends on
implementation details of libc++, which is not great;
but I just left a comment and moved on.
2021-05-25 11:12:36 -04:00
Arthur O'Dwyer fc9248877d [libc++] Assume that __wrap_iter always wraps a fancy pointer.
Not only do we conscientiously avoid using `__wrap_iter` for non-contiguous
iterators (in vector, string, span...) but also we make the assumption
(in regex) that `__wrap_iter<_Iter>` is contiguous for all `_Iter`.

So `__wrap_iter<reverse_iterator<int*>>` should be considered IFNDR,
and every `__wrap_iter` should correctly advertise contiguity in C++20.

Drive-by simplify some type traits.

Reviewed as part of https://reviews.llvm.org/D102781
2021-05-24 17:30:21 -04:00
Mark de Wever 7b2606b0b6 [libc++][doc] Update format paper status.
- Fixes paper number P1862 -> P1868. (The title was correct.)
- Marks P1868 as in progress.
- Marks P1892 as in progress.
- Marks LWG-3327 as nothing to do, since the wording change doesn't
  impact the code. (Also updated on the general C++20 status page.)
2021-05-24 16:48:44 +02:00
Joerg Sonnenberger cb15116451 [libc++] use more early returns for consistency
Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D96983
2021-05-23 23:10:45 +02:00
zoecarver 8110a73164 [libcxx][gardening] Re-order includes across libcxx.
This commit alphabetizes all includes in libcxx. This is a NFC.

This can also serve as a pseudo "announcement" for how we should order these headers going forward (note: double underscores go before other headers).

Differential Revision: https://reviews.llvm.org/D102941
2021-05-21 13:22:10 -07:00
zoecarver 9db55b314b [libcxx][ranges] Add ranges::data CPO.
This is the second to last one! Based on D101396. Depends on D100255. Refs D101079 and D101193.

Differential Revision: https://reviews.llvm.org/D101476
2021-05-21 11:07:23 -07:00
Louis Dionne 31bcdb6635 [libc++] Translate the test suite sanitizer support to the DSL
Differential Revision: https://reviews.llvm.org/D102108
2021-05-20 15:30:48 -04:00
zoecarver c40b02608e [libcxx][ranges] Implement `ranges::borrowed_range`.
Differential Revision: https://reviews.llvm.org/D102426
2021-05-20 11:51:44 -07:00
Louis Dionne 5c26f895b6 [libc++] Fix documentation build failure 2021-05-20 11:01:10 -04:00
Louis Dionne cb82e8ea33 [libc++] Remove workaround for PR28391 (ODR violations with ASAN)
This is not an issue anymore since we don't build the libc++ dylib with
C++14 anymore (see https://llvm.org/PR28391) for details.

Differential Revision: https://reviews.llvm.org/D102106
2021-05-20 10:48:36 -04:00
Louis Dionne b274728b1a [libc++] Switch a few CI jobs to the minimal Lit configuration
Eventually, this should become the default way of running the tests.
For now, only move a few CI nodes to it, and keep a node that runs the
legacy configuration.

Differential Revision: https://reviews.llvm.org/D97565
2021-05-20 10:46:59 -04:00
Christopher Di Bella d8fad66149 [libcxx][ranges] adds concept `sized_range` and cleans up `ranges::size`
* adds `sized_range` and conformance tests
* moves `disable_sized_range` into namespace `std::ranges`
* removes explicit type parameter

Implements part of P0896 'The One Ranges Proposal'.

Differential Revision: https://reviews.llvm.org/D102434
2021-05-19 18:16:45 +00:00
Christopher Di Bella 0f80365722 [libcxx][iterator][nfc] acquires lock for working on [range.iter.ops]
Differential Revision: https://reviews.llvm.org/D101845
2021-05-19 18:05:33 +00:00
Amy Huang 7c2f58278e Apply [[standalone_debug]] to some types in the STL.
Add this attribute to some types to ensure that they have
debug info.
The debug info for these classes are required for debuggers to display
some STL types. With constructor homing (a new debug info optimization)
their debug info isn't emitted because their constructors are never
called.

The list of types with the attribute added are __hash_value_type,
__value_type, __tree_node_base, __tree_node, __hash_node, __list_node,
and __forward_list_node.

Differential Revision: https://reviews.llvm.org/D98750
2021-05-18 17:01:07 -07:00
Arthur O'Dwyer 06b40e80ae [libc++] Alphabetize header inclusions and include-what-you-use <__debug>. NFCI. 2021-05-18 19:56:30 -04:00
Arthur O'Dwyer e130fbe24e [libc++] Some fixes to the <bit> utilities.
Fix __bitop_unsigned_integer and rename to __libcpp_is_unsigned_integer.
There are only five unsigned integer types, so we should just list them out.
Also provide `__libcpp_is_signed_integer`, even though the Standard doesn't
consume that trait anywhere yet.

Notice that `concept uniform_random_bit_generator` is specifically specified
to rely on `concept unsigned_integral` and *not* `__is_unsigned_integer`.
Instantiating `std::ranges::sample` with a type `U` satisfying
`uniform_random_bit_generator` where `unsigned_integral<U::result_type>`
and not `__is_unsigned_integer<U::result_type>` is simply IFNDR.

Orthogonally, fix an undefined behavior in std::countr_zero(__uint128_t).

Orthogonally, improve tests for the <bit> manipulation functions.
It was these new tests that detected the bug in countr_zero.

Differential Revision: https://reviews.llvm.org/D102328
2021-05-18 19:56:30 -04:00
Kristina Bessonova 9f4f012c10 [libcxx][test] Attempt to make debug mode tests more bulletproof
The problem with debug mode tests is that it isn't known which particular
_LIBCPP_ASSERT causes the test to exit, and as shown by
https://reviews.llvm.org/D100029 and 2908eb20ba it might be not the
expected one.

The patch adds TEST_LIBCPP_ASSERT_FAILURE macro that allows checking
_LIBCPP_ASSERT message to ensure we caught an expected failure.

Reviewed By: Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D100595
2021-05-18 14:52:34 +02:00
Kristina Bessonova a18b5f0188 [libcxx] NFC. Add missed articles to _LIPCPP_ASSERT messages in <list> 2021-05-17 10:15:43 +02:00
zoecarver bede7523b1 [libcxx][ranges] Add `contiguous_iterator`.
Differential Revision: https://reviews.llvm.org/D101396
2021-05-14 15:27:40 -07:00
Mark de Wever a85b1320b6 [libc++] Improve make_string test support.
Adds MAKE_CSTRING and makes the operators of `MultiStringType` `constexpr`.

The code is copied from D96664 so it can be used in D80895.

Differential Revision: https://reviews.llvm.org/D102414
2021-05-14 17:42:17 +02:00
Martin Storsjö c12c8124e1 [libcxx] [test] Change the generic_string_alloc test to test conversions to all char types
On windows, the native path char type is wchar_t - therefore, this test
didn't actually do the conversion that the test was supposed to exercise.

The charset conversions on windows do cause extra allocations outside of
the provided allocator though, so that bit of the test has to be waived
now that the test actually does something. (Other tests have similar
TEST_NOT_WIN32() for allocation checks for charset conversions.)

Also fix a typo, and amend the path.native.obs/string_alloc test to
test char8_t, too.

Differential Revision: https://reviews.llvm.org/D102360
2021-05-14 11:56:48 +03:00
zoecarver fe319a8848 [libcxx][docs] Add two locks: transform_view and take_view.
Assign myself both of these views.
2021-05-13 11:49:20 -07:00
zoecarver 3ac9ff5577 [libcxx][docs] Update the One Ranges PRoposal Status with open revisions.
1. Moves the names into the names column.
2. Changes the names to reflect who's actually working on what.
3. Adds open revisions.
2021-05-13 11:49:20 -07:00
zoecarver 98e4fd0701 [libcxx][ranges] Fix `ranges::empty` when begin, end, and empty members are provided.
Before this commit, we'd get a compilation error because the operator() overload was ambiguous.

Differential Revision: https://reviews.llvm.org/D102263
2021-05-13 10:07:57 -07:00
Kristina Bessonova 8a86787847 [libcxx] NFC. Fix misprint unodered -> unordered
Differential Revision: https://reviews.llvm.org/D102354
2021-05-13 09:57:29 +02:00
Christopher Di Bella 46c17429bc [libcxx] modifies `_CmpUnspecifiedParam` ignore types outside its domain
D85051's honeypot solution was a bit too aggressive swallowed up the
comparison types, which made comparing objects of different ordering
types ambiguous.

Depends on D101707.

Differential Revision: https://reviews.llvm.org/D101708
2021-05-13 00:45:39 +00:00
Martin Storsjö 6bd3d8a17c [libcxx] [test] Fix fs.op.last_write_time for Windows
Don't use stat and lstat on Windows; lstat is missing, stat only provides
the modification times with second granularity (and does the wrong thing
regarding symlinks). Instead do a minimal reimplementation using the
native windows APIs.

Differential Revision: https://reviews.llvm.org/D101731
2021-05-12 22:23:01 +03:00
Mark de Wever c273f5ef7d [libc++][nfc] remove duplicated __to_unsigned.
Both `<type_traits>` and `<charconv>` implemented this function with
different names and a slightly different behavior. This removes the
version in `<charconv>` and improves the version in `<typetraits>`.

- The code can be used again in C++11.
-  The original claimed C++14 support, but `[[nodiscard]]` is not
   available in  C++14.
- Adds `_LIBCPP_INLINE_VISIBILITY`.

Reviewed By: zoecarver, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D102332
2021-05-12 21:09:49 +02:00
Kristina Bessonova 96100f1508 [libcxx] NFC. Correct wordings of _LIBCPP_ASSERT debug messages
Differential Revision: https://reviews.llvm.org/D102195
2021-05-12 13:49:57 +02:00
Kristina Bessonova f8306647fa [libcxx][test] Split more debug mode tests
Split a few more debug mode tests missed in D100592.

Differential Revision: https://reviews.llvm.org/D102194
2021-05-12 08:28:16 +02:00
Vladimir Vereschaka 384dd9ddaf [libc++] Run `substitutes-in-compile-flags.sh.cpp` test on Windows.
Fix for substitutes-in-compile-flags.sh.cpp to run it properly on Windows platform.

Differential Revision: https://reviews.llvm.org/D102048
2021-05-11 11:42:13 -07:00
Martin Storsjö 68de58cd64 [libcxx] [test] Fix filesystem permission tests for windows
On Windows, the permission bits are mapped down to essentially only
two possible states; readonly or readwrite. Normalize the checked
permission bitmask to match what the implementation will return.

Differential Revision: https://reviews.llvm.org/D101728
2021-05-11 20:43:24 +03:00
zoecarver db13f832a1 [libcxx][tests] Fix incomplte.verify tests by disabling them on clang-10.
For some reason clang-10 can't match the expected errors produced by
passing icomplete arrays to range access functions. Disabling the tests
is a stop-gap solution to fix the bots.
2021-05-11 09:46:18 -07:00
Arthur O'Dwyer 6491d99e33 [libc++] Remove more unnecessary _VSTD:: from type names. NFCI.
Differential Revision: https://reviews.llvm.org/D102181
2021-05-11 12:23:55 -04:00
Arthur O'Dwyer 866b27950a [libc++] s/_VSTD::is_unsigned/is_unsigned/ in <random>. NFCI. 2021-05-11 12:23:55 -04:00
Arthur O'Dwyer aa5e3beea3 [libc++] s/_VSTD::chrono/chrono/g. NFCI. 2021-05-11 12:23:55 -04:00
Arthur O'Dwyer 0b8da5fa59 [libc++] s/std::size_t/size_t/g. NFCI. 2021-05-11 12:23:55 -04:00
Arthur O'Dwyer ab3fcc5065 [libc++] s/_VSTD::declval/declval/g. NFCI. 2021-05-11 12:23:55 -04:00
Kristina Bessonova 65e40f0b26 [libcxx][test] Make string.modifiers/clear_and_shrink_db1.pass.cpp a regular mode test
Turn this test into a normal mode as it contains well-formed code and
checks for defined behavior. It still can be run in debug mode as of D100866.

Differential Revision: https://reviews.llvm.org/D102192
2021-05-11 10:16:10 +02:00
Christopher Di Bella 578d09c1b1 [libcxx] deprecates/removes `std::raw_storage_iterator`
C++17 deprecates `std::raw_storage_iterator` and C++20 removes it.

Implements part of:
  * P0174R2 'Deprecating Vestigial Library Parts in C++17'
  * P0619R4 'Reviewing Deprecated Facilities of C++17 for C++20'

Differential Revision: https://reviews.llvm.org/D101730
2021-05-11 06:43:29 +00:00
Christopher Di Bella 9eb0969a76 [libcxx] makes comparison operators for `std::*_ordering` types hidden friends
The standard leaves it up to the implementation to decide whether or not
these operators are hidden friends. There are several (well-documented)
reasons to prefer hidden friends, as well as an argument for improved
readability.

Depends on D100342.

Differential Revision: https://reviews.llvm.org/D101707
2021-05-11 06:41:45 +00:00
Christopher Di Bella 20506fb1f3 [libcxx] removes operator!= and globally guards against no spaceship operator
* `operator!=` isn't in the spec
* `<compare>` is designed to work with `operator<=>` so it doesn't
  really make sense to have `operator<=>`-less friendly sections.

Depends on D100283.

Differential Revision: https://reviews.llvm.org/D100342
2021-05-11 06:40:54 +00:00
zoecarver e5d483f28a [libcxx][ranges] Add ranges::empty CPO.
Depends on D101079. Refs D101189.

Differential Revision: https://reviews.llvm.org/D101193
2021-05-10 17:14:39 -07:00
Christopher Di Bella 4ff2fe1df0 [libcxx] removes `weak_equality` and `strong_equality` from <compare>
`weak_equality` and `strong_equality` were removed before being
standardised, and need to be removed.

Also adjusts `common_comparison_category` since its test needed
adjusting due to the equality deletions.

Differential Revision: https://reviews.llvm.org/D100283
2021-05-10 20:45:04 +00:00
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