Commit Graph

307 Commits

Author SHA1 Message Date
Marshall Clow
1a93312404 Fix static assert problem on gcc; remove XFAILs that I put in in r274250
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274285 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 22:05:45 +00:00
Eric Fiselier
3efb2c901e Fix C++03 build.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274274 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 20:46:58 +00:00
Marshall Clow
a0f496b989 Temporarily XFAIL the incomplete type tests for GCC while I figure out why adding a static_assert in r274235 broken them
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274250 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 17:49:36 +00:00
Marshall Clow
256814f751 Implement LWG#2684: 'priority_queue lacking comparator typedef'. We already did this, just added tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274243 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 16:03:50 +00:00
Marshall Clow
f0419f1dcc Implement LWG#2596: 'vector::data() should use addressof'
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274241 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 15:50:55 +00:00
Marshall Clow
0c99f18af4 Implement LWG#2436: 'Comparators for associative containers should always be CopyConstructible'
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274235 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 15:11:53 +00:00
Eric Fiselier
0fc5603d78 Make std::array typedef tests more portable.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274210 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 04:54:00 +00:00
Eric Fiselier
16715b9a88 Fix unary_function inheritance assumption. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274205 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 04:28:12 +00:00
Eric Fiselier
5078baa9e0 Make default_noexcept.pass.cpp container tests more portable. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273823 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-26 20:21:22 +00:00
Eric Fiselier
8d2b31567c Finish converting list _LIBCPP_DEBUG tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273394 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 08:47:43 +00:00
Eric Fiselier
111c696838 Cleanup _LIBCPP_DEBUG tests in std::list. More to come.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273393 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 08:01:27 +00:00
Eric Fiselier
506f9d5bd3 Cleanup [list.modifiers] tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273371 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 03:46:32 +00:00
Eric Fiselier
22bff1afcc Move remaining _LIBCPP_VERSION tests into test/libcxx
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273367 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 02:23:22 +00:00
Eric Fiselier
c02ca7f4b0 Improve portability of vector tests. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272745 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-15 01:44:22 +00:00
Eric Fiselier
d24c465bea Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER.
This is a huge cleanup that helps make the libc++ test suite more portable.
Patch from STL@microsoft.com. Thanks STL!


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272716 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-14 21:31:42 +00:00
Marshall Clow
174432dbd5 Found a couple bugs in the test suite. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272679 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-14 15:25:46 +00:00
Eric Fiselier
831bfc277c Fix vector<bool> tests that were using ints. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272620 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-14 02:53:04 +00:00
Marshall Clow
4241df3ef4 Make the comparison objects that we pass in for various tests look more like actual comparison objects. No functional change.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272288 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 18:34:38 +00:00
Marshall Clow
467eaf8269 Avoid Shadowing warnings in the associative containers tests. Thanks to STL for the patch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272018 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 15:49:39 +00:00
Asiri Rathnayake
1575e3e813 [libcxx] Fix c++98 test failures.
Adds XFAIL/UNSUPPORTED lit tags as appropriate. Gets a clean test run
for -std=c++98 on Fedora 20.

NFC.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271741 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 21:40:03 +00:00
Eric Fiselier
84acb1ec3f Remove trailing whitespace in test suite. Approved by Marshall Clow.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271435 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-01 21:35:39 +00:00
Eric Fiselier
7883d02159 Mark LWG issue 2537 as complete
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271241 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 01:11:20 +00:00
Eric Fiselier
7d1c44c360 Mark LWG issue #2585 as complete
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271240 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 01:03:07 +00:00
Asiri Rathnayake
a3eac518e6 [libcxx] Improve tests to use the UNSUPPORTED lit directive
Quite a few libcxx tests seem to follow the format:
 #if _LIBCPP_STD_VER > X
   // Do test.
 #else
   // Empty test.
 #endif
We should instead use the UNSUPPORTED lit directive to exclude the test on
earlier C++ standards. This gives us a more accurate number of test passes
for those standards and avoids unnecessary conflicts with other lit
directives on the same tests.

Reviewers: bcraig, ericwf, mclow.lists

Differential revision: http://reviews.llvm.org/D20730

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271108 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 08:57:35 +00:00
Eric Fiselier
1e5a4a4a71 Fix or move various non-standard tests.
This patch does the following:

