Commit Graph

40 Commits

Author SHA1 Message Date
Billy Robert O'Neal III
9ae62c79cc Tolerate [[nodiscard]] annotations in the STL. Reviewed as https://reviews.llvm.org/D39033
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318276 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-15 07:40:37 +00:00
Benjamin Kramer
5384fd8538 Placate unused variable warnings uncovered by improvements to clang's -Wunused-variable
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@315809 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-14 15:52:38 +00:00
Eric Fiselier
dfcb00a2c5 Fix failing -verify tests due to change in Clangs static_assert message.
Clang recently changed the way it outputs static assert diagnostics.
This patch fixes libc++'s -verify tests so they tolerate both the old
and new message format.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@313499 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-17 20:57:05 +00:00
Casey Carter
08242cbd9b [test] Cleanup nullopt_t tests
* Update specification text from N4387

* Delete not_brace_initializable.fail.cpp: it's redundant with nullopt_t.fail.cpp

* is_empty<T> implies is_class<T>

* is_literal is deprecated; directly verify that we can create a nullopt_t in a constexpr context

Differential Revision: D37024

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@312256 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-31 17:56:31 +00:00
Stephan T. Lavavej
a686caad20 [libcxx] [test] Untabify, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309464 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29 00:55:10 +00:00
Casey Carter
8b30287098 optional: Implement LWG 2900 and P0602
Differential Revision: https://reviews.llvm.org/D32385

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@307505 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-09 17:15:49 +00:00
Stephan T. Lavavej
b836deb5db [libcxx] [test] Strip trailing whitespace. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@305848 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-20 21:00:02 +00:00
Stephan T. Lavavej
8ba816b366 [libcxx] [test] Remove a Clang/C2 workaround.
Clang/LLVM doesn't need this workaround.

Fixes D33955.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@304999 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-08 18:21:59 +00:00
Casey Carter
57a009ae03 add missing constexpr to optional::value_or
[Credit to cpplearner]

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@304813 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-06 18:47:26 +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
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
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
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
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
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
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
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
Billy Robert O'Neal III
0bdae913c3 Add noexcept(false) to more strongly indicate that not being noexcept is important for hash tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@299735 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-06 23:50:33 +00:00
Billy Robert O'Neal III
2889d45aaa 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@299734 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-06 23:50:21 +00:00
Eric Fiselier
607e0c71ec Fix more -Wshadow warnings introduced by recent Clang change
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@299411 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-04 02:54:27 +00:00
Eric Fiselier
2b3c1c4d9b Fix LWG 2934 - optional<const T> doesn't compare with T
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@299105 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-30 20:06:52 +00:00
Eric Fiselier
5612bd42dc Implement LWG 2842 - optional(U&&) needs to SFINAE on decay_t<in_place_t>
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@299100 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-30 19:43:50 +00:00
Michael Park
ad3680b23e Worked around GCC bug 56480. Explicit specialization in a different namespace.
Summary: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480

Reviewers: EricWF

Reviewed By: EricWF

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298581 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23 06:21:24 +00:00
Marshall Clow
af552ba05a Implement P0599: 'noexcept for hash functions'. Fix a couple of hash functions (optional<T> and unique_ptr<T>) which were mistakenly marked as 'noexcept'. Reviewed as https://reviews.llvm.org/D31234
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298573 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23 02:40:28 +00:00
Stephan T. Lavavej
fdbd18ff71 [libcxx] [test] Strip trailing whitespace.
No functional change, no code review.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294161 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-05 22:48:27 +00:00
Stephan T. Lavavej
939607910d [libcxx] [test] Fix Clang -Wunused-local-typedef, part 2/3.
These typedefs were completely unused.

