Commit Graph

307 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
Marshall Clow
88626bf496 First part of P0600 - '[[nodiscard] in the standard library'. Mark the 'empty()' methods of all the containers as nodiscard. If you're calling empty() w/o looking at the result, you probably meanto to call 'clear()'. c++2a only
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318269 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-15 05:51:26 +00:00
Marshall Clow
2645a49a67 Still more missing tests - this time for the unordered containers
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318268 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-15 05:25:36 +00:00
Marshall Clow
4f009913df More missing tests - array<>::size() and array<>::max_size()
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318256 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-15 02:31:14 +00:00
Marshall Clow
a17cd7c641 Added tests for xxx.size() and xxx.empty() for all the sequence containers
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318244 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-15 01:33:33 +00:00
Eric Fiselier
94c3917960 [libc++] Fix PR34898 - vector iterator constructors and assign method perform push_back instead of emplace_back.
Summary:
The constructors `vector(Iter, Iter, Alloc = Alloc{})` and `assign(Iter, Iter)` don't correctly perform EmplaceConstruction from the result of dereferencing the iterator. This results in them performing an additional and unneeded copy.

This patch addresses the issue by correctly using `emplace_back` in C++11 and newer.

There are also some bugs in our `insert` implementation, but those will be handled separately. 

@mclow.lists We should probably merge this into 5.1, agreed?

Reviewers: mclow.lists, dlj, EricWF

Reviewed By: mclow.lists, EricWF

Subscribers: cfe-commits, mclow.lists

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@315994 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-17 13:03:17 +00:00
Casey Carter
f17205d6a8 [test] Allow other implementations to strengthen noexcept on deque's move constructor
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@314608 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-30 23:15:22 +00:00
Casey Carter
006f64c647 [test] forwardlist.cons/move_noexcept.pass.cpp
* Don't forbid non-libc++ implementations from strengthening noexcept on forward_list's move constructor.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@314459 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-28 20:23:43 +00:00
Stephan T. Lavavej
e8c8bc9433 [libcxx] [test] Update for C++17 feature removals.
test/std/containers/Emplaceable.h
test/std/containers/NotConstructible.h
test/support/counting_predicates.hpp
Replace unary_function/binary_function inheritance with typedefs.

test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp
test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp
test/std/utilities/function.objects/func.require/binary_function.pass.cpp
test/std/utilities/function.objects/func.require/unary_function.pass.cpp
Mark these tests as requiring 98/03/11/14 because 17 removed unary_function/binary_function.

test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp
test/std/thread/futures/futures.task/futures.task.nonmembers/uses_allocator.pass.cpp
Mark these tests as requiring 11/14 because 17 removed packaged_task allocator support.

test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp
This test doesn't need to be skipped in C++17 mode. Only the construction of
std::function from an allocator needs to be skipped in C++17 mode.

test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
When testing these reference_wrapper features, unary_function inheritance is totally irrelevant.

test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
Define and use my_unary_function/my_binary_function to test the weak result type machinery
(which is still present in C++17, although deprecated).

test/support/msvc_stdlib_force_include.hpp
Now we can test C++17 strictly, without enabling removed features.

Fixes D36503.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@311705 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-24 21:24:08 +00:00
Stephan T. Lavavej
5d91f314f1 [libcxx] [test] Change comments to say C++ instead of c++. NFC.
This makes them consistent (many comments already used uppercase).

The special REQUIRES, UNSUPPORTED, and XFAIL comments are excluded from this change.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309468 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29 00:55:35 +00:00
Stephan T. Lavavej
25072f0004 [libcxx] [test] Make files consistently end with newlines, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309465 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29 00:55:22 +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
Marshall Clow
246eb897c9 Fix bug 33389 - __is_transparent check requires too much
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@305292 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13 14:34:58 +00:00
Marshall Clow
568c481c7b [array.tuple]/1 says that instantiating tuple_element<N, array<T, M>> is ill-formed if N >= M. We didn't do that. Add a static_assert to cause a failure, and a test that checks that we failed
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@305191 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-12 14:41:37 +00:00
Stephan T. Lavavej
154d7f1ad6 [libcxx] [test] Fix MSVC "warning C6326: Potential comparison of a constant with another constant".
The expressions `1 == 1` and `true` have the same type, value category, and value.

Fixes D32924.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302322 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 23:38:24 +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
Eric Fiselier
fbca5e0547 Fix tests for extended noexcept in the container adaptors tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300652 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19 02:07:12 +00:00
Eric Fiselier
1ae14a374d Cleanup _LIBCPP_HAS_NO_<c++11-feature> in std::unordered_map and std::unordered_multimap
This completes the cleanup of the containers, at least within the tests.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300620 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 22:50:56 +00:00
Eric Fiselier
6cdc049a90 Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros in std::unordered_set and std::unordered_multiset
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300619 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 22:37:32 +00:00
Eric Fiselier
a8d1b917ee Cleanup _LIBCPP_HAS_NO_<c++11-feature> for std::queue and std::priority_queue.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300604 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 21:23:18 +00:00
Eric Fiselier
7162dceba5 Cleanup _LIBCPP_HAS_NO_<c++11-feature> macro uses in std::stack.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300602 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 21:16:26 +00:00
Eric Fiselier
ce924dce57 Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros in std::map and std::multimap
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300600 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 21:08:06 +00:00
Eric Fiselier
a3de1e063a Cleanup _LIBCPP_HAS_NO_<c++11-feature> for std::set and std::multiset
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300595 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 20:58:03 +00:00
Marshall Clow
07d8458932 Sigh. Once again forgot about the 'no exceptions' bots.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300451 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17 14:18:44 +00:00
Marshall Clow
5e1df5e170 Mark LWG#2853 as complete. No code changes required, but added a couple of extra tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300449 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17 13:19:14 +00:00
Eric Fiselier
1cbdb0cb0e Cleanup one more <forward_list> test
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300417 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 04:05:15 +00:00
Eric Fiselier
ed67bb6007 Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in <forward_list>
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300415 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 04:02:01 +00:00
Eric Fiselier
55ff80ecac Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in <list>
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300414 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 03:45:35 +00:00
Eric Fiselier
48503005c3 Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in deque
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300413 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 03:17:01 +00:00
Eric Fiselier
6c26be6c87 Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in <array>
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300412 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 02:50:40 +00:00
Eric Fiselier
ad421ef159 Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in vector.
This patch cleans up all usages of the following feature test macros inside
<vector> and its tests:

