Commit Graph

616 Commits

Author SHA1 Message Date
Casey Carter
8b55cce1c8 [test] Workaround C1XX bug in uses_allocator_types.hpp
VSO#109062 "Explicit template argument specification with empty template parameter pack expansion does not imply further empty pack expansion"

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@303888 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-25 17:42:17 +00:00
Erik Pilkington
a3e0bf4396 Add support for shared_ptr<FunctionType>
Fixes PR27566.

Differential revision: https://reviews.llvm.org/D30837

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@303874 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-25 15:43:31 +00:00
Marshall Clow
6d52b3b76c Add some constexpr tests for optional's move/copy ctor
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@303824 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-25 00:22:33 +00:00
Marshall Clow
6a5647485a Mark the copy constructor and move
constructor to be constexpr. This only works when the contained type has a constexpr copy/move ctor.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@303268 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-17 15:30:01 +00:00
Eric Fiselier
e250cc68ce Cleanup test issues reported by STL @ Microsoft.
This patch cleans up a number of issues reported by STL, including:

1) Fix duplicate is_convertible test.
2) Move non-standard reference_wrapper tests under test/libcxx
3) Fix assumption that sizeof(wchar_t) == 32 in the codecvt and
   wstring_convert tests.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302870 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-12 03:38:28 +00:00
Eric Fiselier
2d31e197db Fix or move tests with non-standard assumptions
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302862 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-12 01:44:51 +00:00
Marshall Clow
83c266a94f Mark LWG#2782 as complete. No functionality change; we already do this. Just added a few more tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302802 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-11 14:25:45 +00:00
Marshall Clow
4cbf03ea88 Mark LWG#2850 as complete. No functionality change; we had tests that covered it already. Just added comments to the tests. Thanks to K-ballo for the heads up.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302799 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-11 13:55:20 +00:00
Marshall Clow
8fdd8117a9 Mark LWG#2796 as complete. No functionality change; we had tests that covered it already. Just added comments to the tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302798 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-11 13:51:09 +00:00
Michael Park
f318b708ef Fix std::visit for the zero variants case.
Summary:
The following code is broken:

```
    std::visit([]{});
```

Reviewers: EricWF

Reviewed By: EricWF

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302773 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-11 07:17:12 +00:00
Eric Fiselier
ab2f54f103 Remove usages of _LIBCPP_MSVC which is never defined
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302736 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10 21:40:58 +00:00
Eric Fiselier
76515a2dcf Implement LWG 2591 - Patch from K-Ballo
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302724 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10 20:37:43 +00:00
Eric Fiselier
19fc985cce XFAIL is_trivially_copyable test for compilers that don't implement Core 2094
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302723 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10 20:19:35 +00:00
Eric Fiselier
74424d09b4 Fix enable_shared_from_this test in C++11
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302721 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10 20:09:20 +00:00
Billy Robert O'Neal III
b423f1e860 Update is_trivially_copyable tests with CWG 2094
Clang 5.0 implements these changes here: 87cd035326
MSVC++ will implement these changes in the first toolset update to 2017.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302710 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10 19:43:31 +00:00
Eric Fiselier
1bc7a4b31e [libc++] Fix PR32979 - types with a private std::enable_shared_from_this base break shared_ptr
Summary:
This patch fixes bugs.llvm.org/PR32979.

[util.smartptr.shared.const] says:
> In the constructor definitions below, enables shared_from_this with p, for a pointer p of type Y*, means
> that if Y has an unambiguous and accessible base class that is a specialization of enable_shared_from_-
> this.

This means that libc++ needs to respect the access specifier of the base class, and not attempt to construct
and enabled_shared_from_this base if it is private. However access specifiers don't affect overload resolution
so our current implementation will attempt to construct the private base. 

This patch uses SFINAE to correctly detect if the shared_ptr input has an accessible enable_shared_from_this
base class.

Reviewers: mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302709 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10 19:35:49 +00:00
Eric Fiselier
4bd682bf5d Fix two test failures caused by Windows mangling of function types.
On Windows the function template `template <class T> void test()` has
the same mangled name when instantiated with the distinct types `void()`
and `void() noexcept`. When this occurs Clang emits an error. This error
was causing two type-traits tests to fail.

However this can be worked around by using class templates instead of
function templates, which is what this patch does to fix the errors.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302380 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-07 21:15:28 +00:00
Stephan T. Lavavej
5dbf234992 [libcxx] [test] Suppress MSVC's /analyze warning C6294 in a more fine-grained manner.
Fixes D32926.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302325 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 23:51:39 +00:00
Mehdi Amini
907c1196a7 Add markup for libc++ dylib availability
Libc++ is used as a system library on macOS and iOS (amongst others). In order
for users to be able to compile a binary that is intended to be deployed to an
older version of the platform, clang provides the
availability attribute <https://clang.llvm.org/docs/AttributeReference.html#availability>_
that can be placed on declarations to describe the lifecycle of a symbol in the
library.