* Remove <__config> includes from some container tests.
* Guards uses of std::launch::any in async tests because it's an extension.
* Move "test/std/extensions" to "test/libcxx/extensions"
* Moves various non-standard tests including those in "sequences/vector",
  "std/localization" and "utilities/meta".


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267981 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-29 04:07:45 +00:00
Eric Fiselier
375e2f669c Guard libc++ specific c.__invariants() tests in LIBCPP_ASSERT macros
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267947 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 22:28:23 +00:00
Eric Fiselier
bda804ea25 Remove names of unreferenced parameters. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267852 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 03:17:56 +00:00
Eric Fiselier
849c551745 Add braces, move braces, and rename variables to avoid shadowing. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267844 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 02:45:11 +00:00
Marshall Clow
d446308c9c Fix = that should have been == in test. Thanks to STL@microsoft for the catch
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267654 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 01:46:43 +00:00
Eric Fiselier
5ccbc48774 Fix some non-standard parts of our test suite. Reported by STL
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267131 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22 10:33:56 +00:00
Eric Fiselier
6f367f088c Fix C++03 build breakage
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267090 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22 00:47:15 +00:00
Eric Fiselier
c6c26a44de Complete LWG issue #2016. Allocators must be nothrow swappable
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267085 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22 00:15:18 +00:00
Eric Fiselier
8f1e73dfd2 Add is_swappable/is_nothrow_swappable traits
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267079 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21 23:38:59 +00:00
Eric Fiselier
91a156579e Fix LWG issue 2345 - Add insert(value_type&&)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266585 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 01:40:45 +00:00
Eric Fiselier
dc414cd8ca Teach map/unordered_map how to optimize 'emplace(Key, T)'.
In cases where emplace is called with two arguments and the first one
matches the key_type we can Key to check for duplicates before allocating.

This patch expands on work done by dexonsmith@apple.com.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266498 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 00:23:12 +00:00
Eric Fiselier
83c9dc1714 Extract key to avoid preemptive mallocs in insert/emplace in associative containers
Summary: This patch applies Duncan's work on __hash_table to __tree.

Reviewers: mclow.lists, dexonsmith

Subscribers: dexonsmith, cfe-commits

Differential Revision: http://reviews.llvm.org/D18637

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266491 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 23:27:27 +00:00
Marshall Clow
56a0a437b7 Added a noexcept test
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@265674 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 14:24:16 +00:00
Marshall Clow
005c60b666 Fix bug #27260 - add missing swap(reference, reference) to vector<bool>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@265672 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 14:20:31 +00:00
Eric Fiselier
d2864678e0 Fix LWG issue 2469 - Use piecewise construction in map::operator[].
map's allocator may only be used to construct objects of 'value_type',
or in this case 'pair<const Key, Value>'. In order to respect this requirement
in operator[], which requires default constructing the 'mapped_type', we have
to use pair's piecewise constructor with '(tuple<Kep>, tuple<>)'.

Unfortunately we still need to provide a fallback implementation for C++03
since we don't have <tuple>. Even worse this fallback is the last remaining
user of '__hash_map_node_destructor' and '__construct_node_with_key'.

This patch also switches try_emplace over to __tree.__emplace_unique_key_args.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@264989 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 03:13:37 +00:00
Eric Fiselier
db21506d13 Teach __tree how to handle map's __value_type
This patch is fairly large and contains a number of changes. The changes all work towards
allowing __tree to properly handle __value_type esspecially when inserting into the __tree.
I chose not to break this change into smaller patches because it wouldn't be possible to
write meaningful standard-compliant tests for each patch.

It is very similar to r260513 "[libcxx] Teach __hash_table how to handle unordered_map's __hash_value_type".

Changes in <map>
 * Remove __value_type's constructors because it should never be constructed directly.

 * Make map::emplace and multimap::emplace forward to __tree and remove the old definitions

 * Remove "__construct_node" map and multimap member functions. Almost all of the construction is done within __tree.

 * Fix map's move constructor to access "__value_type.__nc" directly and pass this object to __tree::insert.

