Commit Graph

6638 Commits

Author SHA1 Message Date
Louis Dionne c90dee1e90 [libc++] Re-apply fdc41e11f (LWG1203) without breaking the C++11 build
fdc41e11f was reverted in e46c1def5 because it broke the C++11 build.
We shouldn't be using enable_if_t in C++11, instead we must use
enable_if<...>::type.
2020-09-23 08:56:00 -04:00
Raphael Isemann e46c1def52 Revert "[libc++] Implement LWG1203"
This reverts commit fdc41e11f9. It causes the
libcxx/modules/stds_include.sh.cpp test to fail with:
libcxx/include/ostream:1039:45: error: no template named 'enable_if_t'; did you mean 'enable_if'?
template <class _Stream, class _Tp, class = enable_if_t<

Still investigating what's causing this and reverting in the meantime to get
the bots green again.
2020-09-23 10:13:38 +02:00
Louis Dionne 7656dd33d9 [libc++] NFC: Reindent the feature test macro generation script
Each feature-test macro is now a clear block indentation-wise.
2020-09-22 17:40:14 -04:00
Louis Dionne 2404ed0202 [libc++] NFC: Collocate C++20 removed members of std::allocator 2020-09-22 17:40:14 -04:00
Louis Dionne fdc41e11f9 [libc++] Implement LWG1203
Libc++ had an issue where nonsensical code like

  decltype(std::stringstream{} << std::vector<int>{});

would compile, as long as you kept the expression inside decltype in
an unevaluated operand. This turned out to be that we didn't implement
LWG1203, which clarifies what we should do in that case.

rdar://58769296
2020-09-22 17:15:31 -04:00
Louis Dionne 0724f8bf47 [libc++] Implement C++20's P0784 (More constexpr containers)
This commit adds std::construct_at, and marks various members of
std::allocator_traits and std::allocator as constexpr. It also adds
tests and turns the existing tests into hybrid constexpr/runtime tests.

Thanks to Richard Smith for initial work on this, and to Michael Park
for D69803, D69132 and D69134, which are superseded by this patch.

Differential Revision: https://reviews.llvm.org/D68364
2020-09-22 11:20:33 -04:00
Louis Dionne 0451ed9619 [libc++] NFC: Remove trailing whitespace from the feature test macro table 2020-09-22 08:45:48 -04:00
Louis Dionne ac65e3d2ce [libc++] Fix copy/paste error that broke a test 2020-09-21 20:29:54 -04:00
Louis Dionne bb09ef9598 [libc++] Fix failures when running the test suite without RTTI 2020-09-21 20:17:24 -04:00
Louis Dionne 43270c65cf [libc++] Verify base substitutions earlier in the testing format
This allows diagnosing missing substitution issues even when doing
availability feature detection in the DSL.
2020-09-21 15:30:29 -04:00
Mark de Wever d4dd961300 Fixes complexity of map insert_or_assign with a hint.
Mitsuru Kariya reported the map operations insert_or_assign with a hint
violates the complexity requirement. The function no longer uses a lower_bound,
which caused the wrong complexity.

Fixes PR38722: [C++17] std::map::insert_or_assign w/ hint violate complexity requirements

Differential Revision: https://reviews.llvm.org/D62779
2020-09-19 16:28:55 +02:00
Louis Dionne a3c28ccd49 [libc++] Remove some workarounds for missing variadic templates
We don't support GCC in C++03 mode, and Clang provides variadic templates
even in C++03 mode. So there's effectively no supported compiler that
doesn't support variadic templates.

This effectively gets rid of all uses of _LIBCPP_HAS_NO_VARIADICS, but
some workarounds for the lack of variadics remain.
2020-09-17 11:05:39 -04:00
ogiroux 5b205ff474 Commenting out atomics with padding to unbreak MSAN tests 2020-09-16 16:12:10 -07:00
Louis Dionne 39faf42816 [libc++] Ensure streams are initialized early
When statically linking libc++ on some systems, the streams are not
initialized early enough, which causes all kinds of issues. This was
reported e.g. in http://llvm.org/PR28954, but also in various open
source projects that use libc++.

