summaryrefslogtreecommitdiffstats
path: root/libcxx/test/support/test_allocator.h
Commit message (Collapse)AuthorAgeFilesLines
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
* Fix PR37694 - std::vector doesn't correctly move construct allocators.Eric Fiselier2018-06-051-5/+52
| | | | | | | | | | | | | | | | | | | C++2a[container.requirements.general]p8 states that when move constructing a container, the allocator is move constructed. Vector previously copy constructed these allocators. This patch fixes that bug. Additionally it cleans up some unnecessary allocator conversions when copy constructing containers. Libc++ uses __internal_allocator_traits::select_on_copy_construction to select the correct allocator during copy construction, but it unnecessarily converted the resulting allocator to the user specified allocator type and back. After this patch list and forward_list no longer do that. Technically we're supposed to be using allocator_traits<allocator_type>::select_on_copy_construction, but that should seemingly be addressed as a separate patch, if at all. llvm-svn: 334053
* Fix undefined behavior in container swap tests.Eric Fiselier2016-12-111-12/+24
| | | | | | | | | | | | These swap tests were swapping non-POCS non-equal allocators which is undefined behavior. This patch changes the tests to use allocators which compare equal. In order to test that the allocators were not swapped I added an "id" field to test_allocator which does not participate in equality but does propagate across copies/swaps. This patch is based off of D26623 which was submitted by STL. llvm-svn: 289358
* Fix more uses of dynamic exception specifications in C++17Eric Fiselier2016-12-111-17/+17
| | | | llvm-svn: 289356
* Fix __hash_table::max_size() on 32 bit systemsEric Fiselier2016-11-231-1/+2
| | | | llvm-svn: 287749
* [libcxx] Fix max_size() across all containersEric Fiselier2016-11-231-0/+6
| | | | | | | | | | | | 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
* Correctly grant rebound limited_allocators friendship.Eric Fiselier2016-10-121-0/+1
| | | | llvm-svn: 284006
* Add missing include in test_allocator.hEric Fiselier2016-10-081-2/+3
| | | | llvm-svn: 283632
* [libc++] Fix stack_allocatorEric Fiselier2016-10-081-0/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Remove MSVC workarounds. Patch from STL@microsoft.comEric Fiselier2016-10-071-8/+2
| | | | llvm-svn: 283580
* [libc++] Remove various C++03 feature test macrosEric Fiselier2016-09-251-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Silence another occurrence of MSVC's suprious unused warning. Patch from ↵Eric Fiselier2016-08-031-1/+4
| | | | | | STL@microsoft.com llvm-svn: 277572
* Always use the allocator to construct/destruct elements of a deque/vector. ↵Marshall Clow2016-07-111-0/+78
| | | | | | Fixes PR#28412. Thanks to Jonathan Wakely for the report. llvm-svn: 275105
* Suppress stupid and incorrect MSVC warning. patch from STL@microsoft.comEric Fiselier2016-06-221-1/+5
| | | | llvm-svn: 273350
* [libcxx] [test] In test/support/test_allocator.h, fix construct() to avoid ↵Eric Fiselier2016-06-151-11/+12
| | | | | | | | | | | | | | | | | moving immovable types. Summary: In test/support/test_allocator.h, fix construct() to avoid moving immovable types. This improves the allocator's conformance, and fixes compiler errors with MSVC's STL. The scenario is when the allocator is asked to construct an object of type X that's immovable (deleted copy/move ctors), but implicitly constructible from an argument type A. When perfectly forwarded, X can be (explicitly) constructed from A, and everything is fine. That's std::allocator's behavior, and the Standard's default when a user allocator's construct() doesn't exist. The previous implementation of construct() here mishandled this scenario. Passing A to this construct() would implicitly construct an X temporary, bound to (non-templated) T&&. Then construct() would attempt to move-construct X from that X temporary, but X is immovable, boom. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21094 llvm-svn: 272747
* Remove names of unreferenced parameters. Patch from STL@microsoft.comEric Fiselier2016-04-281-3/+3
| | | | llvm-svn: 267852
* Fix bug in test_allocator<void> that used the wrong value to represent ↵Eric Fiselier2015-08-281-2/+2
| | | | | | object state llvm-svn: 246270
* Fix std::function allocator constructors in C++03.Eric Fiselier2015-06-141-6/+6
| | | | | | | | | The C++03 version of function tried to default construct the allocator in the uses allocator constructors when no allocation was performed. These constructors would fail to compile when used with allocators that had no default constructor. llvm-svn: 239708
* More of N4258 implementation. Mark all of our test_allocators as noexcept ↵Marshall Clow2015-06-031-0/+2
| | | | | | constructible. Make the constructors for basic_string noexcept all the time (under C++14). Update tests to reflect the new world order. More to come. llvm-svn: 238957
* Bug #19473. If you pass an allocator to std::function, we should use that ↵Marshall Clow2014-04-181-0/+60
| | | | | | allocator, not construct one from scratch. Add a test to make sure llvm-svn: 206623
* Add license headers to a bunch of libc++ files that were missing them. No ↵Marshall Clow2014-01-161-0/+9
| | | | | | functionality change. Fixes 18291. Thanks to Nico for the bug report and the patch. llvm-svn: 199400
* Found six (nmostly) identical files named 'test_allocator.h' in the libcxx ↵Marshall Clow2013-12-031-0/+155
test suite. Moved one to /support, made it a superset, and removed all but one of the others, and iupdated all the includes. Left the odd one (thread/futures/test_allocator.h) for later. llvm-svn: 196174
OpenPOWER on IntegriCloud