Commit Graph

22 Commits

Author SHA1 Message Date
Chandler Carruth
7c3769df62 Update more file headers across all of the LLVM projects in the monorepo
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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@351648 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 10:56:40 +00:00
Eric Fiselier
301518c94e Fix PR37694 - std::vector doesn't correctly move construct allocators.
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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@334053 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-05 22:32:52 +00:00
Eric Fiselier
11f64dcc58 Fix undefined behavior in container swap tests.
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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289358 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-11 03:41:12 +00:00
Eric Fiselier
e5bca2ba66 Fix more uses of dynamic exception specifications in C++17
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289356 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-11 02:47:36 +00:00
Eric Fiselier
e041941007 Fix __hash_table::max_size() on 32 bit systems
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@287749 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-23 09:16:12 +00:00
Eric Fiselier
ef3060ef96 [libcxx] Fix max_size() across all containers
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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@287729 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-23 01:18:56 +00:00
Eric Fiselier
c69d8ca589 Correctly grant rebound limited_allocators friendship.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284006 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 11:35:37 +00:00
Eric Fiselier
ef9e52bc90 Add missing include in test_allocator.h
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283632 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-08 00:57:56 +00:00
Eric Fiselier
124ed406e5 [libc++] Fix stack_allocator
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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283631 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-08 00:56:22 +00:00
Eric Fiselier
45a9570f5d Remove MSVC workarounds. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283580 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-07 18:51:33 +00:00
Eric Fiselier
4e3e15ad99 [libc++] Remove various C++03 feature test macros
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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@282347 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-25 03:34:28 +00:00
Eric Fiselier
29bb84bd57 Silence another occurrence of MSVC's suprious unused warning. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@277572 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03 05:46:36 +00:00
Marshall Clow
51d7e8e381 Always use the allocator to construct/destruct elements of a deque/vector. Fixes PR#28412. Thanks to Jonathan Wakely for the report.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@275105 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11 21:38:08 +00:00
Eric Fiselier
ff58059a86 Suppress stupid and incorrect MSVC warning. patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273350 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 01:02:08 +00:00
Eric Fiselier
629aa5670a [libcxx] [test] In test/support/test_allocator.h, fix construct() to avoid 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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272747 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-15 01:53:32 +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
5ec04a92d2 Fix bug in test_allocator<void> that used the wrong value to represent object state
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246270 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-28 05:00:25 +00:00
Eric Fiselier
b05f0599c0 Fix std::function allocator constructors in C++03.
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.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@239708 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-14 23:30:09 +00:00
Marshall Clow
7b193f7797 More of N4258 implementation. Mark all of our test_allocators as noexcept 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@238957 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-03 19:56:43 +00:00
Marshall Clow
a178c13419 Bug #19473. If you pass an allocator to std::function, we should use that allocator, not construct one from scratch. Add a test to make sure
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@206623 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-18 17:23:36 +00:00
Marshall Clow
98760c18f8 Add license headers to a bunch of libc++ files that were missing them. No functionality change. Fixes 18291. Thanks to Nico for the bug report and the patch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@199400 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16 16:58:45 +00:00
Marshall Clow
1b92188a82 Found six (nmostly) identical files named 'test_allocator.h' in the libcxx 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@196174 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-03 00:18:10 +00:00