summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std
Commit message (Collapse)AuthorAgeFilesLines
* Make tuples constructors conditionally EXPLICIT. See N4387Eric Fiselier2016-04-1911-3/+285
| | | | llvm-svn: 266703
* Implement LWG issue 2219 - support reference_wrapper in INVOKEEric Fiselier2016-04-187-45/+336
| | | | llvm-svn: 266590
* Add hash specializations for __int128_t. Fixes LWG issue 2119Eric Fiselier2016-04-181-3/+8
| | | | llvm-svn: 266587
* Add tests for LWG issue 2361Eric Fiselier2016-04-1815-8/+262
| | | | llvm-svn: 266586
* Fix LWG issue 2345 - Add insert(value_type&&)Eric Fiselier2016-04-1818-533/+672
| | | | llvm-svn: 266585
* Teach map/unordered_map how to optimize 'emplace(Key, T)'.Eric Fiselier2016-04-163-4/+132
| | | | | | | | | 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. llvm-svn: 266498
* Extract key to avoid preemptive mallocs in insert/emplace in associative ↵Eric Fiselier2016-04-1512-996/+849
| | | | | | | | | | | | | | 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 llvm-svn: 266491
* Cleanup and guard tuple's constructor SFINAE. Fixes PR22806 and PR23256.Eric Fiselier2016-04-153-2/+278
| | | | | | | | | | | | | | | | | | | | | There are two main fixes in this patch. First the constructor SFINAE was changed so that it's evaluated in two stages where the first stage evaluates the "safe" SFINAE conditions and the second evaluates the "dangerous" ones. The key is that the second stage is lazily evaluated only if the first stage passes. This helps fix PR23256 (https://llvm.org/bugs/show_bug.cgi?id=23256). The second fix is for PR22806 and LWG issue 2549. This fix applies the suggested resolution to the LWG issue in order to prevent the construction of dangling references. The SFINAE for this check is contained within the _PreferTupleLikeConstructor alias template. The tuple-like constructors are disabled whenever that trait returns false. (https://llvm.org/bugs/show_bug.cgi?id=22806) (http://cplusplus.github.io/LWG/lwg-active.html#2549) llvm-svn: 266461
* [libcxx] Remove the "reduced-arity-initialization" extension from the ↵Eric Fiselier2016-04-152-55/+98
| | | | | | | | | | | | | | | | | uses-allocator constructors Summary: A default uses-allocator constructor has been added since that overload was previously provided by the extended constructor. Since Clang does implicit conversion checking after substitution this constructor has to deduce the allocator_arg_t parameter so that it can prevent the evaluation of "is_default_constructible" if the first argument doesn't match. See http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1391 for more information. This patch fixes PR24779 (https://llvm.org/bugs/show_bug.cgi?id=24779) Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19006 llvm-svn: 266409
* Implement LWG#680, which was missed lo these many moons ago, and was ↵Marshall Clow2016-04-111-2/+2
| | | | | | reported as bug #27259. As a drive-by fix, replace the hand-rolled equivalent to addressof in __wrap_iter with the real thing. llvm-svn: 265914
* Recommit r263036 with additional inlining, so that it will continue to work ↵Marshall Clow2016-04-071-2/+25
| | | | | | with existing system dylibs. Implements LWG#2583 llvm-svn: 265706
* Added a noexcept testMarshall Clow2016-04-071-0/+6
| | | | llvm-svn: 265674
* Fix bug #27260 - add missing swap(reference, reference) to vector<bool>.Marshall Clow2016-04-071-0/+31
| | | | llvm-svn: 265672
* Fix LWG issue 2469 - Use piecewise construction in map::operator[].Eric Fiselier2016-03-312-4/+68
| | | | | | | | | | | | | | | 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. llvm-svn: 264989
* Teach __tree how to handle map's __value_typeEric Fiselier2016-03-314-0/+479
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 264986
* Update container_test_types.h and cleanup the related testsEric Fiselier2016-03-316-24/+13
| | | | llvm-svn: 264985
* Implement is_always_lock_freeJF Bastien2016-03-251-0/+101
| | | | | | | | | | | | | | | | | | Summary: This was voted into C++17 at the Jacksonville meeting. The final P0152R1 paper will be in the upcoming post-Jacksonville mailing, and is also available here: http://jfbastien.github.io/papers/P0152R1.html Reviewers: mclow.lists, rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D17951 llvm-svn: 264413
* Guard a number of tests relying on threads support when built inRichard Barton2016-03-2310-4/+18
| | | | | | | | single-threaded mode. Differential Revision: http://reviews.llvm.org/D14731 llvm-svn: 264191
* Missing ATOMIC_*_LOCK_FREE testsJF Bastien2016-03-181-0/+8
| | | | | | Forked from D17951, these tests should have been there but weren't. llvm-svn: 263798
* unord: Extract key to avoid preemptive mallocs in insert/emplaceDuncan P. N. Exon Smith2016-03-172-0/+184
| | | | | | | | | | | | | | | | | | | | | | | | | | 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). llvm-svn: 263746
* Make std::addressof constexpr in C++17 (Clang only).Eric Fiselier2016-03-171-0/+42
| | | | llvm-svn: 263688
* [libcxx] Remove localization tests for Russian month namesJonas Hahnfeld2016-03-152-34/+0
| | | | | | | | | | | | | | Commit f49839299a085505eb673544744b61d2d9cdd1db in glibc-2.14 changed the locales to the currently required format. However, they were again changed in commit 55bdd2866f23b28422d969060b3518909a12b100 which has been released in 2.17. That leads to the current situation where Debian and e.g. CentOS 6 have the pre-2.14 locales, for example Ubuntu 14.04 has pre-2.17 and CentOS 7 on the other hand has the newest locales in glibc-2.17. Differential Revision: http://reviews.llvm.org/D18187 llvm-svn: 263554
* Implement LWG2577: {shared,unique}_lock</tt> should use std::addressofMarshall Clow2016-03-1410-42/+150
| | | | llvm-svn: 263506
* Add failing tests that I forgot to add to the last commitMarshall Clow2016-03-143-0/+90
| | | | llvm-svn: 263451
* Implement LWG#2566: Requirements on the first template parameter of ↵Marshall Clow2016-03-143-21/+21
| | | | | | container adaptors llvm-svn: 263450
* Mark exception-throwing test as XFAIL when exceptions are disabledMarshall Clow2016-03-141-0/+1
| | | | llvm-svn: 263405
* Revert r263036, it's ABI-breaking.Nico Weber2016-03-111-25/+2
| | | | llvm-svn: 263246
* Implement LWG#2579: Inconsistency wrt Allocators in basic_string assignment ↵Marshall Clow2016-03-091-1/+33
| | | | | | vs. basic_string::assign llvm-svn: 263042
* Implement LWG#2583: There is no way to supply an allocator for ↵Marshall Clow2016-03-091-2/+25
| | | | | | basic_string(str, pos) llvm-svn: 263036
* Add some more tests for the containers type requirementsMarshall Clow2016-03-096-19/+112
| | | | llvm-svn: 263029
* Remove a couple tabs that crept inMarshall Clow2016-03-081-2/+2
| | | | llvm-svn: 262932
* Implement P0272R1: Give 'std::string' a non-const '.data()' member functionMarshall Clow2016-03-081-10/+36
| | | | llvm-svn: 262931
* Implement P0253R1: Fixing a design mistake in the searchers interface.Marshall Clow2016-03-0811-13/+16
| | | | llvm-svn: 262928
* Implement P0025R0: 'An algorithm to clamp a value between a pair of boundary ↵Marshall Clow2016-03-072-0/+121
| | | | | | values' for C++17 llvm-svn: 262871
* non-member swap for array was mistakenly taking const ref params. Fixed and ↵Marshall Clow2016-03-071-1/+28
| | | | | | added test. Thanks to Ben Craig for the catch llvm-svn: 262866
* Fix for PR26812: possible overflow issue in std::allocator::allocateMarshall Clow2016-03-031-0/+46
| | | | llvm-svn: 262610
* Added tests to make sure that the categorization traits work on incomplete typesMarshall Clow2016-02-2529-15/+127
| | | | llvm-svn: 261925
* No, really - test the constructorMarshall Clow2016-02-251-1/+1
| | | | llvm-svn: 261875
* Add test to ensure that the converting constructor in N4089 is present and ↵Marshall Clow2016-02-251-0/+27
| | | | | | working llvm-svn: 261874
* These new tests fail on the green-dragon bots, which use an old Apple compiler.Marshall Clow2016-02-231-8/+10
| | | | | | | Since they're scheduled to be updated soon, we'll just comment out this test for the moment, and re-commit when the bots are updated. llvm-svn: 261661
* Add tests for LWG#2560. No code changes, just testsMarshall Clow2016-02-231-0/+9
| | | | llvm-svn: 261653
* Add additional tests to ensure that we DTRT with short lists. This is ↵Marshall Clow2016-02-231-0/+14
| | | | | | LWG#2590, but there are no code changes, just additional tests llvm-svn: 261648
* Cleanup node-type handling in the associative containers.Eric Fiselier2016-02-205-0/+247
| | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 261416
* Fix LWG issue 2469 - Use piecewise construction in unordered_map::operator[].Eric Fiselier2016-02-112-12/+52
| | | | | | | | | | | | | 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'. llvm-svn: 260601
* Revert r260514 because it has a bogus commit message.Eric Fiselier2016-02-112-52/+12
| | | | llvm-svn: 260556
* Add some tests to ensure that the __regex_word does not conflict with any of ↵Marshall Clow2016-02-111-0/+13
| | | | | | | | ctype_base's values. Hopefully this will catch cases like https://llvm.org/bugs/show_bug.cgi?id=26476 in the future. llvm-svn: 260527
* Teach __hash_table how to handle unordered_map's __hash_value_type.Eric Fiselier2016-02-112-12/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is fairly large and contains a number of changes. The main change is teaching '__hash_table' how to handle '__hash_value_type'. Unfortunately this change is a rampant layering violation, but it's required to make unordered_map conforming without re-writing all of __hash_table. After this change 'unordered_map' can delegate to '__hash_table' in almost all cases. The major changes found in this patch are: * Teach __hash_table to differentiate between the true container value type and the node value type by introducing the "__container_value_type" and "__node_value_type" typedefs. In the case of unordered_map '__container_value_type' is 'pair<const Key, Value>' and '__node_value_type' is '__hash_value_type'. * Switch almost all overloads in '__hash_table' previously taking 'value_type' (AKA '__node_value_type) to take '__container_value_type' instead. Previously 'pair<K, V>' would be implicitly converted to '__hash_value_type<K, V>' because of the function signature. * Add '__get_key', '__get_value', '__get_ptr', and '__move' static functions to '__key_value_types'. These functions allow '__hash_table' to unwrap '__node_value_type' objects into '__container_value_type' and its sub-parts. * Pass '__hash_value_type::__value_' to 'a.construct(p, ...)' instead of '__hash_value_type' itself. The C++14 standard requires that 'a.construct()' and 'a.destroy()' are only ever instantiated for the containers value type. * Remove '__hash_value_type's constructors and destructors. We should never construct an instance of this type. (TODO this is UB but we already do it in plenty of places). * Add a generic "try-emplace" function to '__hash_table' called '__emplace_unique_key_args(Key const&, Args...)'. The following changes were done as cleanup: * Introduce the '_LIBCPP_CXX03_LANG' macro to be used in place of '_LIBCPP_HAS_NO_VARIADICS' or '_LIBCPP_HAS_NO_RVALUE_REFERENCE'. * Cleanup C++11 only overloads that assume an incomplete C++11 implementation. For example this patch removes the __construct_node overloads that do manual pack expansion. * Forward 'unordered_map::emplace' to '__hash_table' and remove dead code resulting from the change. This includes almost all 'unordered_map::__construct_node' overloads. The following changes are planed for future revisions: * Fix LWG issue #2469 by delegating 'unordered_map::operator[]' to use '__emplace_unique_key_args'. * Rewrite 'unordered_map::try_emplace' in terms of '__emplace_unique_key_args'. * Optimize '__emplace_unique' to call '__emplace_unique_key_args' when possible. This prevent unneeded allocations when inserting duplicate entries. The additional follow up work needed after this patch: * Respect the lifetime rules for '__hash_value_type' by actually constructing it. * Make '__insert_multi' act similar to '__insert_unique' for objects of type 'T&' and 'T const &&' with 'T = __container_value_type'. llvm-svn: 260514
* Teach __hash_table how to handle unordered_map's __hash_value_type.Eric Fiselier2016-02-114-0/+500
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is fairly large and contains a number of changes. The main change is teaching '__hash_table' how to handle '__hash_value_type'. Unfortunately this change is a rampant layering violation, but it's required to make unordered_map conforming without re-writing all of __hash_table. After this change 'unordered_map' can delegate to '__hash_table' in almost all cases. The major changes found in this patch are: * Teach __hash_table to differentiate between the true container value type and the node value type by introducing the "__container_value_type" and "__node_value_type" typedefs. In the case of unordered_map '__container_value_type' is 'pair<const Key, Value>' and '__node_value_type' is '__hash_value_type'. * Switch almost all overloads in '__hash_table' previously taking 'value_type' (AKA '__node_value_type) to take '__container_value_type' instead. Previously 'pair<K, V>' would be implicitly converted to '__hash_value_type<K, V>' because of the function signature. * Add '__get_key', '__get_value', '__get_ptr', and '__move' static functions to '__key_value_types'. These functions allow '__hash_table' to unwrap '__node_value_type' objects into '__container_value_type' and its sub-parts. * Pass '__hash_value_type::__value_' to 'a.construct(p, ...)' instead of '__hash_value_type' itself. The C++14 standard requires that 'a.construct()' and 'a.destroy()' are only ever instantiated for the containers value type. * Remove '__hash_value_type's constructors and destructors. We should never construct an instance of this type. (TODO this is UB but we already do it in plenty of places). * Add a generic "try-emplace" function to '__hash_table' called '__emplace_unique_key_args(Key const&, Args...)'. The following changes were done as cleanup: * Introduce the '_LIBCPP_CXX03_LANG' macro to be used in place of '_LIBCPP_HAS_NO_VARIADICS' or '_LIBCPP_HAS_NO_RVALUE_REFERENCE'. * Cleanup C++11 only overloads that assume an incomplete C++11 implementation. For example this patch removes the __construct_node overloads that do manual pack expansion. * Forward 'unordered_map::emplace' to '__hash_table' and remove dead code resulting from the change. This includes almost all 'unordered_map::__construct_node' overloads. The following changes are planed for future revisions: * Fix LWG issue #2469 by delegating 'unordered_map::operator[]' to use '__emplace_unique_key_args'. * Rewrite 'unordered_map::try_emplace' in terms of '__emplace_unique_key_args'. * Optimize '__emplace_unique' to call '__emplace_unique_key_args' when possible. This prevent unneeded allocations when inserting duplicate entries. The additional follow up work needed after this patch: * Respect the lifetime rules for '__hash_value_type' by actually constructing it. * Make '__insert_multi' act similar to '__insert_unique' for objects of type 'T&' and 'T const &&' with 'T = __container_value_type'. llvm-svn: 260513
* Recommit r260012 - Cleanup node-type handling in the unordered containers.Eric Fiselier2016-02-105-0/+304
| | | | | | | | | | | | | | | | | | | | | | | | | | | This time I kept <ext/hash_map> working! This patch is the first in a series of patches that's meant to better support unordered_map. unordered_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 __hash_table about this special value_type. This patch creates a "__hash_node_types" traits class that contains all of the typedefs needed by the unordered containers and it's iterators. These typedefs include ones for each node type and node pointer type, as well as special typedefs for "unordered_map"'s value type. As a result of this change all of the unordered containers now all support incomplete types. As a drive-by fix I changed the difference_type in __hash_table to always be ptrdiff_t. There is a corresponding change to size_type but it cannot take affect until an ABI break. This patch will be followed up shortly with fixes for various unordered_map bugs and problems. llvm-svn: 260431
* Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr fromRichard Smith2016-02-104-20/+37
| | | | | | | | | | | | | | | | | <string.h> and wcschr, wcspbrk, wcsrchr, wmemchr, and wcsstr from <wchar.h> to provide a const-correct overload set even when the underlying C library does not. This change adds a new macro, _LIBCPP_PREFERRED_OVERLOAD, which (if defined) specifies that a given overload is a better match than an otherwise equally good function declaration without the overload. This is implemented in modern versions of Clang via __attribute__((enable_if)), and not elsewhere. We use this new macro to define overloads in the global namespace for these functions that displace the overloads provided by the C library, unless we believe the C library is already providing the correct signatures. llvm-svn: 260337
OpenPOWER on IntegriCloud