Fixes D29136.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294155 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-05 22:47:41 +00:00
Marshall Clow
e2261bde80 Change the base class of std::bad_optional_access. This is a (subtle) ABI change, and is in response to http://http://wg21.link/LWG2806, which I *expect* to be adopted in Kona. I am making this change now in anticipation, and will get it into 4.0, because (a) 4.0 is the first release with std::optional, and (b) I don't want to make an ABI-change later, when the user base should be significantly larger. Note that I didn't change std::experimental::bad_optional_access, because that's still specified to derive from std::logic_error.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294133 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-05 20:06:38 +00:00
Marshall Clow
a5f53d0730 Mark LWG2736 as complete. No code changes, but we have more tests now
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292958 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24 18:03:32 +00:00
Eric Fiselier
952eaecfc6 Implement P0513R0 - "Poisoning the Hash"
Summary:
Exactly what the title says.

This patch also adds a `std::hash<nullptr_t>` specialization in C++17, but it was not added by this paper and I can't find the actual paper that adds it.

See http://wg21.link/P0513R0 for more info.

If there are no comments in the next couple of days I'll commit this

Reviewers: mclow.lists, K-ballo, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292684 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-21 00:02:12 +00:00
Eric Fiselier
0e5ebbc77c Fix unused parameters and variables
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290459 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-23 23:37:52 +00:00
Stephan T. Lavavej
ae5809a70c [libcxx] [test] D27268: Fix MSVC x64 warning C4267 "conversion from 'size_t' to 'int' [or 'unsigned int'], possible loss of data", part 2/4.
Use static_cast<int> when storing size_t in int (or passing size_t to int).

Also, remove a spurious semicolon in test/support/archetypes.hpp.

test/support/count_new.hpp
Additionally, change data members (and parameters) to size_t.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288752 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 01:14:43 +00:00
Eric Fiselier
a0b4d55133 Add more tests for optional<const T>
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@285384 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-28 06:40:29 +00:00
Eric Fiselier
317120240b Fix unreferenced parameters. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284942 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-23 18:52:58 +00:00
Eric Fiselier
e2c4227504 Fix shadowing warning. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284941 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-23 18:47:58 +00:00
Eric Fiselier
46c0fcb2b3 Update status for std::optional LWG issues and fix an optional SFINAE bug
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284323 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-16 03:21:35 +00:00
Eric Fiselier
35ce4859dd Implement N4606 optional
Summary:
Adapt implementation of Library Fundamentals TS optional into an implementation of N4606 optional.

  - Update relational operators per http://wg21.link/P0307
  - Update to requirements of http://wg21.link/P0032
  - Extension: Implement trivial copy/move construction/assignment for `optional<T>` when `T` is trivially copyable.

Audit P/Rs for optional LWG issues:
  - 2756 "C++ WP optional<T> should 'forward' T's implicit conversions" Implemented, which also resolves 2753 "Optional's constructors and assignments need constraints" (modulo my refusal to explicitly delete the move operations, which is a design error that I'm working on correcting in the 2756 P/R).
  - 2736 "nullopt_t insufficiently constrained" Already conforming. I've added a test ensuring that `nullopt_t` is not copy-initializable from an empty braced-init-list, which I believe is the root intent of the issue, to avoid regression.
  - 2740 "constexpr optional<T>::operator->" Already conforming.
  - 2746 "Inconsistency between requirements for emplace between optional and variant" No P/R, but note that the author's '"suggested resolution" is already implemented.
  - 2748 "swappable traits for optionals" Already conforming.
  - 2753 "Optional's constructors and assignments need constraints" Implemented.

Most of the work for this patch was done by Casey Carter @ Microsoft. Thank you Casey!



Reviewers: mclow.lists, CaseyCarter, EricWF

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283980 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 07:46:20 +00:00
Eric Fiselier
ead5d404cc Revert Add <optional>. Will recommit with better commit message
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283978 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 06:48:31 +00:00
Eric Fiselier
fbc80168bb Add <optional> header.
This patch is largely thanks to Casey Carter @ Microsoft. He did the initial
work of porting our experimental implementation and tests over to namespace
std.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283977 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 06:45:11 +00:00