Fixes http://llvm.org/PR28954.

Differential Revision: https://reviews.llvm.org/D31413
2020-09-16 13:19:16 -04:00
Louis Dionne 583c8ce30c [libc++] Fix broken test for std::any and allocators
The test was not allocating the right number of bytes. This is my fault,
not Marshall's, as I was the one to write the tests for 39c8795141.
2020-09-15 15:01:52 -04:00
Louis Dionne d9c9a74d0d [libc++] Add missing friend keyword
Otherwise, we're declaring a non-static member function, and that
gives errors in C++11 because of the change of semantics between
C++11 and C++14 for non-const constexpr member functions.

This was always intended to be a friend declaration.
2020-09-15 14:21:05 -04:00
Mark de Wever 74a9c6d7e1 [libc++] Add a benchmark for std::map operations
Before tackling http://llvm.org/PR38722, make sure there is a baseline
benchmark.

Differential Revision: https://reviews.llvm.org/D62778
2020-09-15 12:09:29 -04:00
Marshall Clow 39c8795141 [libc++] Use allocator_traits to consistently allocate/deallocate/construct/destroy objects in std::any
https://llvm.org/PR45099 notes (correctly) that we're inconsistent in memory
allocation in `std::any`. We allocate memory with `std::allocator<T>::allocate`,
construct with placement new, destroy by calling the destructor directly, and
deallocate by calling `delete`. Most of those are customizable by the user,
but in different ways.

The standard is silent on how these things are to be accomplished.
This patch makes it so we use `allocator_traits<allocator<T>>` for all
of these operations (allocate, construct, destruct, deallocate).
This is, at least, consistent.

Fixes https://llvm.org/PR45099.

Differential Revision: https://reviews.llvm.org/D81133
2020-09-15 11:04:59 -04:00
Oliver Stannard 2744c2e295 [libcxx] Disable failing test for no-exceptions build
This test tries to create a 2 GiB std::string, catching the bad_alloc
exception if the allocation fails. However, for no-exceptions builds
there is no way for the error to be reported, so this crashes with a
null pointer dereference.

Differential revision: https://reviews.llvm.org/D87682
2020-09-15 14:28:32 +01:00
zoecarver 3ed89b51da [Take 2] [libc++] Make rotate a constexpr.
This patch makes `std::rotate` a constexpr. In doing so, this patch also
updates the internal `__move` and `__move_backward` funtions to be
constexpr.

This patch was previously reverted in ed653184ac because it was missing
some UNSUPPORTED markup for older compilers. This commit adds it.

Differential Revision: https://reviews.llvm.org/D65721
2020-09-14 18:14:46 -04:00
zoecarver ed653184ac Revert "[libc++] Make rotate a constexpr."
This reverts commit 1ec02efee9.
2020-09-14 14:53:17 -07:00
Louis Dionne b3445c839f [libc++][test] Portability fix of std::strstreambuf constructor test
The standard does not require the constructor `strstreambuf(streamsize alsize_arg = 0)`
leave the stream array unallocated when called with parameter `alsize_arg > 0`.
Conformant implementations of this constructor may allocate minimal `alsize_arg`
number of bytes forcing `str()` method to return non-null pointer.

Thanks to Andrey Maksimov for the patch.

Differential Revision: https://reviews.llvm.org/D72465
2020-09-14 17:09:09 -04:00
Nicholas-Baron b552a30283 [libc++] Finish implementing P0202R3
cppreference lists the support for this paper as partial.
I found 4 functions which the paper marks as `constexpr`,
but did not use the appropriate macro.