See docs/DesignDocs/AvailabilityMarkup.rst for more information.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302172 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 17:08:54 +00:00
Casey Carter
d252306885 [test] variant: enable constexpr construction tests on MSVC STL
* Add a new macro _MSVC_STL_VER to detect when the MSVC STL is being tested
* Workaround C1XX __is_trivially_copyable bug

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302158 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 15:32:54 +00:00
Stephan T. Lavavej
559442652c [libcxx] [test] Strip trailing whitespace. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302105 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 01:43:58 +00:00
Casey Carter
fba865a217 Expand test coverage for LWG2857
* Cover optional's emplace-from-initializer_list overload

* Verify that any::emplace and optional::emplace return a reference to the correct type even for throwing cases.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@301055 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21 22:38:59 +00:00
Eric Fiselier
d311b3c55a Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the utilities library
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300635 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19 00:56:32 +00:00
Casey Carter
21d02bea58 [test] Silence another unused-typedef warning
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300581 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 20:04:39 +00:00
Casey Carter
6f448f6943 [test] Silence unused parameter/typedef warnings
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300575 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 18:44:33 +00:00
Billy Robert O'Neal III
937aecfb3d Allow a standard library to implement conditional noexcept for optional and unique_ptr hash functions.
These tests were unconditionally asserting that optional and unique_ptr declare throwing hashes, but MSVC++ implements conditional noexcept forwarding that of the underlying hash function. As a result we were failing these tests but there's nothing forbidding strengthening noexcept in that way.

Changed the ASSERT_NOT_NOEXCEPT asserts to use types which themselves have non-noexcept hash functions.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300516 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 00:19:50 +00:00
Eric Fiselier
7e698523da Fix passing incorrectly value-category when constructing unique_ptr's deleter
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300489 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17 20:20:27 +00:00
Casey Carter
634a2b535f [optional] Update synopsis for LWG2934
(comment-only change)

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300488 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17 20:15:16 +00:00
Eric Fiselier
ffaa304088 Workaround Clang bug regarding template template parameters
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300411 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 02:47:46 +00:00
Eric Fiselier
a4fd0c9d61 Overhaul unique_ptr - Implement LWG 2801, 2905, 2520.
This patch overhauls both specializations of unique_ptr while implementing
the following LWG issues:

* LWG 2801 - This issue constrains unique_ptr's constructors when the deleter type
  is not default constructible. Additionally it adds SFINAE conditions
  to unique_ptr<T[]>::unique_ptr(Up).

* LWG 2905 - This issue reworks the unique_ptr(pointer, /* see below */ deleter)
  constructors so that they correctly SFINAE when the deleter argument cannot
  be used to construct the stored deleter.

* LWG 2520 - This issue fixes initializing unique_ptr<T[]> from nullptr.
  Libc++ had previously implemented this issue, but the suggested resolution
  still broke initialization from NULL. This patch re-works the
  unique_ptr<T[]>(Up, deleter) overloads so that they accept NULL as well
  as nullptr.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300406 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 01:51:04 +00:00
Eric Fiselier
98d9a858da Implement LWG 2857 for variant. Tests from Casey Carter @ Microsoft.
Also mark LWG 2857 as complete, since the changes to optional and
any were completed by Marshall earlier.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300403 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-15 19:32:02 +00:00
Eric Fiselier
81f58e5052 Rewrite and cleanup unique_ptr tests.
This patch almost entirely rewrites the unique_ptr tests. There are a couple
of reasons for this:

A) Most of the *.fail.cpp tests were either incorrect or could be better written
  as a *.pass.cpp test that uses <type_traits> to check if certain operations
  are valid (Ex. Using static_assert(!std::is_copy_constructible_v<T>) instead
  of writing a failure test).

B) [unique.ptr.runtime] has very poor test coverage. Many of the constructors
  and assignment operators have to tests at all. The special members that have
  tests have very few test cases and are typically way out of date.

C) The tests for [unique.ptr.single] and [unique.ptr.runtime] are largely
  duplicates of each other. This means common requirements have two different
  sets of tests in two different test files. This makes the tests harder to
  maintain than if there was a single copy.

To address (A) this patch changes almost all of the *.fail.cpp tests into
.pass.cpp tests using type traits; Allowing the *.fail.cpp tests to be removed.

