summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers
Commit message (Collapse)AuthorAgeFilesLines
...
* [libcxx] [test] D27025: Fix MSVC warning C4389 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-12-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | part 12/12. Various changes: test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp This is comparing value_type to unsigned. value_type is sometimes int and sometimes struct S (implicitly constructible from int). static_cast<value_type>(unsigned) silences the warning and doesn't do anything bad (as the values in question are small). test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp This is comparing an int remote-element to size_t. The values in question are small and non-negative, so either type is fine. I think that converting int to size_t is marginally better here than the reverse. test/std/containers/sequences/deque/deque.cons/size.pass.cpp DefaultOnly::count is int (and non-negative). When comparing to unsigned, use static_cast<unsigned>. test/std/strings/basic.string/string.access/index.pass.cpp We're comparing char to '0' through '9', but formed with the type size_t. Add static_cast<char>. test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp Include <cstddef> for pedantic correctness (this test was already mentioning std::size_t). "v[i] == (i & 1)" was comparing bool to size_t. Saying "v[i] == ((i & 1) != 0)" smashes the RHS to bool. llvm-svn: 288749
* [libcxx] [test] D27024: Fix MSVC warning C4389 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-12-067-17/+17
| | | | | | | | | | | | part 11/12. Change "unsigned n = 0;" to "int n = 0;". It's being compared to int elements and ptrdiff_t distances. test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp This one's a little special, but not really. "*i == n" is comparing MoveOnly to n. MoveOnly is implicitly constructible from int, so int is the correct type to use here. llvm-svn: 288748
* [libcxx] [test] D27023: Fix MSVC warning C4389 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-12-061-8/+8
| | | | | | | | | | | | part 10/12. Add static_cast<int>. In these cases, the values are guaranteed to be small-ish, and they're being compared to int elements. test/std/containers/sequences/deque/deque.capacity/access.pass.cpp Use int instead of unsigned to iterate from 0 to 10. llvm-svn: 288747
* [libcxx] [test] D27022: Fix MSVC warning C4389 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-12-069-17/+23
| | | | | | | | | | part 9/12. Add static_cast<std::size_t> to more comparisons. (Performed manually, unlike part 8/12.) Also, include <cstddef> when it wasn't already being included. llvm-svn: 288746
* [libcxx] [test] D27021: Fix MSVC warning C4389 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-12-06116-941/+1043
| | | | | | | | | | | | | | | | | | | | | part 8/12. Add static_cast<std::size_t> when comparing distance() to size(). These replacements were performed programmatically with regex_replace(): const vector<pair<regex, string>> reg_fmt = { { regex(R"(assert\((\w+)\.size\(\) == std::distance\((\w+, \w+)\)\))"), "assert($1.size() == static_cast<std::size_t>(std::distance($2)))" }, { regex(R"(assert\(distance\((\w+\.begin\(\), \w+\.end\(\))\) == (\w+)\.size\(\)\))"), "assert(static_cast<std::size_t>(distance($1)) == $2.size())" }, { regex(R"(assert\(std::distance\((\w+\.\w*begin\(\), \w+\.\w*end\(\))\) == (\w+)\.size\(\)\))"), "assert(static_cast<std::size_t>(std::distance($1)) == $2.size())" }, }; Also, include <cstddef> when it wasn't already being included. llvm-svn: 288745
* Protect sequences test under libcpp-no-exceptionsRoger Ferrer Ibanez2016-12-012-7/+11
| | | | | | | | Replace throw with TEST_THROW and protect tests that do throw. Also add missing assert(false). Differential Revision: https://reviews.llvm.org/D27252 llvm-svn: 288383
* Protect std::array tests under noexceptionsRoger Ferrer Ibanez2016-11-291-3/+14
| | | | | | | | Skip tests that expect exceptions be thrown. Also add missing asserts. Differential Revision: https://reviews.llvm.org/D27095 llvm-svn: 288165
* Protect std::{,unordered_}map tests under noexceptionsRoger Ferrer Ibanez2016-11-292-2/+18
| | | | | | | | Skip tests that use exceptions Differential Revision: https://reviews.llvm.org/D27093 llvm-svn: 288157
* [libcxx] [test] D27027: Strip trailing whitespace.Stephan T. Lavavej2016-11-2315-20/+20
| | | | llvm-svn: 287829
* [libcxx] [test] D27016: Fix MSVC warning C4018 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-11-236-19/+25
| | | | | | | | | | part 4/12. Change "int j;" indices to "std::size_t j;". Also, include <cstddef> when it wasn't already being included. llvm-svn: 287824
* [libcxx] [test] D27014: Fix MSVC warning C4018 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-11-2316-59/+73
| | | | | | | | | | part 2/12. Add static_cast<std::size_t> when comparing int to std::size_t. Also, include <cstddef> when it wasn't already being included. llvm-svn: 287822
* [libcxx] [test] D27013: Fix MSVC warning C4018 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-11-237-8/+15
| | | | | | | | | | part 1/12. Change loop indices from int to std::size_t. Also, include <cstddef> when it wasn't already being included. llvm-svn: 287820
* [libcxx] Fix max_size() across all containersEric Fiselier2016-11-2312-100/+385
| | | | | | | | | | | | Summary: The `max_size()` method of containers should respect both the allocator's reported `max_size` and the range of the `difference_type`. This patch makes all containers choose the smallest of those two values. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26885 llvm-svn: 287729
* [libcxx] [test] D26627: Fix ordering assumptions in unordered container tests.Stephan T. Lavavej2016-11-153-32/+17
| | | | llvm-svn: 286984
* [libcxx] [test] D26624: Fix bucket_count() assumptions.Stephan T. Lavavej2016-11-158-96/+96
| | | | | | | | | With a max_load_factor of 1.0, the only guarantee is that bucket_count() >= size(). (Note: setting max_load_factor without rehashing isn't supposed to affect this, because setting max_load_factor is currently specified to be constant time.) llvm-svn: 286982
* [libcxx] [test] Replace _LIBCPP_STD_VER with TEST_STD_VER.Stephan T. Lavavej2016-11-0484-105/+187
| | | | | | | | | | | This replaces every occurrence of _LIBCPP_STD_VER in the tests with TEST_STD_VER. Additionally, for every affected file, #include "test_macros.h" is being added explicitly if it wasn't already there. https://reviews.llvm.org/D26294 llvm-svn: 286007
* Change from "XFAIL: libcpp-no-exceptions" to "UNSUPPORTED: ↵Roger Ferrer Ibanez2016-10-315-5/+5
| | | | | | | | | | | | | libcpp-no-exceptions" tests that only check exceptions and nothing else This is a follow up of D24562. These tests do not check anything but exceptions, so it makes sense to mark them as UNSUPPORTED under a library built without exceptions. Differential Revision: https://reviews.llvm.org/D26075 llvm-svn: 285550
* [PATCH] D25483: [libcxx] [test] Fix non-Standard assumptions about how many ↵Stephan T. Lavavej2016-10-2712-16/+31
| | | | | | elements are allocated llvm-svn: 285346
* [libc++] Fix stack_allocatorEric Fiselier2016-10-0831-135/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: To quote STL the problems with stack allocator are" >"stack_allocator<T, N> is seriously nonconformant to N4582 17.6.3.5 [allocator.requirements]. > First, it lacks a rebinding constructor. (The nested "struct rebind" isn't sufficient.) > Second, it lacks templated equality/inequality. > Third, it completely ignores alignment. > Finally, and most severely, the Standard forbids its existence. Allocators are forbidden from returning memory "inside themselves". This requirement is implied by the Standard's requirements for rebinding and equality. It's permitted to return memory from a separate buffer object on the stack, though." This patch attempts to address all of those issues. First, instead of storing the buffer inside the allocator I've change `stack_allocator` to accept the buffer as an argument. Second, in order to fix rebinding I changed the parameter list from `<class T, size_t NumElements>` to `<class T, size_t NumBytes>`. This allows allocator rebinding between types that have different sizes. Third, I added copy and rebinding constructors and assignment operators. And finally I fixed the allocation logic to always return properly aligned storage. Reviewers: mclow.lists, howard.hinnant, STL_MSFT Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25154 llvm-svn: 283631
* Update -verify test to use new static assert messageEric Fiselier2016-09-251-5/+0
| | | | llvm-svn: 282352
* [libc++] Remove various C++03 feature test macrosEric Fiselier2016-09-2511-31/+22
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Libc++ still uses per-feature configuration macros when configuring for C++11. However libc++ requires a feature-complete C++11 compiler so there is no reason to check individual features. This patch starts the process of removing the feature specific macros and replacing their usage with `_LIBCPP_CXX03_LANG`. This patch removes the __config macros: * _LIBCPP_HAS_NO_TRAILING_RETURN * _LIBCPP_HAS_NO_TEMPLATE_ALIASES * _LIBCPP_HAS_NO_ADVANCED_SFINAE * _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS * _LIBCPP_HAS_NO_STATIC_ASSERT As a drive I also changed our C++03 static_assert to use _Static_assert if available. I plan to commit this without review if nobody voices an objection. Reviewers: mclow.lists Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24895 llvm-svn: 282347
* Add missing include that caused a test failure on Windows. Thanks to STL for ↵Marshall Clow2016-08-221-0/+1
| | | | | | the patch. No functional change. llvm-svn: 279453
* make the associative containers do the right thing for ↵Marshall Clow2016-08-171-0/+158
| | | | | | propogate_on_container_assignment. Fixes bug #29001. Tests are only for <map> right now - more complete tests will come when we revamp our allocator testing structure. llvm-svn: 279008
* Support allocators with explicit conversion constructors. Fixes bug #29000Marshall Clow2016-08-1737-3/+974
| | | | llvm-svn: 278904
* Fix compile error due to mismatched iterator types. Patch from STL@microsoft.comEric Fiselier2016-08-031-1/+1
| | | | llvm-svn: 277574
* Make dtor_noexcept.pass.cpp tests more portable. Patch from STL@microsoft.comEric Fiselier2016-07-2513-17/+30
| | | | llvm-svn: 276595
* Mark bucket_count() assertions as non-portable. Patch from STL@microsoft.comEric Fiselier2016-07-25107-349/+458
| | | | llvm-svn: 276593
* Make move_assign_noexcept.pass.cpp tests more portable. Patch from ↵Eric Fiselier2016-07-2512-18/+30
| | | | | | STL@microsoft.com llvm-svn: 276591
* Make swap_noexcept.pass.cpp tests more portable. Patch from STL@microsoft.com.Eric Fiselier2016-07-2516-246/+142
| | | | | | See D21820 for more information (https://reviews.llvm.org/D21820). llvm-svn: 276590
* Fix a non-standard allocator in vector tests. Patch from STL@microsoft.comEric Fiselier2016-07-241-0/+3
| | | | llvm-svn: 276588
* Mark bucket() assertions as non-portable. Patch from STL@microsoft.comEric Fiselier2016-07-244-8/+12
| | | | llvm-svn: 276584
* Make move_noexcept.pass.cpp tests more portable. Patch from STL@microsoft.comEric Fiselier2016-07-2414-39/+53
| | | | llvm-svn: 276581
* Make bucket_count() greater-equal assertions portable. Patch from ↵Eric Fiselier2016-07-244-7/+7
| | | | | | STL@microsoft.com llvm-svn: 276580
* Mark bucket_size() assertions as non-portible. Patch from STL@microsoft.comEric Fiselier2016-07-244-48/+52
| | | | llvm-svn: 276578
* Implement P0084r2. Changing emplace return types.Eric Fiselier2016-07-219-80/+104
| | | | llvm-svn: 276230
* Fix undefined behavior in __treeEric Fiselier2016-07-191-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch attempts to fix the undefined behavior in __tree by changing the node pointer types used throughout. The pointer types are changed for raw pointers in the current ABI and for fancy pointers in ABI V2 (since the fancy pointer types may not be ABI compatible). The UB in `__tree` arises because tree downcasts the embedded end node and then deferences that pointer. Currently there are 3 node types in __tree. * `__tree_end_node` which contains the `__left_` pointer. This node is embedded within the container. * `__tree_node_base` which contains `__right_`, `__parent_` and `__is_black`. This node is used throughout the tree rebalancing algorithms. * `__tree_node` which contains `__value_`. Currently `__tree` stores the start of the tree, `__begin_node_`, as a pointer to a `__tree_node`. Additionally the iterators store their position as a pointer to a `__tree_node`. In both of these cases the pointee can be the end node. This is fixed by changing them to store `__tree_end_node` pointers instead. To make this change I introduced an `__iter_pointer` typedef which is defined to be a pointer to either `__tree_end_node` in the new ABI or `__tree_node` in the current one. Both `__tree::__begin_node_` and iterator pointers are now stored as `__iter_pointers`. The other situation where `__tree_end_node` is stored as the wrong type is in `__tree_node_base::__parent_`. Currently `__left_`, `__right_`, and `__parent_` are all `__tree_node_base` pointers. Since the end node will only be stored in `__parent_` the fix is to change `__parent_` to be a pointer to `__tree_end_node`. To make this change I introduced a `__parent_pointer` typedef which is defined to be a pointer to either `__tree_end_node` in the new ABI or `__tree_node_base` in the current one. Note that in the new ABI `__iter_pointer` and `__parent_pointer` are the same type (but not in the old one). The confusion between these two types is unfortunate but it was the best solution I could come up with that maintains the ABI. The typedef changes force a ton of explicit type casts to correct pointer types and to make current code compatible with both the old and new pointer typedefs. This is the bulk of the change and it's really messy. Unfortunately I don't know how to avoid it. Please let me know what you think. Reviewers: howard.hinnant, mclow.lists Subscribers: howard.hinnant, bbannier, cfe-commits Differential Revision: https://reviews.llvm.org/D20786 llvm-svn: 276003
* Add includes in test. Patch from STL@microsoft.comEric Fiselier2016-07-181-0/+4
| | | | llvm-svn: 275751
* Always use the allocator to construct/destruct elements of a deque/vector. ↵Marshall Clow2016-07-112-0/+21
| | | | | | Fixes PR#28412. Thanks to Jonathan Wakely for the report. llvm-svn: 275105
* Fix static assert problem on gcc; remove XFAILs that I put in in r274250Marshall Clow2016-06-306-12/+0
| | | | llvm-svn: 274285
* Fix C++03 build.Eric Fiselier2016-06-304-1/+13
| | | | llvm-svn: 274274
* Temporarily XFAIL the incomplete type tests for GCC while I figure out why ↵Marshall Clow2016-06-306-0/+12
| | | | | | adding a static_assert in r274235 broken them llvm-svn: 274250
* Implement LWG#2684: 'priority_queue lacking comparator typedef'. We already ↵Marshall Clow2016-06-301-0/+4
| | | | | | did this, just added tests llvm-svn: 274243
* Implement LWG#2596: 'vector::data() should use addressof'Marshall Clow2016-06-302-3/+41
| | | | llvm-svn: 274241
* Implement LWG#2436: 'Comparators for associative containers should always be ↵Marshall Clow2016-06-3012-0/+348
| | | | | | CopyConstructible' llvm-svn: 274235
* Make std::array typedef tests more portable.Eric Fiselier2016-06-301-4/+25
| | | | llvm-svn: 274210
* Fix unary_function inheritance assumption. Patch from STL@microsoft.comEric Fiselier2016-06-301-2/+2
| | | | llvm-svn: 274205
* Make default_noexcept.pass.cpp container tests more portable. Patch from ↵Eric Fiselier2016-06-2615-27/+42
| | | | | | STL@microsoft.com llvm-svn: 273823
* Finish converting list _LIBCPP_DEBUG tests.Eric Fiselier2016-06-225-81/+7
| | | | llvm-svn: 273394
* Cleanup _LIBCPP_DEBUG tests in std::list. More to come.Eric Fiselier2016-06-2211-515/+7
| | | | llvm-svn: 273393
* Cleanup [list.modifiers] tests.Eric Fiselier2016-06-229-566/+53
| | | | llvm-svn: 273371
OpenPOWER on IntegriCloud