Commit Graph

7642 Commits

Author SHA1 Message Date
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
Martin Storsjö 7acfd85756 [libcxx] [test] Don't add dirs from the LIB env var to PATH
The directories in LIB normally only contain import libraries or
static libraries, no runtime DLLs that would need to be found
while running tests.

This code stems from 1cd196e7b4,
which (among other things) tried to do this:

> * [Test] Fix handling of library runtime search paths by correctly adding them
>   to the PATH variable when running the tests.

It's unclear to me exactly what this fixed (or tried to) at the time,
as the LIB var doesn't normally point to runtime libs.

Differential Revision: https://reviews.llvm.org/D99241
2021-03-31 09:05:47 +03:00
Martin Storsjö 4a0a85becc [libcxx] [test] Fix tests of <cuchar> that unexpectedly succeed on windows
The tests expect that the <cuchar> include should fail. When libc++
is built on top of the MSVC runtime, the header does exist provided
by MSVC. Therefore, just mark the test as unsupported on windows,
to avoid tests that unexpectedly succeed.

Differential Revision: https://reviews.llvm.org/D99096
2021-03-31 09:05:47 +03:00
Louis Dionne c06a8f9caa [libc++] Include <__config_site> from <__config>
Prior to this patch, we would generate a fancy <__config> header by
concatenating <__config_site> and <__config>. This complexifies the
build system and also increases the difference between what's tested
and what's actually installed.

This patch removes that complexity and instead simply installs <__config_site>
alongside the libc++ headers. <__config_site> is then included by <__config>,
which is much simpler. Doing this also opens the door to having different
<__config_site> headers depending on the target, which was impossible before.

It does change the workflow for testing header-only changes to libc++.
Previously, we would run `lit` against the headers in libcxx/include.
After this patch, we run it against a fake installation root of the
headers (containing a proper <__config_site> header). This makes use
closer to testing what we actually install, which is good, however it
does mean that we have to update that root before testing header changes.
Thus, we now need to run `ninja check-cxx-deps` before running `lit` by
hand.

Differential Revision: https://reviews.llvm.org/D97572
2021-03-30 14:06:11 -07:00
Louis Dionne 180e9e5eab [libc++] Add a CI job to test the Runtimes build
Differential Revision: https://reviews.llvm.org/D97888
2021-03-30 09:00:30 -04:00
Louis Dionne 478d1eded2 [libc++] Re-enable macOS back-deployment testing
Download older roots from Dropbox instead of Green Dragon, which is too
unreliable. Also XFAIL tests that were broken for back-deployment
configurations by D98097.

Differential Revision: https://reviews.llvm.org/D99359
2021-03-29 22:09:23 -04:00
Petr Hosek bc4d3ca7bd [libcxx] Use integer division
In Python 3, math.floor returns int when both arguments are ints.
In Python 2, math.floor returns float. This leads to a failure
because the result of math.floor is used as an array index. While
Python 2 is on its way out, it's still used in some places so use
an integer division instead.

Differential Revision: https://reviews.llvm.org/D99520
2021-03-29 11:59:44 -07:00
Christopher Di Bella 24c44c379f [libcxx] adds std::identity to <functional>
Implements parts of:
    - P0898R3 Standard Library Concepts

Differential Revision: https://reviews.llvm.org/D98151
2021-03-29 16:16:05 +00:00
Christopher Di Bella e06f1a8e3c [libcxx] reworks invocable and regular_invocable tests
The tests for `std::invocable` and `std::regular_invocable` were
woefully incomplete. This patch closes many of the gaps (though some
probably remain).

Differential Revision: https://reviews.llvm.org/D99398
2021-03-29 15:26:05 +00:00
Arthur O'Dwyer 199d2ebeed [libc++] Use _EnableIf and __iter_value_type consistently. NFCI.
Specifically, use these metafunctions consistently in areas that are
about to be affected by P1518R2's changes.

This is the NFCI part of https://reviews.llvm.org/D97742 .
The functional-change part is still waiting for P1518R2 to be
officially merged into the working draft.
2021-03-29 09:22:52 -04:00
Christopher Di Bella 24dd2d2f9e [libcxx] rearranges all concept tests
moves tests into directories matching their stable names so that the
tests can reflect the concept name

Differential Revision: https://reviews.llvm.org/D99104
2021-03-27 22:13:58 +00:00
Zbigniew Sarbinowski 4d478121f3 [SystemZ][z/OS] exclude nasty_macros.h from check-cxx
Need to exclude nasty_macros.h from check-cxx on z/OS due to conflicts within system headers.

Sample failure in `random_shuffle.depr_in_cxx14.verify.cpp` libcxx test.
```
error: 'error' diagnostics seen but not expected:
Line 1268: expected ')'
Line 1268: unknown type name 'This'
Line 1268: expected ')'
```

caused by the following  macros in `nasty_macros.h`
```
#define NASTY_MACRO This should not be expanded!!!
#define _E NASTY_MACRO
```
The name collision is observed in the following code snippet whre `_E` is being used as parameter name:
```
inline int iswalnum(wint_t _E) {return __iswalnum(_E);}
```

It is reasonable to exclude `nasty_macros.h` on z/OS similarly as it was done on Windows.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D99378
2021-03-26 15:08:37 +00:00
Marek Kurdej 0324b46cd8 [libc++] [C++2b] [P2162] Allow inheritance from std::variant.
This patch changes the variant even in pre-C++2b.
It should not break anything, only allow use cases that didn't work previously.

Notes:
 `__as_variant` is used in `__visitation::__variant::__visit_alt`, but I haven't used it in `__visitation::__variant::__visit_alt_at`.
That's because it is used only in `__visit_value_at`, which in turn is always used on variant specializations (that's in comparison operators).

* https://wg21.link/P2162

Reviewed By: ldionne, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D97394
2021-03-25 18:20:50 +01:00
Arthur O'Dwyer e21ab31f45 [libc++] Eliminate <compare>'s dependency on <array>.
This refactor is not only a good idea, but is in fact required by the standard,
in the sense that <array> is mandated to include <compare>.
So <compare> shouldn't have a circular dependency on <array>!

Differential Revision: https://reviews.llvm.org/D99307
2021-03-25 10:34:35 -04:00
Arthur O'Dwyer 06e2b737aa [libc++] [P1032] Misc constexpr bits in <iterator>, <string_view>, <tuple>, <utility>.
This completes the implementation of P1032's changes to <iterator>,
<string_view>, <tuple>, and <utility> in C++20.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1032r1.html

Drive-by fix a couple of unintended rvalues in "*iterators*/*.fail.cpp".

Differential Revision: https://reviews.llvm.org/D96385
2021-03-25 10:34:35 -04:00
Martin Storsjö b8b23aa80e [libcxx] [test] Quote env variables that are set with a shell "export" in ssh.py
This safeguards against cases if some of the env vars contain chars
that are problematic for shells, e.g. if called with --env "X=Y;Z".

(In cases of cross testing for windows, the PATH variable can end up
specified with semicolon separators - even if specifying a PATH when
cross testing in such differing environments might not make sense or
do anything - but this makes ssh.py not break on such a variable.)

Differential Revision: https://reviews.llvm.org/D99242
2021-03-25 09:46:44 +02:00
Christopher Di Bella 3f143a10cc [libcxx] updates regular_invocable test to actually test regular_invocable
The test wasn't previously testing this concept, but its base.

Differential Revision: https://reviews.llvm.org/D99306
2021-03-25 06:33:48 +00:00
jasonliu 09a84d3047 [libc++] Match declaration for non-member function std::swap(std::packaged_task) with what standard specify
Standard specifies:
```
template<class R, class... ArgTypes>
  void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
```

Differential Revision: https://reviews.llvm.org/D99102
2021-03-24 22:33:32 +00:00
jasonliu 158026301b [libc++][AIX] Initial patch to unblock the libc++ build on AIX
This path would unblock the build of libc++ library on AIX:
1. Add _AIX guard for _LIBCPP_HAS_THREAD_API_PTHREAD
2. Use uselocale to actually take the locale setting
   into account.
3. extract_mtime and extract_atime mod needed for AIX. As stat
   structure on AIX uses internal structure st_timespec to store
   time for binary compatibility reason. So we need to convert it
   back to timespec here.
4. Do not build cxa_thread_atexit.cpp for libcxxabi on AIX.

Differential Revision: https://reviews.llvm.org/D97558
2021-03-24 22:13:20 +00:00
Martin Storsjö 675401e04c [libcxx] Avoid pulling in xlocinfo.h in public headers
Including xlocinfo.h is a bit of a layering violation; locale.h is
the C library header we should use, while xlocinfo.h is essentially
part of the MS C++ library. Including xlocinfo.h brings in yvals.h,
which brings in yvals_core.h, which defines the MS STL's version
support macros, overriding what libc++'s <version> had defined.

Instead just include locale.h, and provide the few defines we need
for locale categories manually.

Differential Revision: https://reviews.llvm.org/D99213
2021-03-24 23:29:59 +02:00
Louis Dionne 6427c53940 [libc++] Use add_lit_testsuite to register the libc++ test suite
The Runtimes build uses variables set by add_lit_testsuite to discover
tests suites to run.