Differential Revision: https://reviews.llvm.org/D84275
2020-09-14 16:58:49 -04:00
zoecarver 1ec02efee9 [libc++] Make rotate a constexpr.
This patch makes `std::rotate` a constexpr. In doing so, this patch also
updates the internal `__move` and `__move_backward` funtions to be
constexpr.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D65721
2020-09-14 13:56:48 -07:00
Louis Dionne becf155275 [libc++] Add comment in atomic test to explain why part of it is disabled on Apple 2020-09-14 16:13:25 -04:00
Louis Dionne f06090243d [libc++] Use LLVM 11 instead of trunk on build bots
Somehow the snapshot of LLVM trunk we use was seeing failures.
2020-09-14 15:12:13 -04:00
Louis Dionne 7235326fb2 [libc++] Upgrade the Clang on build bots 2020-09-14 13:52:01 -04:00
Louis Dionne 71a16e40f7 [libcxx] ostream{,buf}_iterator::difference_type changes in C++20
In C++20, since P0896R4, std::ostream_iterator and std::ostreambuf_iterator
must have std::ptrdiff_t instead of void as a difference_type.

Tests by Casey Carter (thanks!).

Differential Revision: https://reviews.llvm.org/D87459
2020-09-14 11:08:09 -04:00
Olivier Giroux 59fc867790 Re-split integral & pointer overloads. Add tests. 2020-09-11 12:13:35 -07:00
Louis Dionne f980ed4184 [libcxx] Remove the 'availability' Lit feature
Instead, use with_system_cxx_lib with various compile-only tests to ensure
that we're getting compile-time errors, as expected. This follows the
lead of ec46cfefe8.
2020-09-11 11:34:49 -04:00
Louis Dionne 4d12d6149c [libc++] NFC: Add missing license to test 2020-09-11 10:15:27 -04:00
Mikhail Maltsev 6af8758ba4 [libcxx] Handle target triples with dashes in platform name
Target triples may contain a dash in the platform name (e.g.
"aarch64-arm-none-eabi"). Account for it when splitting the triple
into components.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D87508
2020-09-11 14:42:05 +01:00
Louis Dionne b0ae5332dc [libcxx] Make sure we pass -isysroot when linking AND when compiling 2020-09-10 12:24:11 -04:00
Louis Dionne ec46cfefe8 [libcxx] Simplify back-deployment testing
The needs of back-deployment testing currently require two different
ways of running the test suite: one based on the deployment target,
and one based on the target triple. Since the triple includes all the
information we need, it's better to have just one way of doing things.

Furthermore, `--param platform=XXX` is also supersedded by using the
target triple. Previously, this parameter would serve the purpose of
controling XFAILs for availability markup errors, however it is possible
to achieve the same thing by using with_system_cxx_lib only and using
.verify.cpp tests instead, as explained in the documentation changes.

The motivation for this change is twofold:
1. This part of the Lit config has always been really confusing and
   complicated, and it has been a source of bugs in the past. I have
   simplified it iteratively in the past, but the complexity is still
   there.
2. The deployment-target detection started failing in weird ways in
   recent Clangs, breaking our CI. Instead of band-aid patching the
   issue, I decided to remove the complexity altogether by using target
   triples even on Apple platforms.