Changes in <__tree>
 * Add traits to detect, handle, and unwrap, map's "__value_type".

 * Convert methods taking "value_type" to take "__container_value_type" instead. Previously these methods caused
  unwanted implicit conversions from "std::pair<Key, Value>" to "__value_type<Key, Value>".

 * Delete __tree_node and __tree_node_base's constructors and assignment operators. The node types should never be constructed
   because the "__value_" member of __tree_node must be constructed directly by the allocator.

 * Make the __tree_node_destructor class and "__construct_node" methods unwrap "__node_value_type" into "__container_value_type" before invoking the allocator. The user's allocator can only be used to construct and destroy the container's value_type. Passing it map's "__value_type" was incorrect.

 * Cleanup the "__insert" and "__emplace" methods. Have __insert forward to an __emplace function wherever possible to reduce
   code duplication. __insert_unique(value_type const&) and __insert_unique(value_type&&) forward to __emplace_unique_key_args.
   These functions will not allocate a new node if the value is already in the tree.

 * Change the __find* functions to take the "key_type" directly instead of passing in "value_type" and unwrapping the key later.
   This change allows the find functions to be used without having to construct a "value_type" first. This allows for a number
   of optimizations.

 * Teach __move_assign and __assign_multi methods to unwrap map's __value_type.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@264986 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 02:15:15 +00:00
Eric Fiselier
21f3b4ca42 Update container_test_types.h and cleanup the related tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@264985 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 02:13:14 +00:00
Duncan P. N. Exon Smith
798ec8436d unord: Extract key to avoid preemptive mallocs in insert/emplace
unordered_set::emplace and unordered_map::emplace construct a node, then
try to insert it.  If insertion fails, the node gets deleted.

To avoid this unnecessary malloc traffic, check to see if the argument
to emplace has the appropriate key_type.  If so, we can use that key
directly and delay the malloc until we're sure we're inserting something
new.

Test updates by Eric Fiselier, who rewrote the old allocation tests to
include the new cases.

There are two orthogonal future directions:

1. Apply the same optimization to set and map.

2. Extend the optimization to when the argument is not key_type, but can
   be converted to it without side effects.  Ideally, we could do this
   whenever key_type is trivially destructible and the argument is
   trivially convertible to key_type, but in practise the relevant type
   traits "blow up sometimes".  At least, we should catch a few simple
   cases (such as when both are primitive types).

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263746 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-17 20:45:20 +00:00
Marshall Clow
fd2d680753 Add failing tests that I forgot to add to the last commit
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263451 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-14 17:58:54 +00:00
Marshall Clow
ed77ffbc4d Implement LWG#2566: Requirements on the first template parameter of container adaptors
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263450 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-14 17:58:11 +00:00
Marshall Clow
d7d1bda0f4 Add some more tests for the containers type requirements
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263029 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-09 17:19:07 +00:00
Marshall Clow
8d48d9b2cc non-member swap for array was mistakenly taking const ref params. Fixed and added test. Thanks to Ben Craig for the catch
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@262866 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-07 21:57:10 +00:00
Marshall Clow
20fefa6b3a Add additional tests to ensure that we DTRT with short lists. This is LWG#2590, but there are no code changes, just additional tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@261648 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-23 16:25:20 +00:00
Eric Fiselier
55263484af Cleanup node-type handling in the associative containers.
This patch is very similar to r260431.

This patch is the first in a series of patches that's meant to better
support map. map has a special "value_type" that
differs from pair<const Key, Value>. In order to meet the EmplaceConstructible
and CopyInsertable requirements we need to teach __tree about this
special value_type.

This patch creates a "__tree_node_types" traits class that contains
all of the typedefs needed by the associative containers and their iterators.
These typedefs include ones for each node type and  node pointer type,
as well as special typedefs for "map"'s value type.

Although the associative containers already supported incomplete types, this
patch makes it official by adding tests.

This patch will be followed up shortly with various cleanups within __tree and
fixes for various map bugs and problems.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@261416 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-20 05:28:30 +00:00
Eric Fiselier
410ed303ba Fix LWG issue 2469 - Use piecewise construction in unordered_map::operator[].
unordered_map's allocator may only be used to construct objects of 'value_type',
or in this case 'pair<const Key, Value>'. In order to respect this requirement
in operator[], which requires default constructing the 'mapped_type', we have
to use pair's piecewise constructor with '(tuple<Kep>, tuple<>)'.

Unfortunately we still need to provide a fallback implementation for C++03
since we don't have <tuple>. Even worse this fallback is the last remaining
user of '__hash_map_node_destructor' and '__construct_node_with_key'.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@260601 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-11 21:45:53 +00:00
Eric Fiselier
ab4148260e Revert r260514 because it has a bogus commit message.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@260556 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-11 18:21:18 +00:00