Commit Graph

2544 Commits

Author SHA1 Message Date
Eric Fiselier
df46b78ce7 Fix LWG issue #2106: move_iterators returning prvalues
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267091 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22 00:49:12 +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
a6013cc92f Make ios_base::failure visibility specified consistent
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267076 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21 23:00:33 +00:00
Eric Fiselier
566bcb4bad Fix most GCC attribute ignored warnings
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267074 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21 22:54:21 +00:00
Weiming Zhao
994fb967d3 [libc++] fix macro redef warning when exception is disabled
Summary:
 when setting LIBCXX_ENABLE_EXCEPTIONS=false, _LIBCPP_NO_EXCEPTIONS wil be defined in both commandline and _config

Reviewers: bcraig, EricWF

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266956 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21 05:28:18 +00:00
Eric Fiselier
cf4550d351 Add cxx_runtime_root options for testing against a different libc++ at runtime
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266855 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20 04:17:39 +00:00
Eric Fiselier
e94c1aee2b [libcxx] Fix PR15638 - Only allocate in parent when starting a thread to prevent calling terminate.
Summary:
Hi,

When creating a new thread libc++ performs at least 2 allocations. The first allocates a tuple of args and the functor that will be passed to the new thread. The second allocation is for the thread local storage needed internally by libc++. Currently the second allocation happens in the child thread, meaning that if it throws the program will terminate with an uncaught bad alloc.

The solution to this is to allocate ALL memory in the parent thread and then pass it to the child.

See https://llvm.org/bugs/show_bug.cgi?id=15638

Reviewers: mclow.lists, danalbert, jroelofs, EricWF

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266851 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20 02:21:33 +00:00
Eric Fiselier
8d5cbd7ce2 Add 'is_callable' and 'is_nothrow_callable' traits and cleanup INVOKE.
The primary purpose of this patch is to add the 'is_callable' traits.
Since 'is_nothrow_callable' required making 'INVOKE' conditionally noexcept
I also took this oppertunity to implement a constexpr version of INVOKE.
This fixes 'std::experimental::apply' which required constexpr 'INVOKE support'.

This patch will be followed up with some cleanup. Primarly removing most
of "__member_function_traits" since it's no longer used by INVOKE (in C++11 at least).


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266836 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20 00:14:32 +00:00
Ben Craig
9c6f00d616 XFAILing new test on C++03
initializer_list doesn't exist in C++03.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266820 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-19 21:07:30 +00:00
Ben Craig
d59d416bc9 Include initializer_list from utility
The C++11 and C++14 standards both say in the header <utility> synopsis that
<utility> shall include <initializer_list>.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266808 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-19 20:13:55 +00:00
Ben Craig
611ab2b462 Framework to allow testing of static libc++abi
These changes make linking against static libraries more explicit. Instead
of using -lc++ and -lc++abi in the tests, an absolute path to the library is
provided instead.

The choices of shared vs. static, and the choices of library paths for both
libcxx and libcxxabi needed to be exchanged for this to work. In other words,
libcxx tests need to know the library path of libcxxabi, and whether libcxxabi
is a static or shared library.

Some Mac specific logic for testing against libc++abi had to be moved from
libcxxabi's config.py, as it was overriding choices made in libcxx's config.py.
That logic is now in libcxx's target_info.py.

Testing a static libcxx on Linux will now automatically link in librt most of
the time. Previously, lots of pthread tests would fail because of an
unresolved clock_gettime.