The address (B) and (C) the tests for [unique.ptr.single] and [unique.ptr.runtime]
have been combined into a single directory, allowing both specializations to share
common tests. Tests specific to the single/runtime specializations are given the
suffix "*.single.pass.cpp" or "*.runtime.pass.cpp".

Finally the unique.ptr test have been moved into the correct directory according
to the standard. Specifically they have been removed from "utilities/memory" into
"utilities/smartptr".

PS. This patch also adds newly written tests for upcoming unique_ptr changes/fixes.
However since these tests don't currently pass they are guarded by the macro
TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES. This allows other STL's to validate
the tests before libc++ implements the changes. The relevant libc++ changes should
land in the next week.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300388 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-15 05:28:06 +00:00
Eric Fiselier
0301092a7b Cleanup any_cast failure test
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300175 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13 05:27:55 +00:00
Eric Fiselier
e4b267b262 Fix template >> within C++03 code
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300165 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13 02:56:03 +00:00
Eric Fiselier
dd5982633c Fix C++03 test failures
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300159 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13 01:13:58 +00:00
Eric Fiselier
0cb22a2fb4 Add tests that std::unique_ptr's default constructor is constexpr.
std::unique_ptr's default constructor must be constexpr in order
to allow constant initialization to take place for static objects;
Even though we can never have a constexpr unique_ptr variable since
it's not a literal type.

This patch adds tests that constant initialization takes place by
using the __attribute__((require_constant_initialization)) macro.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300158 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13 01:11:58 +00:00
Eric Fiselier
db14bcc51c [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and add constexpr.
Summary:
__compressed_pair takes and passes it's constructor arguments by value. This causes arguments to be moved 3 times instead of once. This patch addresses that issue and fixes `constexpr` on the constructors.

I would rather have this fix than D27564, and I'm fairly confident it's not ABI breaking but I'm not 100% sure.

I prefer this solution because it removes a lot of code and makes the implementation *much* smaller.

Reviewers: mclow.lists, K-ballo

Reviewed By: K-ballo

Subscribers: K-ballo, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300140 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 23:45:53 +00:00
Eric Fiselier
87fd9b2370 Fix test failures with older Clang versions
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300132 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 23:17:17 +00:00
Eric Fiselier
7b41c797ba [libc++] Implement LWG 2911 - add an is_aggregate type-trait
Summary:
This patch implements http://cplusplus.github.io/LWG/lwg-defects.html#2911.

I'm putting this up for review until __is_aggregate is added to clang (See D31513)

Reviewers: mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300126 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 23:08:46 +00:00
Marshall Clow
9bd669bd90 Additional test file for r300123
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300124 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 22:51:56 +00:00
Marshall Clow
22381ddf4f Implement part of LWG#2857 - any/optional. Still to do - variant. Reviewed as https://reviews.llvm.org/D31956
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300123 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 22:51:27 +00:00
Eric Fiselier
39683f1377 Fix incorrectly qualified return type from unique_ptr::get_deleter().
For reference deleter types the const qualifier on the return type
of get_deleter() should be ignored, and a non-const deleter should
be returned.

This patch fixes a bug where "const deleter_type&" is incorrectly
formed.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300121 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 22:43:49 +00:00
Stephan T. Lavavej
00f804a0a5 [libcxx] [test] Avoid Clang's -Wunused-const-variable in is_constructible.pass.cpp.
This happens when using Clang with MSVC's STL, so there are no actual uses of this variable.

Fixes D31966.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300079 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 17:16:38 +00:00
Marshall Clow
a98a45148f Add some FAIL constexpr tests for optional's copy/move ctors.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300009 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 00:07:29 +00:00
Marshall Clow
01208afbd6 Implement LWG#2873: 'Add noexcept to several shared_ptr related functions' This issue missed a couple, so I added those as well (see LWG#2942)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@299963 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11 17:08:53 +00:00
Marshall Clow
f4f8803751 Fix a C++03 failure
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@299909 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11 01:54:48 +00:00
Marshall Clow
726efd8dfd Remove some trigraphs that GCC was complaining about
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@299907 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11 00:18:28 +00:00
Marshall Clow
a43fe06888 Fix PR#32605: common_type<T> is not SFINAE-friendly
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@299901 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10 23:47:47 +00:00
Marshall Clow
c50c6b79c3 Fix PR#32606: std::decay mishandles abominable function types
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@299894 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10 22:51:07 +00:00
Akira Hatanaka
733ab2f9f0 Revert "Allow a standard library to implement conditional noexcept for optional and unique_ptr hash functions."
This reverts commit r299734.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@299744 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-07 05:55:28 +00:00