Differential Revision: https://reviews.llvm.org/D97913
2021-03-24 16:47:34 -04:00
Louis Dionne c504c68fac [libc++] Add a CI configuration with static libc++/libc++abi
Differential Revision: https://reviews.llvm.org/D99268
2021-03-24 16:30:48 -04:00
Martin Storsjö b6c4b280a0 [libcxx] [test] Add return values after assert(false) in some experimental tests
When building in MSVC mode (in release mode), the assert(false) don't
make the end of the function unreachable, so add return statements to
silence compiler warnings (treated as errors).

Also change 'virtual' into 'override', which was requested in review,
as these files require C++11.

Differential Revision: https://reviews.llvm.org/D99214
2021-03-24 11:44:01 +02:00
Louis Dionne 6c93eb4477 [libc++] Remove old cache file that was left behind by accident 2021-03-23 14:15:48 -04:00
Arthur O'Dwyer a644920a02 [libc++] Simpler Python script for generating a graph of libc++'s header dependencies
My attempts to play around with the old graph_header_deps.py were mostly fruitless;
I needed to modify it in various ways to make it work, and then even when I got it
working, it generated pretty ugly graphs.

Old graph_header_deps.py (after my local changes to simplify the usage)
(producing https://i.imgur.com/zATrsaP.jpg )

    mkdir foo
    time ./graph_header_deps.py --libcxx-only -o foo --clang-command ~/llvm-project/build/bin/clang++
    dot -Tpng < foo/all_headers.dot > old.png
    file old.png

    real    0m37.453s
    old.png: PNG image data, 25882 x 3035, 8-bit/color RGBA, non-interlaced

New graph_header_deps.py
(producing https://i.imgur.com/ZU0G52U.png )

    time ./graph_header_deps.py | dot -Tpng > new.png
    file new.png

    real    0m1.063s
    new.png: PNG image data, 6162 x 1344, 8-bit/color RGBA, non-interlaced

Differential Revision: https://reviews.llvm.org/D99124
2021-03-23 14:12:05 -04:00
Louis Dionne 2e033b36bf [libc++] NFC: nodebug => no-debug in the CI configurations 2021-03-23 14:10:27 -04:00
Marek Kurdej 28f82bec7f [libc++] [C++20] [P0482] Add missing tests and synopses for char8_t.
Left to finish P0482:
* <cuchar> header.
* Parts of <memory_resource> concerning char8_t. Also, tests for hash<pmr::*string>.

Reviewed By: ldionne, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D99184
2021-03-23 18:45:31 +01:00
Marek Kurdej 00a6d3dfa6 [libc++] Add missing test_macros.h include in tests using TEST_STD_VER. 2021-03-23 18:40:44 +01:00
Martin Storsjö 7a804c0979 [libcxx] Consistently set CMAKE_STATIC_LIBRARY_PREFIX regardless of LIBCXX_ENABLE_STATIC
CMAKE_STATIC_LIBRARY_PREFIX affects the naming of all static libs (in
MSVC configurations), including c++experimental, which only is produced
as static regardless of LIBCXX_ENABLE_STATIC.

Differential Revision: https://reviews.llvm.org/D99176
2021-03-23 18:18:16 +02:00
Arthur O'Dwyer 43aaf87173 [libc++] Include <__config> first in all standard headers.
Mostly, *don't* include <experimental/__config> from C++17 <any>,
because that doesn't make any sense. I think it was just a cut-and-paste
typo when this header moved from experimental/.

Differential Revision: https://reviews.llvm.org/D99089
2021-03-22 19:01:18 -04:00
Martin Storsjö 695ec081a4 [libcxx] [test] Fix fs.op.proximate for windows
Simmilar to many other similar path handling tests, convert the
test reference to preferred separators, and ifdef a few test references
that use network root names.

Additionally, generalize code for trimming off the root path for
generating relative_cwd, and for skipping the root name element
in count_path_elems.

Rename one fictive path for consistency with the other test cases,
and add a bunch of more test cases for completeness.

Differential Revision: https://reviews.llvm.org/D98988
2021-03-23 00:32:44 +02:00
Martin Storsjö 4f7fa06a66 [libcxx] [test] Add XFAIL LIBCXX-WINDOWS-FIXME in 124 tests that fail in the future CI configuration
This makes no attempt yet to look into the why/what for each of them,
but makes the CI configuration useful for tracking further regressions.
After looking into each case, they can either be fixed, or converted
into UNSUPPORTED: windows or XFAIL: windows, once the cause is known
and explained.

A number of the filesystem cases can be fixed by patches that are
currently in review.

Differential Revision: https://reviews.llvm.org/D99095
2021-03-22 23:41:11 +02:00
Martin Storsjö 247f8f6719 [libcxx] [test] Remove a couple outdated XFAIL LIBCXX-WINDOWS-FIXME
With current versions of MSVC, these tests do succeed.

Differential Revision: https://reviews.llvm.org/D99094
2021-03-22 23:41:10 +02:00
Martin Storsjö 4c402ae880 [libcxx] [test] Don't leave test dirs behind in fs.op.current_path on Windows
Fix nesting of static_env and CWDGuard, restore the cwd (with
CWDGuard) before cleaning up the static_env.

Previously, every test run left 2 directories behind in the temp dir.

Differential Revision: https://reviews.llvm.org/D98954
2021-03-22 23:41:10 +02:00
Louis Dionne 1e337b1dd9 [libc++] Revert "[SystemZ][z/OS] Missing wchar functions libc++"
This reverts commit febbf68b42 because it
added files that were not under the LLVM license.

See https://reviews.llvm.org/D98207 for details.
2021-03-22 17:35:43 -04:00
Arthur O'Dwyer 2ac6babcc0 [libc++] Move __libcpp_erase_if_container into <iterator>, and ADL-proof it.
The container headers don't need to include <functional> for any other reason
(or at least, they wouldn't if we moved `less` and `equal_to` out of <functional>),
so let's put `__libcpp_erase_if_container` somewhere that's common to the
containers but outside of <functional>.

Also, calling `std::erase_if(c, pred)` should not trigger ADL.

Differential Revision: https://reviews.llvm.org/D99043
2021-03-22 11:13:33 -04:00
Louis Dionne 116b8525c9 [libc++] Run ninja with --verbose
This makes it easier to see what exact build commands are used.

Differential Revision: https://reviews.llvm.org/D98992
2021-03-22 09:17:52 -04:00
Louis Dionne 976eba51d0 [libc++] NFCI: Remove dead code in the Lit configuration
I was trying to fix something else and I stumbled upon several methods
that are not used anymore in target_info.py.

Differential Revision: https://reviews.llvm.org/D98896
2021-03-19 12:01:30 -07:00
Martin Storsjö 7a154c3230 [libcxx] [test] Account for differences in a trailing slash in weakly_canonical
This seems to be a documented quirk in libc++'s implementation of
weakly_canonical (in a comment in the weakly_canonical test).
Together with a difference between windows and posix regarding whether
paths can go through nonexistent dirs, this results in a difference in
a trailing slash.

Just document this as expected, and degrade the comment from fixme to
a note, as MS STL and libstdc++ behave in the same way.

Differential Revision: https://reviews.llvm.org/D98642
2021-03-19 18:49:05 +02:00
David Spickett 3aa6a4cb39 [libcxx][Arm] Move buildbot flags into cmake files
Reviewed By: #libc, Mordante, curdeius

Differential Revision: https://reviews.llvm.org/D98771
2021-03-19 16:45:09 +00:00
Arthur O'Dwyer 72557476d4 [libc++] Consistency on _LIBCPP_CLANG_VER tests in <type_traits>.
This came out of my review comments on D97283.

This patch re-enables the use of `__is_fundamental`, `__is_signed`, etc.
on non-Clang compilers. Previously, when we found that a builtin didn't
work on old Clangs, we had been reacting by limiting its use to new Clangs
(i.e., we'd also stop using it on new GCCs and new MSVCs, just because of
the old Clang bug). I claim that this was unintentional.

Notice that on Apple Clang, `_LIBCPP_COMPILER_CLANG` is defined and
`_LIBCPP_CLANG_VER` is not defined (therefore `0` in arithmetic expressions).
We assume that Apple Clang has all the bugs of all the Clangs.

Differential Revision: https://reviews.llvm.org/D98720
2021-03-19 10:49:00 -04:00
Martin Storsjö 2ec9239a7b [libcxx] [test] Fix weakly_canonical for windows
Differential Revision: https://reviews.llvm.org/D98643
2021-03-19 16:12:24 +02:00
Martin Storsjö b982c6f5fa [libcxx] [test] Avoid race conditions between tests regarding temp directories
Prior to e0d01294bc, all tests used a
random directory name, but now it is deterministic, based on the
test name. This change was done under the assumption that the filename
portion of the cwd is unique across tests that use the filesystem
test temporary directories.

When running tests locally, the cwd of the test is something like
"<build-dir>/test/<test path>/Output/copy_assign.pass.cpp.dir",
and the filename portion, "copy_assign.pass.cpp.dir", is used as
base for the temp directory names.

The change noted that there's a risk for race conditions if multiple
threads within one test try to create temp directories in parallel, but
that doesn't really happen in practice.

However, if running tests with a large number of parallel workers,
multiple tests with the same filename portion, e.g. "copy_assign.pass.cpp.dir",
can run in parallel, leading to race conditions across processes.

Therefore, add a hash of the full cwd to distinguish such cases
from each other.

Secondly, don't use two separate levels of temporary directories
(<base>/static_env.0). When cleaning up, only the individual
directory is removed, leaving the empty intermediate directory
behind littering the temp directory.

Differential Revision: https://reviews.llvm.org/D98703
2021-03-19 16:12:24 +02:00
Martin Storsjö aee005f912 [libcxx] [test] Fix windows errors in fs.op.rename
Differential Revision: https://reviews.llvm.org/D98640
2021-03-19 16:12:24 +02:00
Martin Storsjö c9fc1a979c [libcxx] [test] Explicitly check that some env vars are ignored in the temp_dir_path test
This was suggested in the review of D98139.

Differential Revision: https://reviews.llvm.org/D98696
2021-03-19 09:33:26 +02:00
Muiez Ahmed f6af5efcec [SystemZ][z/OS] vasprintf fix libc++
The aim is to use the correct vasprintf implementation for z/OS libc++, where a copy of va_list ap is needed. In particular, it avoids the potential that the initial internal call to vsnprintf will modify ap and the subsequent call to vsnprintf will use that modified ap.

Differential Revision: https://reviews.llvm.org/D97473
2021-03-18 15:00:57 -04:00
Markus Böck 6359049c35 [CMake][runtimes] Add file level dependency to merge_archives commands
Both libc++ and libc++abi have options of merging with another archive. In the case of libc++abi, libunwind can be merged into it and in the case of libc++, libc++abi can be merged into it.

This is realized using add_custom_command with POST_BUILD and the usage of the CMake generator expression TARGET_LINKER_FILE in the arguments. For such generator expressions CMake doc states: "This target-level dependency does NOT add a file-level dependency that would cause the custom command to re-run whenever the executable is recompiled" [1]

This patch adds a DEPENDS argument to both add_custom_command invocations so that the archives also have a file-level dependency on the target they are merging with. That way, changes in say, libunwind source code, will be updated in the libc++abi and/or libc++ static libraries as well.

[1] https://cmake.org/cmake/help/v3.20/command/add_custom_command.html

Differential Revision: https://reviews.llvm.org/D98129
2021-03-18 18:51:10 +01:00
Arthur O'Dwyer eb37d3546c [libc++] Future-proof generate_feature_test_macro_components.py against long names.
`__cpp_lib_default_template_type_for_algorithm_values` is 52 characters long,
which is enough to reduce the multiplier to less-than-zero, producing an empty
string between the name of the macro and its numeric value. Ensure there's
always a space between the name of the macro and its value.

Differential Revision: https://reviews.llvm.org/D98869
2021-03-18 13:35:28 -04:00
Louis Dionne 6a9e7b117b [libc++] Remove the Docker files for BuildBot
We don't use them anymore since we're using the BuildKite setup.

Differential Revision: https://reviews.llvm.org/D97779
2021-03-18 10:24:48 -07:00
Christopher Di Bella 580416d573 [libcxx] updates the feature-test macro generator
D97015 didn't correctly update `generate_feature_test_macro_components.py`.

Reviewed By: ldionne, Quuxplusone, #libc, Mordante

Differential Revision: https://reviews.llvm.org/D97904
2021-03-18 17:08:10 +00:00
Martin Storsjö 6718ce4037 [libcxx] [docs] Fix formatting of inline verbatim snippets in the Windows section
Use double backticks instead of single, as single backticks produces
italic formatting.
2021-03-17 11:41:45 +02:00
Martin Storsjö 42d653d294 [libcxx] Simplify rounding of durations in win32 __libcpp_thread_sleep_for
Also fix a comment typo, and remove a superfluous "std::" qualififcation
in __libcpp_semaphore_wait_timed for consistency.

This mirrors what was suggested in review of
1773eec692.

Differential Revision: https://reviews.llvm.org/D98015
2021-03-17 10:09:10 +02:00
Arthur O'Dwyer 0aa637b203 [libc++] Improve src/filesystem's formatting of paths.
This is my attempt to merge D98077 (bugfix the format strings for
Windows paths, which use wchar_t not char)
and D96986 (replace C++ variadic templates with C-style varargs so that
`__attribute__((format(printf)))` can be applied, for better safety)
and D98065 (remove an unused function overload).

The one intentional functional change here is in `__create_what`.
It now prints path1 and path2 in square-brackets _and_ double-quotes,
rather than just square-brackets. Prior to this patch, it would
print either path double-quoted if-and-only-if it was the empty
string. Now the double-quotes are always present. I doubt anybody's
code is relying on the current format, right?

Differential Revision: https://reviews.llvm.org/D98097
2021-03-16 15:00:36 -04:00
Tomas Matheson 64595f9b84 [libcxx][type_traits] add tests for is_signed and is_unsigned
In previous versions of clang, __is_signed and __is_unsigned builtins did not
correspond to is_signed and is_unsigned behaviour for enums.  The builtins were
fixed in D67897 and D98104.

* Disable the fast path of is_unsigned for clang versions < 13

* Add more tests for is_signed, is_unsigned and is_arithmetic

Differential Revision: https://reviews.llvm.org/D97283
2021-03-16 16:36:10 +00:00
Martin Storsjö b5e228fc00 [libcxx] [test] Fix the temp_directory_path test for windows
Check a different set of env vars, don't check the exact value
of the fallback path. (GetTempPath falls back to returning the Windows
folder if nothing better is available in env vars.)

The test still fails one check on windows (due to relying on perms::none),
which will be addressed separately.

Differential Revision: https://reviews.llvm.org/D98139
2021-03-15 19:24:56 +02:00
Martin Storsjö d07e5c23b4 [libcxx] [test] Fix the get_temp_file_name() function for mingw
Add the missing includes for getting the defines and functions used
in the mingw version of get_temp_file_name().

This fixes 31 tests when built in a mingw configuration.

Also remove a redundant ifdef; _WIN32 is defined in mingw targets too.

Differential Revision: https://reviews.llvm.org/D97456
2021-03-15 18:52:49 +02:00
Martin Storsjö f5f3a59837 [libcxx] [test] Disable some allocation checks in class.path tests on windows
On windows, the path internal representation is wchar_t, and
input/output often goes through utf8 inbetween, which causes extra
allocations.

MS STL also fails a number of strict allocation checks, so this
shouldn't be a standards compliance issue.

Differential Revision: https://reviews.llvm.org/D98398
2021-03-15 18:52:48 +02:00
Martin Storsjö 995a128f07 [libcxx] [docs] Update docs about how to build for Windows
Refresh the existing paragraphs on building in MSVC configurations,
add a sample of one working configuration for MinGW, and add more
details on what's necessary to run the tests these days.

Differential Revision: https://reviews.llvm.org/D97166
2021-03-15 17:30:26 +02:00
Muiez Ahmed 62705ee012 [SystemZ][z/OS] Define _LIBCPP_ELAST
The aim is to define _LIBCPP_ELAST for z/OS libc++ since strerror/strerror_r can't handle out-of-range errno values.

Differential Revision: https://reviews.llvm.org/D98541
2021-03-15 09:23:36 -04:00
Muiez Ahmed febbf68b42 [SystemZ][z/OS] Missing wchar functions libc++
The aim is to add the missing z/OS specific implementations for mbsnrtowcs and wcsnrtombs, as part of libc++.

Differential Revision: https://reviews.llvm.org/D98207
2021-03-12 15:39:31 -05:00
Christopher Di Bella 8d4af1b6e0 [libcxx] adds concept std::regular
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D97911

Reviewed By: EricWF, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D98154
2021-03-12 08:54:03 -08:00
David Spickett 44e36fc2b1 [libcxx] Move Linaro 32 bit armv bots to buildkite
Instead of setting mcpu like the previous bots,
set the target triple.

Each config builds either Arm only or Thumb only
code. This gives us some coverage of thumb specific
issues.

The new agents on Linaro's side are running on v8 hardware
so will report arch "armv8l" just like the v8 bots.
(and buildkite can choose any of them for v7/v8 jobs)

Reviewed By: #libc, curdeius, Mordante

Differential Revision: https://reviews.llvm.org/D98019
2021-03-12 09:47:07 +00:00
Christopher Di Bella 154395536e [libcxx] adds concept std::semiregular
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D97443

Reviewed By: Quuxplusone, EricWF, #libc

Differential Revision: https://reviews.llvm.org/D97911
2021-03-11 22:40:07 -08:00
Christopher Di Bella 8ef69c66d5 [libcxx] adds concept std::copyable
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D97359

Reviewed By: EricWF, #libc, Quuxplusone, zoecarver

Differential Revision: https://reviews.llvm.org/D97443
2021-03-11 19:30:55 -08:00
Christopher Di Bella dc9f385722 [libcxx] adds concept std::movable
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D97162

Reviewed By: EricWF, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D97359
2021-03-11 19:27:43 -08:00
Marek Kurdej e9ba25b59d [libc++] [docs] Add link to clang status page for C++2b and fix anchor for C++20. 2021-03-11 20:49:14 +01:00
Martin Storsjö e69c65d5c4 [libcxx] Test accessing a directory on windows that gives "access denied" errors
Fix handling of skip_permission_denied on windows; after converting
the return value of GetLastError() to a standard error_code, ec.value()
is in the standard errc range, not a native windows error code. This
was missed in 156180727d.

The directory "C:\System Volume Information" does seem to exist and
have these properties on most relevant contempory setups.

Differential Revision: https://reviews.llvm.org/D98166
2021-03-11 21:07:29 +02:00
Martin Storsjö 8ba05e1489 [libcxx] [test] Disable a test regarding error behaviour for excessively long paths on windows
Checking for the existence of an invalid long path name isn't
an error in itself on windows.

Differential Revision: https://reviews.llvm.org/D98141
2021-03-11 20:21:54 +02:00
Martin Storsjö 49173ca4db [libcxx] Avoid intermediate string objects for substrings in windows operator/=
Check that appends with a path object doesn't do allocations, even
on windows.

Suggested by Marek in D98398. The patch might apply without D98398
(depending on how much of the diff context has to match), but doesn't
make much sense until after that patch has landed.

Differential Revision: https://reviews.llvm.org/D98412
2021-03-11 19:34:59 +02:00
Martin Storsjö cb2648e6f0 [libcxx] [test] Use a string_view of the native path type in the concat test
This makes sure that no extra allocations happen on windows, fixing
earlier errors in the DisableAllocationGuard (in the second case that
is modified).

This is split out from D98398.

Differential Revision: https://reviews.llvm.org/D98406
2021-03-11 19:34:58 +02:00
Aditya Kumar 6976255faf Add noreturn attribute to non-returning functions
Differential Revision: https://reviews.llvm.org/D97308
2021-03-10 14:35:50 -08:00
Martin Storsjö e23317c9da [libcxx] [test] Adjust separator form in fs.op.absolute for libc++ on windows
This test was previously tweaked in
321f696920 to match the output of
of MS STL (except that the MS STL fails on the testcase with an
empty path).

libc++ doesn't produce paths with all normalized separators (and the
spec doesn't mandate it to either).

Tweak the test reference to match exactly what libc++ produces. If
testing with a non-libc++ library, do a relaxed comparison that allows
the separators to differ.

Differential Revision: https://reviews.llvm.org/D98215
2021-03-09 16:57:26 +02:00
Muiez Ahmed ebe6161c54 [SystemZ][z/OS] Missing locale functions libc++
The aim is to add the missing z/OS specific locale functions for libc++ (newlocale, freelocale and uselocale).

Reviewed By: ldionne, #libc, curdeius

Differential Revision: https://reviews.llvm.org/D98044
2021-03-08 19:32:33 +00:00
Martin Storsjö b9f169fb7d [libcxx] Document windows specifics regarding file_type and perms. NFC.
This was requested in the review of D98138.

Differential Revision: https://reviews.llvm.org/D98155
2021-03-08 15:27:07 +02:00
Arthur O'Dwyer ab49f50ad0 [libc++] Fix typos in the synopsis of bit_xor, bit_not, etc. NFC. 2021-03-07 20:22:50 -05:00
Martin Storsjö 3a11a41795 [libcxx] [test] Don't test CharFile (/dev/null) on windows
Also clarify a nearby comment regarding block devices.

Differential Revision: https://reviews.llvm.org/D98138
2021-03-07 23:26:41 +02:00
Martin Storsjö 52c5f5ad5f [libcxx] [test] Fix building create_directory in MSVC configurations
Don't use the mode_t type - the official windows sdk doesn't have that type.
(Mingw headers does have such a typedef though.) The umask function returns
int on windows, in both header variants.

Thus just use auto to deduce the umask return type automatically.

Differential Revision: https://reviews.llvm.org/D98140
2021-03-07 23:26:41 +02:00
Martin Storsjö 4d571cf4e9 [libcxx] [test] Clarify and improve consistency in lexically_relative_and_proximate.pass.cpp. NFC.
Use "expect" instead of "output" for generating "proximate_expected",
pass the arguments to PathEq in the same order as above, rename the
"proximate_expected" variable to be consistent with the naming of the
earlier "expect", use .empty() instead of .native().empty().

Differential Revision: https://reviews.llvm.org/D98127
2021-03-07 23:15:05 +02:00
Martin Storsjö ab67fd39fc [libcxx] [test] Fix path.modifiers remove_filename and replace_filename for windows
Also fix the synopsis in the replace_filename test, while touching
that file.

Differential Revision: https://reviews.llvm.org/D98108
2021-03-07 10:37:13 +02:00
Martin Storsjö d601edf0b0 [libcxx] [test] Fix lexically_normal and lexically_relative_and_proximate for windows
Convert the expected result path to preferred separators, add exceptions
to the test results where needed (due to some cases being interpreted
as a root name).

Differential Revision: https://reviews.llvm.org/D98106
2021-03-06 22:42:38 +02:00
Martin Storsjö 15fdd536f9 [libcxx] [test] Fix path.itr/iterator.pass.cpp for windows
Differential Revision: https://reviews.llvm.org/D98107
2021-03-06 19:27:14 +02:00
David Zarzycki f4059cc352 Partially revert "[runtimes] Use add_lit_testsuite to register lit testsuites"
This partially reverts commit e1173c8794
until we find out why libcxx tests are failing under runtimes build.
2021-03-06 06:06:55 -05:00
Martin Storsjö 714644a36c [libcxx] [test] Move the is_<platform> functions down to subclasses
If cross testing (and manually specifying a LIBCXX_TARGET_INFO in the
cmake configuration, as the default is to match the build platform),
we want the accessors for querying the target platform, is_windows,
is_darwin, to return the right value depending on which target info
class is used, not based on what platform is running the build and
driving the tests.

When LIBCXX_TARGET_INFO isn't defined, the right target info class
is chosen automatically based on the platform one is running on, so
this shouldn't make any practical difference for such setups.

Differential Revision: https://reviews.llvm.org/D98045
2021-03-06 08:52:34 +02:00
Christopher Di Bella c744332793 [libcxx] adds std::ranges::swap, std::swappable, and std::swappable_with
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96742

Differential Revision: https://reviews.llvm.org/D97162
2021-03-05 19:03:57 -08:00
Jessica Clarke 5d6e0e474e [benchmark] Replace references to M680x0 with M68k
The former was the old unusual name of the out-of-tree backend but it
was renamed to M68k during the code review process to conform with how
almost everything refers to the Motorola 68000 family of processors.
Thus, update the comments to avoid confusion when the backend lands.
2021-03-06 01:04:36 +00:00
Martin Storsjö 9e29852f5c [libcxx] [test] Fix detection of clang-cl when cross compiling
When cross compiling, the compiler tool doesn't have a .exe suffix.

Differential Revision: https://reviews.llvm.org/D98026
2021-03-06 00:49:26 +02:00
Martin Storsjö 1540646dbd [libcxx] Don't add -Wall when building in MSVC mode
The MSVC -Wall (or /Wall) option maps (in clang-cl) to the GCC style
option -Weverything, which we don't really want. Instead use -W4 which
is the corresponding MSVC option.

This silences the build with clang-cl, which previously used to
output 100 warnings per translation unit.

Differential Revision: https://reviews.llvm.org/D98035
2021-03-05 23:48:02 +02:00
Martin Storsjö 24a176b107 [libcxx] Apply pragma for silencing warning when building with clang-cl too
This silences warnings about unused functions (in an anonymous
namespace).

Differential Revision: https://reviews.llvm.org/D98036
2021-03-05 21:36:54 +02:00
Petr Hosek e1173c8794 [runtimes] Use add_lit_testsuite to register lit testsuites
The runtimes build uses variables set by add_lit_testsuite to collect
testsuites from all the runtimes.

Differential Revision: https://reviews.llvm.org/D97913
2021-03-05 10:37:21 -08:00
Martin Storsjö 232fec941d [libcxx] [test] Add an option to ssh.py for using a different temp path
If cross testing on Windows via WSL (at least with WSL 1), the Windows
executables can't be executed if they are in WSL specific directories
(like /tmp).

Differential Revision: https://reviews.llvm.org/D98028
2021-03-05 19:37:31 +02:00
Martin Storsjö 1adaf48d23 [libcxx] [test] Fix path.decompose for windows
Add ifdefs to the test reference tables for cases where paths are
interpreted differently (paths that contain a root name).

Fix test assumptions regarding has_root_name() and is_absolute() and
add logic to verify the results of is_absolute() for the test cases in
the table.

Also add a testcase for the path "//net/", which seemed like an
omission.

Differential Revision: https://reviews.llvm.org/D89943
2021-03-05 19:37:31 +02:00
Marek Kurdej 43e4214173 [libc++] [C++2b] [P1682] Add to_underlying.
* https://wg21.link/P1682

Reviewed By: ldionne, Mordante, #libc

Differential Revision: https://reviews.llvm.org/D97365
2021-03-05 10:31:21 +01:00
Martin Storsjö 29012ce986 [libcxx] Map ERROR_BAD_PATHNAME to errc::no_such_file_or_directory on windows
Opening a path like \\server (without a trailing share name and
path) produces this error, while opening e.g. \\server\share
(for a nonexistent server/share) produces ERROR_BAD_NETPATH (which
already is mapped).

This happens in some testcases (in fs.op.proximate); as proximate()
calls weakly_canonical() on the inputs, weakly_canonical() checks
whether the path exists or not. When the error code wasn't recognized
(it mapped to errc::invalid_argument), the stat operation wasn't
conclusive and weakly_canonical() errored out. With the proper error
code mapping, this isn't considered an error, just a nonexistent
path, and weakly_canonical() can proceed.

This roughly matches what MS STL does - it doesn't have
ERROR_BAD_PATHNAME in its error code mapping table, but it
checks for this error code specifically in the return of their
correspondence of the stat function.

Differential Revision: https://reviews.llvm.org/D97619
2021-03-05 10:49:03 +02:00
Martin Storsjö 99c7b53294 [libcxx] Avoid infinite recursion in create_directories, if the root directory doesn't exist
Differential Revision: https://reviews.llvm.org/D97618
2021-03-05 10:49:01 +02:00
Martin Storsjö 1773eec692 [libcxx] Implement semaphores for windows
Also add WIN32_LEAN_AND_MEAN before including windows.h, for consistency
with other sources.

Differential Revision: https://reviews.llvm.org/D97539
2021-03-05 10:48:59 +02:00
Christopher Di Bella 6eb5d55c55 [libcxx] fixes up some [concepts]-related code
* moves `std::copy_constructible` so it comes before
  `std::equality_comparable_with`
* replaces a few uses of `auto`
2021-03-04 22:09:43 -08:00
Christopher Di Bella e63ddcccf8 [libcxx] adds concepts std::equality_comparable[_with]
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96660

Reviewed By: ldionne, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D97176
2021-03-04 18:24:04 -08:00
Martin Storsjö 53d7c63657 [libcxx] [test] Use separate references for windows in the path.append test
Differential Revision: https://reviews.llvm.org/D89945
2021-03-04 23:21:02 +02:00
Louis Dionne c7f244b897 [libc++] Properly pick up the Ninja from Xcode in the CI script 2021-03-04 16:03:39 -05:00
Muiez Ahmed 53c8587dcd [SystemZ][z/OS] Missing non-posix functions libc++
The aim is to add missing non-posix functions for z/OS libc++ (strtod_l and strtof_l).

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D97051
2021-03-04 15:23:21 +00:00
David Spickett 6e5342a6b0 [libcxx] Move Linaro AArch64 buildbots to buildkite
Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D96267
2021-03-04 10:22:17 +00:00
Martin Storsjö c793f68d9b [libcxx] Don't use dllimport for a static member in a template
This fixes clang warnings (that are treated as errors when running
the test suite):

libcxx/include/string:4409:59: error: definition of dllimport static field [-Werror,-Wdllimport-static-field-def]
               basic_string<_CharT, _Traits, _Allocator>::npos;

The warning is normally not visible as long as the libc++ headers
are treated as system headers.

The same construct is always an error in MSVC.

(One _LIBCPP_FUNC_VIS was added in
2d8f23f571, which broke DLL builds.
59919c4d6b fixed this by adding another
_LIBCPP_FUNC_VIS on the declaration for consistency, but the underlying
issue remained, that one can't use dllimport here.)

Differential Revision: https://reviews.llvm.org/D97168
2021-03-04 08:55:27 +02:00
Christopher Di Bella 647af31e74 [libcxx] adds concept `std::assignable_from`
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96660

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96742
2021-03-03 22:41:55 -08:00
Christopher Di Bella f893312c1a [libcxx] adds concept `std::common_with`
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96660

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96683
2021-03-03 20:01:11 -08:00
Arthur O'Dwyer 09fa1d0e50 [libc++] Introduce __identity_t<T>. NFCI.
This is just a shorter synonym for `__identity<T>::type`.
Use it consistently throughout, where possible.

There is still some metaprogramming in <memory> and <variant>
where `__identity` is being used _without_ immediately calling
`::type` on it; but this is the unusual case, and it will become
even less usual as we start deliberately protecting certain types
against deduction (e.g. D97742).

Differential Revision: https://reviews.llvm.org/D97862
2021-03-03 22:23:14 -05:00
Christopher Di Bella 3f5438c46c [libcxx] adds concept `std::common_reference_with`
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96657

Reviewed By: ldionne, Mordante, #libc

Differential Revision: https://reviews.llvm.org/D96660
2021-03-03 17:52:41 -08:00
Louis Dionne 460953ad9a [libc++] Temporary hack: disable Apple back-deployment testing
Apple back-deployment testing is currently failing because Green Dragon
is down. To avoid stalling the whole CI pipeline because of that, I am
temporarily disabling those jobs until Green Dragon is back, or even
better we have found a different way to store those small artifacts.
2021-03-03 17:02:48 -05:00
Louis Dionne 3c62198c61 [libc++] NFC: Normalize links to bug reports 2021-03-03 13:45:29 -05:00
Louis Dionne 5034d7115d [libc++] Use generator expression to simplify the CMake code
A comment was left for when we would require CMake >= 3, which we do now.
I expect this should be a NFC.

Differential Revision: https://reviews.llvm.org/D97341
2021-03-03 12:59:51 -05:00
Louis Dionne 5601305fb3 [libc++/abi] Replace uses of _NOEXCEPT in src/ by noexcept
We always build the libraries in a Standard mode that supports noexcept,
so there's no need to use the _NOEXCEPT macro.

Differential Revision: https://reviews.llvm.org/D97700
2021-03-03 12:57:31 -05:00
zoecarver 84a50f5911 [libc++] Add bind_front function (P0356R5).
Implementes [[ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0356r5.html | P0356R5 ]]. Adds `bind_front` to `functional`.

Reviewed By: ldionne, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D60368
2021-03-02 16:18:06 -08:00
Christopher Di Bella eadece333f [libcxx] adds common_reference to <type_traits>
Implements part of P0898R3 Standard Library Concepts

Reworks D74351 to use requires-clauses over SFINAE and so that it more
closely follows the wording.

Co-authored by: Michael Schellenberger Costa <mschellenbergercosta@googlemail.com>

(Michael did all the heavy lifting and I came in to polish it for
 submission, since Michael is focussing on `std::format` now.)

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96657
2021-03-02 22:33:37 +00:00
Martin Storsjö 34ee3d91a8 [libcxx] [test] Pass some windows environment variables through to test processes
Normally, the run.py wrapper script runs the child processes in
a clean environment, with only the environment variables available
that are passed via the --env parameter.

However, the COMSPEC and TEMP variables are kind of necessary when
running some tests; COMSPEC is necessary for finding the interpreter
when executing commands via std::system().

Before f1a96de1bc, tests were executed
via an intermediate shell which implicitly readded the COMSPEC variable.

The TEMP variable allows temp files to be placed in a sensible
location; if unset, they're placed in the default temp fallback of
C:\Windows instead.

Differential Revision: https://reviews.llvm.org/D97452
2021-03-02 22:39:14 +02:00
Martin Storsjö c5e8f024dc [libcxx] Explicitly return the expected error code in create_directories if the parent isn't a directory
On windows, going ahead and actually trying to create the directory
doesn't return an error code that maps to
std::errc::not_a_directory in this case.

This fixes two cases of
    TEST_CHECK(ErrorIs(ec, std::errc::not_a_directory))
in filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
for windows (in testcases added in 59c72a7012).

Differential Revision: https://reviews.llvm.org/D97090
2021-03-02 22:21:29 +02:00
Martin Storsjö 4adb4bca05 [libcxx] [test] Fix a test error with condvars with trivial destruction
If the destructor is trivial (_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION,
the constructor always is), the compiler warns about the
std::condition_variable being unused.

Add a cast to void to silence the warning about the object being unused.

Differential Revision: https://reviews.llvm.org/D97540
2021-03-02 20:34:22 +02:00
Louis Dionne c5659dd4cc [libc++] Add a utility script to run the Docker image used by builders
Several contributors have been asking me how to reproduce the CI
environment locally. This is the last step towards making that work
out-of-the-box. Basically, just run `libcxx/utils/ci/run-buildbot-container`
and you're good to go.

Differential Revision: https://reviews.llvm.org/D97782
2021-03-02 13:06:14 -05:00
Martin Storsjö 74c883f7e5 [libcxx] [test] Use the native path types in path.compare
This makes sure that it actually tests the right compare() overloads
in windows configurations.

This also fixes the allocation guards that enforce no allocations
while running the compare() functions.

Differential Revision: https://reviews.llvm.org/D97551
2021-03-01 21:01:46 +02:00
Louis Dionne 60ba1fefab [libc++/abi] Allow running back-deployment testing against libc++abi
Before this patch, we could only link against the back-deployment libc++abi
dylib. This patch allows linking against the just-built libc++abi, but
running against the back-deployment one -- just like we do for libc++.

Also, add XFAIL markup to flag expected errors.

Differential Revision: https://reviews.llvm.org/D91069
2021-03-01 12:13:03 -05:00
Marek Kurdej 11ef785cdd [libc++] [docs] [C++2b] Update status page with issues (and forgotten papers) adopted in November 2020 and February 2021 virtual meetings.
Sources:
* https://github.com/cplusplus/draft/pull/4380 (November 2020)
* https://github.com/cplusplus/draft/pull/4523 (February 2021)
* https://github.com/cplusplus/draft/issues?q=is%3Aissue+LWG+Motion
2021-03-01 11:19:18 +01:00
Vitaly Buka 3744ba24dc [NFC][libc++] Suppress "warning: ignoring return value"
According to the comment on the next line
it's expected behaviour.
2021-02-26 14:32:54 -08:00
Casey Carter 30cd3dd0fb [libcxx][test] Don't require Container<cv T> extension on non-libc++
... when testing `default_initializable`. Also, include `<memory>` for `unique_ptr`.
2021-02-26 13:40:22 -08:00
Christopher Di Bella e4dd614ae8 [libcxx] cleans up __cpp_concepts mess
libc++ was previously a bit confused by what the value of __cpp_concepts
should be. Also replaces `__floating_point` with `floating_point` now
that it exists.

Differential Revision: https://reviews.llvm.org/D97015
2021-02-26 18:43:40 +00:00
Louis Dionne 27f9ed7850 [libc++] Make the from-scratch config work on macOS out-of-the-box 2021-02-26 13:11:49 -05:00
Louis Dionne f8e810c359 [libc++] Allow running CI on macOS when Ninja isn't installed outside of Xcode
Xcode does bundle Ninja, so we can use that Ninja if there's no system-wide
Ninja installed. This is useful on some CI bots we have that don't come
with Ninja pre-installed.
2021-02-26 12:15:12 -05:00
Louis Dionne cb3de09503 [libc++] Remove the now unused macos-trunk and macos-backdeployment CI scripts
We use the run-buildbot script everywhere now.
2021-02-26 10:29:02 -05:00
Martin Storsjö c7d46f221e [libcxx] Use the allocating form of getcwd() on Glibc and Apple platforms
This avoids having to query pathconf for a max size for
preallocating a buffer for the return value.

This is an extension to the POSIX getcwd() spec.

Differential Revision: https://reviews.llvm.org/D97460
2021-02-26 00:14:12 +02:00
Martin Storsjö fb2e4f5401 [libcxx] [test] Add a MinGW target
This can't easily be autodetected (unless LIBCXX_TARGET_TRIPLE is
specified, or unless we query what the compiler's default target is,
which only is supported by clang), but can be chosen manually via
LIBCXX_TARGET_INFO.

This chooses mingw style lib naming, and uses -nostdlibc++ instead
of -nodefaultlib -nostdlib (as the latter requires specifying a lot of
details manually - this is done in the cmake config though).

Differential Revision: https://reviews.llvm.org/D97294
2021-02-26 00:10:48 +02:00
Martin Storsjö 72fe14d40a [libcxx] [cmake] Add asm to the runtimes build languages
This fixes building libunwind with a new enough version of cmake.

(libunwind treats its asm sources as C depending on the cmake version
on some platforms; this fixes builds when such workarounds aren't used,
when cmake treats asm correctly on its own.)

Differential Revision: https://reviews.llvm.org/D97399
2021-02-26 00:10:48 +02:00
Martin Storsjö 3be7968c36 [libcxx] [test] Ifdef out uses of create_fifo on windows
Restructure code in directory_entry.obs/file_type_obs.pass.cpp
and directory_entry.obs/hard_link_count.pass.cpp to reduce the
amount of ifdeffery needed.

In file_type_obs.pass.cpp, we can't inline the calls to
env.create_* into the lambda calls (e.g. "test_path(env.create_*())"),
because the lambda removes the referenced file, and the hardlink
must be created while the earlier test file exists.

In hard_link_count.pass.cpp, move restoration of the original
directory permissions to the end of the lambda, so that new
directory entries can be created after the lambda has run once.

Differential Revision: https://reviews.llvm.org/D89948
2021-02-26 00:10:47 +02:00
Martin Storsjö f15377084c [libcxx] [test] Use string().c_str() to convert a std::filesystem::path to a const char*
On Windows, path::value_type is wchar_t, so one can't pass the return
value of path::c_str() directly to std::remove().

This matches what was done for tests under std/input.output/filesystems
in 81db3c31aa and
3784bdf217.

Differential Revision: https://reviews.llvm.org/D97458
2021-02-26 00:10:47 +02:00
Louis Dionne 618862e89a [libc++] Fix incorrect forwarding in tuple's assignment operator
Also, add a bunch of tests for tuple and pair's assignment operators
involving reference types.

Differential Revision: https://reviews.llvm.org/D97419
2021-02-25 14:56:16 -05:00
Martin Storsjö c218c80c73 [libcxx] [test] Quote the path to the python interpreter
This should allow running tests with the interpreter in some of the
default paths where Python for Windows might be installed.

Differential Revision: https://reviews.llvm.org/D97369
2021-02-24 22:24:41 +02:00
Louis Dionne 5f5416e1c4 [libc++] NFC: Fix a few tests in tuple that would succeed trivially 2021-02-24 11:33:41 -05:00
Louis Dionne 4814985dec [libc++] NFC: Fix a few tests in pair that would succeed trivially 2021-02-24 11:25:45 -05:00
Martin Storsjö 90232b2ecd [libcxx] [test] Don't pass INCLUDE to clang via -isystem
Passing the MSVC include dirs via -isystem makes them included before
clang's own include resource dir (<prefix>/lib/clang/<version>/include).
This causes includes of stddef.h to bypass clang's stddef.h which
defines max_align_t, which libc++ needs defined.

This was added in 4372f06d0f when the
initial windows testing support was added, and has been brought along
since. It's unclear if this was needed back then - now it no longer is
needed at least, and since libc++ started depending on max_align_t, this
became an issue.

Differential Revision: https://reviews.llvm.org/D97167
2021-02-24 11:16:49 +02:00
Marek Kurdej 77bd454da3 [libc++] [docs] [C++2b] Update status page with papers adopted in February 2021 virtual meeting. 2021-02-24 09:40:33 +01:00
Martin Storsjö f97ea0d5b3 [libcxx] [test] Define _CRT_STDIO_ISO_WIDE_SPECIFIERS while building tests
This matches how libc++ itself is built. This avoids errors due to
mismatch if linking libc++ statically.

Differential Revision: https://reviews.llvm.org/D97169
2021-02-23 15:57:30 +02:00
Mark de Wever c61e511f38 [NFC][libc++] Fix _LIBCPP_HAS_BITSCAN64 usage.
Seems line was accidentally left in
llvm-svn: 290924 86eebc5b65

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D97211
2021-02-23 08:13:49 +01:00
Louis Dionne a0839b14df [libc++] Fix tuple assignment from types derived from a tuple-like
The implementation of tuple's constructors and assignment operators
currently diverges from the way the Standard specifies them, which leads
to subtle cases where the behavior is not as specified. In particular, a
class derived from a tuple-like type (e.g. pair) can't be assigned to a
tuple with corresponding members, when it should. This commit re-implements
the assignment operators (BUT NOT THE CONSTRUCTORS) in a way much closer
to the specification to get rid of this bug. Most of the tests have been
stolen from Eric's patch https://reviews.llvm.org/D27606.

As a fly-by improvement, tests for noexcept correctness have been added
to all overloads of operator=. We should tackle the same issue for the
tuple constructors in a future patch - I'm just trying to make progress
on fixing this long-standing bug.

PR17550
rdar://15837420

Differential Revision: https://reviews.llvm.org/D50106
2021-02-22 14:52:18 -05:00
Martin Storsjö 3d6ca4b8dc [libcxx] [test] Call create_directory_symlink when linking directories
This makes the symlinks work properly on windows.

A similar round of cleanup was done in
c41bda7f5f, but these tests were
added after that.

Differential Revision: https://reviews.llvm.org/D97089
2021-02-21 00:25:54 +02:00
Martin Storsjö 26005c788b [libcxx] Make path::format a non-class enum
The spec doesn't declare it as an enum class, and being declared
as an enum class breaks referring to the values as e.g.
path::auto_format.

Differential Revision: https://reviews.llvm.org/D97084
2021-02-21 00:25:54 +02:00
Mark de Wever 84dbcdd5ff [libc++] Fix the build for AppleClang.
Forgot to add some parts of D93593, this should disable the tests on
Apple. Seems Louis was right ;-)
2021-02-20 13:54:46 +01:00
Martin Storsjö 7b5f0050a9 [libcxx] [test] Remove two unnecesary files/variables in a test
These don't seem to have any function in the test.

The non_regular_file one seems to have been added in
0f8c8f59df, without any apparent
purpose there.

Differential Revision: https://reviews.llvm.org/D97083
2021-02-20 10:20:12 +02:00
Martin Storsjö 8c305a5d82 [libcxx] Rename a method in PathParser for clarity. NFC.
Differential Revision: https://reviews.llvm.org/D97081
2021-02-20 10:20:11 +02:00
Mark de Wever 1a5c92f680 [libc++] Fixes _LIBCPP_HAS_NO_CONCEPTS
Before the define was in a GCC specific part. Now it's available for all
compilers. The patch had its CI run in D93593.
2021-02-20 09:13:16 +01:00
zoecarver 6c75a84ce7 [libc++][nfc] Only test if pair is_assignable after C++03.
In C++03 libc++ uses a different set of constructors which aren't
constrained, so these tests won't work. This should fix the bots.

Refs: 82c4701.
2021-02-19 15:14:44 -08:00
Martin Storsjö 99fc4a6584 [libcxx] Enable filesystem by default for mingw targets
This feature can be built successfully for windows now. However,
the helper functions for __int128_t aren't available in MSVC
configurations, so don't enable it by default there yet. (See
https://reviews.llvm.org/D91139 for discussion on how to proceed
with things in MSVC environments.)

Differential Revision: https://reviews.llvm.org/D97075
2021-02-20 01:09:10 +02:00
zoecarver 82c4701d4e [libc++][nfc] SFINAE on pair/tuple assignment operators: LWG 2729.
This patch ensures that SFINAE is used to delete assignment operators in pair and tuple based on issue 2729.

Differential Review: https://reviews.llvm.org/D62454
2021-02-19 13:25:34 -08:00
Martin Storsjö f4f5fb9151 [libcxx] Make generic_*string return paths with forward slashes on windows
This matches what MS STL returns; in std::filesystem, forward slashes
are considered generic dir separators that are valid on all platforms.

Differential Revision: https://reviews.llvm.org/D91181
2021-02-19 21:49:51 +02:00
zoecarver dbc89028d7 [libcxx] Fix LWG 2875: shared_ptr::shared_ptr(Y*, D, […]) constructors should be constrained.
Fixes LWG issue 2875.

Differential Revision: https://reviews.llvm.org/D81414
2021-02-19 11:11:39 -08:00
Martin Storsjö 513463fd26 [libcxx] Have lexically_normal return the path with preferred separators
Differential Revision: https://reviews.llvm.org/D91179
2021-02-19 21:06:54 +02:00
Marek Kurdej bcb5a124ae [libc++] Turn off clang-format for auto-generated version header. NFC. 2021-02-19 17:26:16 +01:00
zoecarver 6a328c66d3 [libc++] shared_ptr deleter requirements (LWG 2802).
This patch implements 2802. Requires _Deleter to have call operator and be move constructible. Based on D62233.

Refs PR37637.

Differential Revision: https://reviews.llvm.org/D62274
2021-02-18 21:31:07 -08:00
zoecarver 82b82b9430 Mark 2534 as Complete.
c90dee1 fixed LWG 1203 which supresses LWG 2534 as well.

Refs D62889.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96885
2021-02-18 21:28:49 -08:00
Christopher Di Bella 9f4f6ac94b [libcxx] adds concept `std::uniform_random_bit_generator`
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/D96577
2021-02-19 01:47:29 +00:00
Joerg Sonnenberger a77e918016 libcxx: use early returns
Differential Revision: https://reviews.llvm.org/D96955
2021-02-18 19:43:14 +01:00
Nico Weber 9d36f70ef2 libcxx: fix a documentation typo
See `grep 'option.LIBCXX_INCLUDE_TESTS' libcxx/CMakeLists.txt`.
2021-02-18 11:59:51 -05:00
Zbigniew Sarbinowski 25aa0d1244 [SystemZ][ZOS] Guard using declaration for ::fchmodat
The use of fchmodat() is beeing guarded but its using declaration is not. Let's use the same guard in both places to avoid compiler errors on platforms where `fchmodat` does not exist.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D96303
2021-02-18 15:01:04 +00:00
Martin Storsjö 78d693faec [libcxx] Implement append and operator/ properly for windows
The root_path function has to be changed to return the parsed bit
as-is; otherwise a path like "//net" gets a root path of "//net/", as
the root name, "//net", gets the root directory (an empty string) appended,
forming "//net/". (The same doesn't happen for the root dir "c:" though.)

Differential Revision: https://reviews.llvm.org/D91178
2021-02-18 09:03:53 +02:00
Martin Storsjö 8a783e6845 [libcxx] Implement is_absolute properly for windows
Differential Revision: https://reviews.llvm.org/D91177
2021-02-17 19:33:05 +02:00
Louis Dionne 642048eea0 [libc++] Allow retries in a few more flaky tests 2021-02-17 11:20:40 -05:00
Martin Storsjö 929f0bcc24 [libcxx] Implement parsing of root_name for paths on windows
Differential Revision: https://reviews.llvm.org/D91176
2021-02-17 15:45:31 +02:00
Zbigniew Sarbinowski 5f9be2c3e3 [SystemZ][ZOS] Prefer -nostdlib++ as opposed to -nodefaultlibs when building c++ libraries
Let's use -nostdlib++ rather than -nodefaultlibs when building libc++/libc++abi/libunwind libraries. The default is -nostdlib++ if supported by a build compiler like it is the case with clang, otherwise -nodefaultlibs is used as before.

This change is needed to avoid additional changes at the link step and not to increase the maintenance costs. If clang with -nodefaultlibs is used all the libraries which are removed but required would have to be manually added in. This set of libraries are unique and will send out.

The propose change will allow to make the link step simple for other platforms as well.

Reviewed By: #libc, #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D95875
2021-02-16 18:42:14 +00:00
Colin Finck 0f5020af7f [libc++] Build thread_win32.cpp only if LIBCXX_HAS_PTHREAD_API is not set
This allows building libc++ against winpthreads from mingw-w64 to support
operating systems older than Windows 7. The remaining libc++ code already
supports `WIN32` with `LIBCXX_HAS_PTHREAD_API`.

Note that there is also the older "pthreads-win32". However, that support
library implements `pthread_t` as a struct, which violates the libc++
assumption that `pthread_t` is always a scalar and can be compared,
ordered, and set to zero.

Differential Revision: https://reviews.llvm.org/D96339
2021-02-16 10:03:42 -05:00
Arthur O'Dwyer 5f58374bbe [libc++] Change `std::numeric_limits` to just `numeric_limits` in <chrono>.
The namespace is unnecessary, and libc++ style is not to include it on type names.
(As opposed to function names, where qualification affects ADL; and in certain
function signatures where `std::` and `_VSTD::` might be mangled differently.
This is none of those situations.)
2021-02-15 16:12:10 -05:00
Louis Dionne 5d0d465ad4 [libc++] Mark __cpp_lib_constexpr_memory as being implemented 2021-02-15 15:26:53 -05:00
Dimitry Andric 328261019f Define new/delete in libc++ when using libcxxrt
Always turn on LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS, if libcxxrt is used
as the C++ ABI library, since libcxxrt does not provide the full set
ofnew and delete operators. In particular, the aligned versions of these
operators are completely missing. This primarily addresses builds on
FreeBSD, as this platform uses libcxxrt by default.

Also, attempt to provide a FreeBSD.cmake cache file, with hopefully sane
settings, partially copied from the Apple.cmake cache file. This needs
more work, probably some additions to ci build scripts (although I am
not aware of any 'official' FreeBSD build bots).

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96720
2021-02-15 21:22:12 +01:00
Zbigniew Sarbinowski 48fcce1aea [SystemZ][ZOS] Fix __libcpp_thrad_isnull()
Previous pthread revision https://reviews.llvm.org/D91875 missed a small change for `__libcpp_thrad_isnull()` required for z/OS.

Reviewed By: zibi

Differential Revision: https://reviews.llvm.org/D96302
2021-02-12 20:21:11 +00:00
Zbigniew Sarbinowski cb2d2ae56a [SystemZ][ZOS] Provide CLOCK_MONOTONIC alternative
We need CLOCK_MONOTONIC equivalent implementation for z/OS within libc++. The default implementation is asserting.

On z/OS the lack of  'clock_gettime()' and 'time_point()' force us to look for alternatives.
The current proposal is to use `gettimeofday()` for CLOCK_MONOTONIC  which is also used in CLOCK_REALTIME.  This will allow us to skip the assertion with compromised CLOCK_MONOTONIC implementation which will not guarantee to never go back in time because it will use `gettimeofday()` but only when it's set.

Is this a good compromise for platforms which does not support monotonic clock?
Hopefully this will spark the discussion and agreement how to proceed in this situation.

Reviewed By: #libc, ldionne, hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D93542
2021-02-12 18:39:48 +00:00
Mark de Wever f8772da8cc [libc++][format] Enable format_error on older compilers.
It seems like modifying the header doesn't cause libc++ to be rebuild.
So the breakage of the previous commit didn't happen on my system.

This should fix the build of https://buildkite.com/mlir/mlir-core
2021-02-11 19:11:20 +01:00
Mark de Wever af83e89ae3 [libc++][format] Improve Add basic_format_parse_context.
Add an additional guard to prevent building on older clang versions.

This should fix the build of https://buildkite.com/mlir/mlir-core
2021-02-11 18:55:54 +01:00
Mark de Wever 38ddeade65 [libc++][format] Add basic_format_parse_context.
Implements parts of:
- P0645 Text Formatting

Depends on D92214

Reland with changes:
The format header will only be compiled if the compiler used has support
for concepts. This should fix the issues with the initial version.

Differential Revision: https://reviews.llvm.org/D93166
2021-02-11 17:57:54 +01:00
Ilya Tokar c81d52997a [libc++] Use builtins in more math.h functions.
Not using builtins doesn't always imply worse code,
but for e. g. isinf, this is 30%+ faster.

Before:
name        time/op
BM_isinf     2.14ns ± 2%

After:
name        time/op
BM_isinf     1.33ns ± 2%

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D88854
2021-02-10 15:17:42 -05:00
Christopher Di Bella 17db24a7a8 [libcxx] adds concepts `std::invocable` and `std::regular_invocable`
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/D96235
2021-02-10 19:35:53 +00:00
Christopher Di Bella c63de225fd [libcxx] adds concept std::derived_from
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D74292
2021-02-10 19:30:08 +00:00
Christopher Di Bella bee7b07f23 [libcxx] adds [concepts.arithmetic]
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/D88131
2021-02-10 19:04:57 +00:00
Louis Dionne 183b75f667 [libc++] Remove c++98 Lit features in the test suite
We don't populate a Lit feature named c++98 since 31cbe0f240.
2021-02-10 13:32:41 -05:00
Christopher Di Bella 2193e8be3e [libcxx] adds concept `std::copy_constructible`
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96230

Differential Revision: https://reviews.llvm.org/D96232
2021-02-10 17:56:42 +00:00
Christopher Di Bella 2b2f36a8b1 [libcxx] adds concept `std::move_constructible`
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D77961

Differential Revision: https://reviews.llvm.org/D96230
2021-02-10 17:33:35 +00:00
Colin Finck ebfadd82cb [libc++] Fix copy-paste mistake in __threading_support
Differential Revision: https://reviews.llvm.org/D96115
2021-02-10 11:00:32 -05:00
Christopher Di Bella 8caf835337 [libcxx] adds concept `std::convertible_to`
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/D77961
2021-02-10 03:27:41 +00:00
Arthur O'Dwyer eec04092d6 [libc++] [LWG2993] reference_wrapper<T> conversion from U&&
Implement the resolution of LWG2993. Replace a deleted constructor
with a constructor that SFINAEs away in appropriate circumstances.
Also, now that the constructor is templated, we must have an
explicit deduction guide to make CTAD work.

Some tests have been merged in from Agustín Bergé's D40259.

Differential Revision: https://reviews.llvm.org/D92725
2021-02-09 15:50:25 -05:00
zoecarver dea74b2820 [libc++] Add `noexcept` to `string::find` and similar members.
Adds `noexcept` to `string_view`/`string::find` and similar members
(`rfind`, etc.). See discussion in D95251. Refs D95821.

Reviewed By: curdeius, ldionne

Differential Revision: https://reviews.llvm.org/D95848
2021-02-09 11:47:40 -08:00
Mark de Wever 171956aab3 Revert "[libc++] Require C++20 to build the benchmarks."
There are build bots without C++20 support building the benchmarks.

This reverts commit 34acc91642.
2021-02-09 19:59:34 +01:00
Mark de Wever 34acc91642 [libc++] Require C++20 to build the benchmarks.
Some work-in-progress patches for the format header contain benchmarks.
The format header requires C++20 to build. This is a preparation to make
it easy to add these benchmarks.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96057
2021-02-09 18:34:07 +01:00
Mark de Wever 2544060e71 [libc++] Remove C++11 work-arounds in src.
Building libcxx requires at least C++17 so remove the old work-arounds.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96200
2021-02-09 18:31:00 +01:00
Louis Dionne 73aa09704a [libc++] Add a wait step in the BuildKite pipeline to shield macOS builders
We don't have many of those and they are rather slow, so we'd rather not run
those jobs if we know other jobs in the pipeline failed anyway.
2021-02-08 10:14:16 -05:00
Sterling Augustine a34b8b879e Various minor fixes for python 3
Switch StdTuple printer from python 2-style "next" to python 3.

Nested iteration changed enough to make the original bitset iteration
code a bit trickier than it needs to be, so unnest.

The end node of a map iterator is sometimes hard to detect in isolation,
don't fail in that case.

Differential Revision: https://reviews.llvm.org/D96167
2021-02-05 13:01:34 -08:00
Martin Storsjö d4f4e723d0 [libcxx] Implement temp_directory_path using GetTempPath on windows
This does roughly the same as the manual implementation, but checks
a slightly different set of environment variables and has a more
appropriate fallback if no environment variables are available
(/tmp isn't a very useful fallback on windows).

Differential Revision: https://reviews.llvm.org/D91175
2021-02-05 22:47:33 +02:00
Martin Storsjö 4d292d531b [libcxx] Use the posix code for directory_entry::__do_refresh
This works just fine for windows, as all the functions it calls
are implemented and wrapped for windows.

Differential Revision: https://reviews.llvm.org/D91173
2021-02-05 22:47:33 +02:00
Arthur O'Dwyer 85167fb7c2 [libc++] Further improve the contiguous-iterator story, and fix some bugs.
- Quality-of-implementation: Avoid calling __unwrap_iter in constexpr contexts.
    The user might conceivably write a contiguous iterator where normal iterator
    arithmetic is constexpr-friendly but `std::to_address(it)` isn't.

- Bugfix: When you pass contiguous iterators to `std::copy`, you should get
    back your contiguous iterator type, not a raw pointer. That means that
    libc++ can't `__unwrap_iter` unless it also does `__rewrap_iter`.
    Fortunately, this is implementable.

- Improve test coverage of the new `contiguous_iterator` test iterator.
    This catches the bug described above.

- Tests: Stop testing that we can `std::copy` //into// an `input_iterator`.
    Our test iterators may currently support that, but it seems nonsensical to me.

Differential Revision: https://reviews.llvm.org/D95983
2021-02-05 15:18:04 -05:00
zoecarver fab194898b [lic++][docs] Explain noexcept policy for narrow contracts.
Adds documentation around libc++'s policy to add noexcept to things that cannot throw but aren't marked as noexcept.

Refs LWG 3518 and D95251.

Differential Revision: https://reviews.llvm.org/D95821
2021-02-05 11:27:19 -08:00
Arthur O'Dwyer 5d9565634c Revert "Revert "[libc++] [P0879] constexpr std::nth_element, and rewrite its tests.""
This reverts commit b6ffece320.

The bug is now fixed (it was a stupid cut-and-paste kind of error),
and the regression test added. The new patch is also simpler than the old one!

Differential Revision: https://reviews.llvm.org/D96084
2021-02-05 12:02:43 -05:00
Jordan Rupprecht b6ffece320 Revert "[libc++] [P0879] constexpr std::nth_element, and rewrite its tests."
This reverts commit 207d4be4d9 due to returning incorrect results. Regression test case posted in D96074.
2021-02-04 14:03:49 -08:00
Marek Kurdej 1361c5e7d7 [libc++] Add format check to CI
Note: contrary to what I said previously, I didn't change .clang-format nor utils/generate_feature_test_macro_components.py script.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92229
2021-02-04 21:15:37 +01:00
Louis Dionne 1700ea7302 [libc++] Remove the ability to use braced-init for filesystem paths
According to my reading of http://eel.is/c++draft/filesystems#fs.class.path,
the Standard doesn't actually mention that this should work. Since other
implementations don't allow it, allowing it in libc++ is just setting a
portability trap.

Supersedes https://reviews.llvm.org/D89865.

Differential Revision: https://reviews.llvm.org/D95975
2021-02-04 11:49:00 -05:00
Louis Dionne 76fc35752d [libc++] Make feature-test macros consistent with availability macros
Before this patch, feature-test macros didn't take special availability
markup into account, which means that feature-test macros can sometimes
appear to "lie". For example, if you compile in C++20 mode and target
macOS 10.13, the __cpp_lib_filesystem feature-test macro will be provided
even though the <filesystem> declarations are marked as unavailable.
This patch fixes that.

rdar://68142369

Differential Revision: https://reviews.llvm.org/D94983
2021-02-04 11:40:22 -05:00
Louis Dionne 85b9c5ccc1 [libc++] Fix libcxx build on 32bit architectures with 64bit time_t defaults e.g. riscv32
Patch by Khem Raj.

Differential Revision: https://reviews.llvm.org/D85095
2021-02-04 11:38:54 -05:00
Mark de Wever e275e62983 [libc++] Adds a make_string test helper function.
These function makes it easier to write generic unit tests for the
format header. It solves the issue where it's not possible to use
  `templated_prefix"foo"`
where `templated_prefix` resolves to: nothing, `L`, `u8`, `u`,
or `U`. The templated_prefix would be more faster during execution.

Reviewed By: ldionne, #libc, curdeius

Differential Revision: https://reviews.llvm.org/D93414
2021-02-04 17:16:44 +01:00
Louis Dionne b51756819a [libc++] Rename include/support to include/__support
We do ship those headers, so the directory name should not be something
that can potentially conflict with user-defined directories.

Differential Revision: https://reviews.llvm.org/D95956
2021-02-04 10:16:33 -05:00
Arthur O'Dwyer 493f140792 [libc++] [P0879] constexpr std::sort
This completes libc++'s implementation of
P0879 "Constexpr for swap and swap related functions."
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0879r0.html

For the feature-macro adjustment, see
https://cplusplus.github.io/LWG/issue3256

Differential Revision: https://reviews.llvm.org/D93661
2021-02-03 18:57:05 -05:00