http://reviews.llvm.org/D16544


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266730 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-19 12:49:05 +00:00
Eric Fiselier
95526d31cb Make tuples constructors conditionally EXPLICIT. See N4387
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266703 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-19 01:19:25 +00:00
Eric Fiselier
1350927628 Mark P0152R1 as complete.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266592 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 06:58:50 +00:00
Eric Fiselier
2e37f92b52 Mark LWG issue 2469 as done. Also simplify try_emplace and insert_or_assign implementations in unordered_map
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266591 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 06:51:33 +00:00
Eric Fiselier
134ff65b8f Implement LWG issue 2219 - support reference_wrapper in INVOKE
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266590 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 06:17:30 +00:00
Eric Fiselier
b952822a48 Add hash specializations for __int128_t. Fixes LWG issue 2119
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266587 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 02:54:00 +00:00
Eric Fiselier
c325f3dccf Add tests for LWG issue 2361
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266586 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 02:31:05 +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
Eric Fiselier
d5019333fa Cleanup and guard tuple's constructor SFINAE. Fixes PR22806 and PR23256.
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)

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266461 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 18:05:59 +00:00
Eric Fiselier
55ad3ac786 [libcxx] Remove the "reduced-arity-initialization" extension from the 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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266409 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 03:29:40 +00:00
Marshall Clow
8165249d39 Qualify calls to addressof to avoid getting ADL. Fixes PR#27254.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266209 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 17:02:23 +00:00
Marshall Clow
dca800cd0f Implement LWG#680, which was missed lo these many moons ago, and was reported as bug #27259. As a drive-by fix, replace the hand-rolled equivalent to addressof in __wrap_iter with the real thing.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@265914 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 03:54:53 +00:00
Eric Fiselier
547d4a0764 Update filesystem status
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@265856 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 21:52:32 +00:00
Marshall Clow
f4f7d8fc96 Recommit r263036 with additional inlining, so that it will continue to work with existing system dylibs. Implements LWG#2583
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@265706 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 18:13:41 +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
Marshall Clow
32c9099aac Remove unused internal routines. No functional change
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@265363 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 23:23:35 +00:00
Marshall Clow
5f9110c961 Put back the undefs that Richard removed. Boost won't build w/o these; specifically the file 'bytes_methods.h' in Apple's python framework defines these.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@265358 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 22:49:20 +00:00
Marshall Clow
a27781113c Fix for Bug #27193; 'std::acos on complex does not agree with C'. Tests need work; so the bug will stay open.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@265306 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 16:08:54 +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
Paul Robinson
e7931f9d92 Update copyright year to 2016.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@264950 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 22:39:53 +00:00
JF Bastien
08511cda39 Implement is_always_lock_free
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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@264413 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 15:48:21 +00:00
Richard Barton
037efda0ac Guard a number of tests relying on threads support when built in
single-threaded mode.

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



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@264191 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-23 21:04:11 +00:00
JF Bastien
4c51222b28 Missing ATOMIC_*_LOCK_FREE tests
Forked from D17951, these tests should have been there but weren't.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263798 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-18 17:48:58 +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
Eric Fiselier
735026e3ee Make std::addressof constexpr in C++17 (Clang only).
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263688 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-17 03:30:56 +00:00
Eric Fiselier
8b15aee1a1 Add __unconstref for future use
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263659 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-16 20:32:07 +00:00
Eric Fiselier
a15e8c3a18 Add clang thread safety annotations to mutex and lock_guard. Patch by jamesr@google.com.
This adds clang thread safety annotations to std::mutex and
std::lock_guard so code using these types can use these types directly
instead of having to wrap the types to provide annotations. These checks
when enabled by -Wthread-safety provide simple but useful static
checking to detect potential race conditions.
See http://clang.llvm.org/docs/ThreadSafetyAnalysis.html for details.

This patch was reviewed in http://reviews.llvm.org/D14731.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263611 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-16 02:30:06 +00:00
Jonas Hahnfeld
3614681995 [libcxx] Remove localization tests for Russian month names
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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263554 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-15 15:55:58 +00:00
Marshall Clow
d124b5b45d Missed this file in previous checkin
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263507 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-14 23:07:58 +00:00
Marshall Clow
e22d9e58d3 Implement LWG2577: {shared,unique}_lock</tt> should use std::addressof
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263506 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-14 23:07:32 +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
d8b9e0bbff Mark exception-throwing test as XFAIL when exceptions are disabled
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263405 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-14 02:51:50 +00:00