A follow-up to this commit will bring the test suite in line with
the recommended way of handling availability markup tests.
2020-09-10 08:17:26 -04:00
Olivier Giroux 11352fa83b Revert a test using padding bits in atomics 2020-09-09 12:14:53 -07:00
Eric Fiselier 1301febe71 [libc++] Fix variant benchmark build for some configurations.
The benchmarks expect to be built in C++17 or newer, but this
isn't always how CMake configures the C++ dialect. Instead
we need to explicitly set the CXX_STANDARD target property.
2020-09-09 14:25:17 -04:00
Olivier Giroux fc4bff0cd3 Update atomic feature macros, synopsis, signatures to match C++20. Improve test coverage for non-lock-free atomics. 2020-09-09 10:00:09 -07:00
Louis Dionne c2f6a00128 [libc++] Allow overriding the cached value of LIBCXX_TEST_CONFIG 2020-09-08 11:29:32 -04:00
Louis Dionne 6454140ab3 [libc++] Make sure we always print all available features
Previously, we'd only print the features added through the new config,
however printing all the features is important for debugging purposes.
2020-09-08 11:18:02 -04:00
Raul Tambre 86bd8f82cc [CMake] Remove dead FindPythonInterp code
LLVM has bumped the minimum required CMake version to 3.13.4, so this has become dead code.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D87189
2020-09-08 15:23:23 +03:00
Louis Dionne d0706cfc4c [libc++] Mark std::atomic<_ExtInt> test as unsupported in C++03 2020-09-03 13:28:21 -04:00
John Brawn db574fc7ba [libc++] Make ext-int.verify.cpp test compatible with c++03
Currently the libcxx/atomics/ext-int.verify.cpp test fails when run with
-std=c++03 because there's an extra error due to using list initialization. Fix
this by using parentheses instead.
2020-09-03 18:18:19 +01:00
Louis Dionne 5571467879 [libc++] Avoid including <sys/cdefs.h> on non-Apple platforms in <ctime> 2020-09-02 18:11:26 -04:00
Michael Schellenberger Costa afe8ca8673 [libcxx] Fix whitespace error 2020-09-02 21:44:15 +02:00
Michael Schellenberger Costa 737a4501e8 Add constexpr to pair
Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D80558
2020-09-02 21:21:24 +02:00
Louis Dionne 4f57a126c4 [libc++] Remove definition of _LIBCPP_ALIGNOF for GCC in C++03 mode
That definition is known to be potentially incorrect, and we don't support
GCC in C++03 mode anyway.
2020-09-02 12:29:42 -04:00
hyd-dev 44cc78da05 [libc++] Fix incorrect usage of __STDC_HOSTED__
D56913 introduced the _LIBCPP_FREESTANDING macro and guarded its
definition by:

	#ifndef __STDC_HOSTED__
	#  define _LIBCPP_FREESTANDING
	#endif

However, __STDC_HOSTED__ is defined as 0 in freestanding implementations
instead of undefined, which means that _LIBCPP_FREESTANDING would never
get defined. This patch corrects the above as:

	#if __STDC_HOSTED__ == 0
	#  define _LIBCPP_FREESTANDING
	#endif

Differential Revision: https://reviews.llvm.org/D86055
2020-09-02 12:26:37 -04:00
Louis Dionne 5201b962e8 [libc++] Re-apply the workaround for timespec_get not always being available in Apple SDKs
This commit re-applies 99f3b231cb, which was reverted in 8142425727
because it broke the modules build. The modules failure was a circular
dependency between the Darwin module and __config. Specifically, the
issue was that if <__config> includes a system header, the std_config
module depends on the Darwin module. However, the Darwin module already
depends on the std_config header because some of its headers include
libc++ headers like <ctype.h> (they mean to include the C <ctype.h>,
but libc++ headers are first in the header search path).

This is fixed by moving the workaround to <ctime> only.

https://llvm.org/PR47208
rdar://68157284
2020-09-02 12:20:32 -04:00
Louis Dionne 255a60cdd6 [libc++] Make some testing utilities constexpr
This will be needed in order to test constexpr std::vector.
2020-09-02 10:05:44 -04:00
Raphael Isemann 8142425727 Revert "[libc++] Workaround timespec_get not always being available in Apple SDKs"
This reverts commit 99f3b231cb. It breaks
libcxx/modules/stds_include.sh.cpp on macOS as the new include to sys/cdefs.h
causes a dependency from __config to the Darwin module (which already has
a dependency on __config). This cyclic dependency breaks compiling the std
module which breaks compiling pretty much every program with ToT libc++ and
enabled modules.

I'll revert for now to get the bots green again. Sorry for the inconvenience.
2020-09-02 09:45:35 +02:00