* _LIBCPP_HAS_NO_RVALUE_REFERENCES
* _LIBCPP_HAS_NO_VARIADICS
* _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

Where needed the above guards were replaced with _LIBCPP_CXX03_LANG.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300410 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 02:40:45 +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
Bruce Mitchener
50145cc3e9 [libcxx] Improve code generation for vector::clear().
Summary:
By manipulating a local variable in the loop, when the loop can
be optimized away (due to no non-trivial destructors), this lets
it be fully optimized away and we modify the __end_ separately.

This results in a substantial improvement in the generated code.

Prior to this change, this would be generated (on x86_64):

    movq    (%rdi), %rdx
    movq    8(%rdi), %rcx
    cmpq    %rdx, %rcx
    je    LBB2_2
    leaq    -12(%rcx), %rax
    subq    %rdx, %rax
    movabsq    $-6148914691236517205, %rdx ## imm = 0xAAAAAAAAAAAAAAAB
    mulq    %rdx
    shrq    $3, %rdx
    notq    %rdx
    leaq    (%rdx,%rdx,2), %rax
    leaq    (%rcx,%rax,4), %rax
    movq    %rax, 8(%rdi)

And after:

    movq    (%rdi), %rax
    movq    %rax, 8(%rdi)

This brings this in line with what other implementations do.

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298601 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23 14:39:23 +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
Eric Fiselier
04732df052 Fix sign-compare warning in test; Oddly this only appears on OS X
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@296851 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-03 02:02:07 +00:00
Eric Fiselier
f9ddb9a217 Fix test failures due to bad test hasher
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@296568 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-01 02:34:27 +00:00
Eric Fiselier
b7fd0be370 Update all bug URL's to point to https://bugs.llvm.org/...
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@295434 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 08:37:03 +00:00
Marshall Clow
426546ecec Stop using random_shuffle in the libc++ test suite. It's going to be removed in c++17. Use shuffle() instead. No change to libc++, just the tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294328 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-07 18:41:25 +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
Stephan T. Lavavej
5597800045 [libcxx] [test] Fix Clang -Wunused-local-typedef, part 1/3.
Guard typedefs and static_asserts with _LIBCPP_VERSION.

test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp
test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp
Additionally deal with conditional compilation.

test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp
test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp
Additionally deal with typedefs used by other typedefs.

Fixes D29135.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294154 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-05 22:47:09 +00:00
Marshall Clow
4e42dc97f3 Change the return type of emplace_[front|back] back to void when building with C++14 or before. Resolves PR31680.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292990 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24 23:09:12 +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
Stephan T. Lavavej
16e2ba19df [libcxx] [test] Fix comment typos, strip trailing whitespace.
No functional change, no code review.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292434 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 20:10:25 +00:00
Stephan T. Lavavej
c3564b92bc [libcxx] [test] Fix MSVC warnings C4127 and C6326 about constants.
MSVC has compiler warnings C4127 "conditional expression is constant" (enabled
by /W4) and C6326 "Potential comparison of a constant with another constant"
(enabled by /analyze). They're potentially useful, although they're slightly
annoying to library devs who know what they're doing. In the latest version of
the compiler, C4127 is suppressed when the compiler sees simple tests like
"if (name_of_thing)", so extracting comparison expressions into named
constants is a workaround. At the same time, using std::integral_constant
avoids C6326, which doesn't look at template arguments.

test/std/containers/sequences/vector.bool/emplace.pass.cpp
Replace 1 == 1 with true, which is the same as far as the library is concerned.

Fixes D28837.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292432 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 20:09:56 +00:00
Marshall Clow
d25c997c77 Implement the missing constexpr stuff in <array>. Fixes PR#31645.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292091 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16 03:02:10 +00:00
Stephan T. Lavavej
51eb1be9ec [libcxx] [test] Strip trailing whitespace. NFC, no code review.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@291322 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-07 01:12:15 +00:00
Marshall Clow
e22af6b758 Implement the last bit of P0031: 'A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access' for C++17
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290976 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-04 17:58:17 +00:00
Eric Fiselier
fb342388df Fix debug mode for vector/list and cleanup tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290657 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-28 06:06:09 +00:00
Eric Fiselier
f47536798d Fix yet another missed -Wunused warning. Hopefully this is the last one
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290476 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-24 01:29:27 +00:00
Eric Fiselier
e9784032ce fix warnings only produced by apple-clang
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290474 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-24 01:07:54 +00:00