Commit Graph

868 Commits

Author SHA1 Message Date
Richard Smith
73c1fce21c Use __builtin_operator_new/__builtin_operator_delete when available. This
allows allocations and deallocations to be optimized out.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@210211 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-04 19:54:15 +00:00
Nico Weber
0211e86a5e Make locales (and transitively, std::endl) work reliably with gcc.
libc++ currently relies on undefined initialization order of global
initializers when using gcc:

1. __start_std_streams in iostream.cpp calls locale:🆔:_init, which assigns
   an id to each locale::facet in an initializer

2. Every facet has a static locale::id id, whose constructor sets the facet's
   id to 0

If 2 runs after 1, it clobbers the facet's assigned consecutive id, causing
exceptions to be thrown when e.g. running code like "cout << endl".

To fix this, let _LIBCPP_CONSTEXPR evaluate to "constexpr" instead of nothing
with gcc.  locale::id's constructor is marked _LIBCPP_CONSTEXPR, which ensures
that it won't get an initializer that could potentially run after the
iostream.cpp initializer. (This remains broken when building with msvc.)

Also switch constexpr-specific code in bitset to use __SIZEOF_SIZE_T__ instead
of __SIZE_WIDTH__, because gcc doesn't define the latter.

Pair-programmed/debugged with Dana Jansens.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@210188 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-04 15:46:56 +00:00
Marshall Clow
360f3196d7 Preparation for <string_view>. More helper functions that can be shared between <string> and <string_view>. No functionality change
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@210002 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-02 02:22:49 +00:00
Nico Weber
3c122d81be Add a _LIBCPP_CONSTEXPR that was missed in r170026.
(clang doesn't complain about this, but gcc does.  This is necessary for a
follow-up patch that will enable _LIBCPP_CONSTEXPR for gcc.)


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@209888 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-30 12:09:47 +00:00
Marshall Clow
4f3368e269 Fix a problem exposed by r208825, which caused bind (and other bits of libc++) to stop working. And tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@209785 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-29 01:10:28 +00:00
Marshall Clow
6b7e6921e2 Fix Bug 19678 - libc++ does not correctly handle the regex: '[^\0]*'
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@209307 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-21 16:29:50 +00:00
Marshall Clow
117563c516 Fix bug 19740; round-tripping a pointer through a stream doesn't work
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@209305 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-21 16:02:20 +00:00
Richard Smith
f33ffcc651 [modules] Add initial module map for libc++.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@209265 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-21 00:33:49 +00:00
Nico Weber
7fac8f6b9f Update cstddef after clang r207606.
r207606 changed the __need_foo macros to behave like they do with gcc: If they
are set, _only_ the __need_foo stuff gets defined.  As a consequence, cstddef
no longer defined "offsetof".  It looks like the __need_foo defines aren't
needed anymore, so just remove them.

Fixes PR19723.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@208942 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-16 01:45:02 +00:00
Alp Toker
ec34c48976 Fix typos
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@208869 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-15 11:27:39 +00:00
Marshall Clow
1f50f2d64b Add Address Sanitizer support to std::vector
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@208319 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-08 14:14:06 +00:00
Marshall Clow
6b5be703db Fix PR 19663. Some calls to find(vector<bool>) were returning iterators that were subtly invalid (didn't compare equal). Thanks to Erik Verbruggen for the report (and diagnosis)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@208096 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-06 15:33:23 +00:00
Joerg Sonnenberger
55622073f4 Exceptions store the message as reference counted string for
compatibility to libstdc++. Move the implementation into a header for
easier sharing with libc++abi. Merge a number of improvements from that
version. Provide a POD definition for <stdexcept>'s public use to avoid
cast dances. Discussed with Marshall Clow.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@207695 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-30 19:54:11 +00:00
Marshall Clow
5f64a2b3c3 Fix bug #18350. Add tests for tuples of all the smart pointers (except auto_ptr)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@207307 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-26 05:19:48 +00:00
Marshall Clow
398c9d882b Default the copy and move constructors for __tuple_leaf. This fixes bugs 18853 and 19118. Add a test case for that.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@206829 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-21 23:48:09 +00:00
Marshall Clow
067e91d29e Use compiler intrinsic __is_constructible if available
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@206805 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-21 22:30:32 +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
6601516af8 Remove some unnecessary noexcept conditions. Thanks to Richard Smith for the catch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@206424 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-16 23:12:55 +00:00
Marshall Clow
7d4d519f0b Define a new macro in libc++ named '_LIBCPP_HAS_NO_ASAN'. When this is defined,
libc++ will not call address_sanitizer to detect addressing errors in the
standard library containers. This is a negative macro to enable users to
disable the libc++ checks even if they are compiling with address sanitizer
enabled by defining this macro.

At the present time, there is no code in libc++ that looks at this macro.
That will come soon. This is just infrastructure.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@206184 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-14 15:44:57 +00:00
Marshall Clow
140e8f52c3 Remove node from a container before destroying it. Thanks to Alexander Potapenko for pointing this out.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@206024 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-11 08:22:42 +00:00
Marshall Clow
f1264e7c9e Fix PR19819
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@205709 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-07 13:32:26 +00:00
Tim Northover
0835e16c6d RTTI Uniqueness: remove __name_for_load function.
It's identical to name() these days. (At one point it avoided masking
of the RTTI uniqueness bit because ARM64 ignored it architecturally,
but no longer).

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@205518 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-03 09:12:38 +00:00
Tim Northover
81339cff83 Use defined(__APPLE__) rather than __APPLE__
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@205150 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-30 14:59:12 +00:00
Tim Northover
6fdde87640 ARM64: compare RTTI names as strings
ARM64 generates RTTI with hidden visibility, which means that typeinfo
must be compared char-by-char since it's not guaranteed to be uniqued
across the whole program.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@205139 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-30 11:34:26 +00:00
Tim Northover
c030063cc2 ARM64: use the alternate string layout on Apple platforms.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@205138 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-30 11:34:22 +00:00
Stephan Tolksdorf
8a71d23633 [libc++] Teach is_integral, is_[un]signed and make_[un]signed about __[u]int128_t
This commit also adds tests for std::numeric_limits<__[u]int128_t>.

Reviewed in http://llvm-reviews.chandlerc.com/D2917

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@204849 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-26 19:45:52 +00:00
Marshall Clow
b0767852f7 Implement LWG issue #2135. If something goes wrong in condition_variable::wait, call terminate() rather than throwing an error. Do this indirectly, by marking the call as 'noexcept'. This is better than just calling terminate() directly, because it gives a better error message on the console.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@204778 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-26 02:45:04 +00:00
David Majnemer
f9f95be930 Implement N3891: A proposal to rename shared_mutex to shared_timed_mutex
This is as straightforward as it sounds, a renamed from shared_mutex to
shared_timed_mutex.

Note that libcxx .dylib and .so files built with c++14 support need to
be rebuilt.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@204078 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-17 20:19:44 +00:00
Marshall Clow
5a8e27b5b3 THIRD TIME. Richard pointed out (again) that I'd switched the order of the instance variables; and thus failed to repair the ABI break. After this, I'm going to sit down and watch TV for the evening.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@203631 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-12 01:19:36 +00:00
Marshall Clow
668a1d8c44 Fix ABI break I made in r203587; thanks to Richard Smith for the catch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@203610 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-11 22:05:31 +00:00
Marshall Clow
be3d117702 Fix misguided #elif - it checked the value of _AIX instead of defined(_AIX). Thanks to Johan Bergström for the bug report.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@203589 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-11 17:18:47 +00:00
Marshall Clow
b1ead689be Implement LWG 2360: 'reverse_iterator::operator*() is unimplementable'. Note that this is a (small) behavior change in the library. Reverse iterators whose base iterators' operator* return references to 'within themselves' have been sacrificed to the greater goal of avoiding data races.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@203587 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-11 17:16:17 +00:00
Marshall Clow
caaa1412b0 Fix bug I introduced (enabling implicit conversions from compare function to map) in r202994. Thanks to Sebastian Redl for the catch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@203443 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-10 04:50:10 +00:00
Marshall Clow
b90686c1ec Implement LWG #2344: quoted()'s interaction with padding is unclear. I think that anyone using quoted with padding is really confused, but it should work the way the rest of iostreams works.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@203290 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-07 21:45:32 +00:00
Peter Collingbourne
9d3d032c7d Do not derive __gnu_cxx::hash<T> from std::hash<T>.
Instead, define explicit specializations for the basic types listed in
the SGI documentation. This solves two problems:

 1) Helps avoid silent ODR violations caused by the absence of a
    user-supplied __gnu_cxx::hash specialization in cases where a std::hash
    specialization exists (e.g. for std::string).

 2) __gnu_cxx::hash semantics are slightly different to those of
    std::hash (for example, the former may dereference a pointer argument)
    so it is inappropriate for __gnu_cxx::hash to receive std::hash
    specializations by default.

Differential Revision: http://llvm-reviews.chandlerc.com/D2747

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@203070 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-06 04:11:10 +00:00
Marshall Clow
48c74700ec Implement LWG 2193. Default constructors for standard library containers are explicit. Note that libc++ already did this for string/deque/forward_list/list/vector and the unordered containers; implement it for set/multiset/map/multimap. Add tests for all the containers. Two drive-by fixes as well: add a missing explicit in <deque>, and remove a tab that snuck into a container test. This issue is also LLVM bug 15724, and resolves it.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202994 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-05 19:06:20 +00:00
Marshall Clow
24b29a02f1 Mark is_final as a C++14 feature.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202991 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-05 17:58:48 +00:00
Marshall Clow
0d6dcb5569 Remove definition of std::fmaf from libc++. Fixes bug #18910. This function should come from the C standard library. As a drive-by fix, update the tests to remove a warning from -Wabsolute-value
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202990 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-05 17:09:51 +00:00
Marshall Clow
ebd6c2b81d Implement LWG #2212: std::is_final. This requires compiler support, which modern versions of clang provide. Also mark LWG #2230 as complete - no code changes needed.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202934 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-05 03:39:25 +00:00
Marshall Clow
23ef151614 Update synposis in <memory> to show move semantics for weak_ptr; add tests for already existing move semantics. Mark LWG issues #2315 (no changes needed), 2316 (move semantics for weak_ptr), 2252 (previous commit) and 2271 (previous commit) as complete.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202931 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-05 03:12:04 +00:00
Marshall Clow
a93b5e27a8 Implement LWG #2268: Setting a default argument in the declaration of a member function assign of std::basic_string.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202876 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-04 19:17:19 +00:00
Peter Collingbourne
be8a99ad0f [libc++] Const qualify __gnu_cxx::hash_map<>::const_iterator::pointer type.
Differential Revision: http://llvm-reviews.chandlerc.com/D2811

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202749 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-03 19:50:01 +00:00
Marshall Clow
53c0e72d5c Implement LWG 2324: Insert iterator constructors should use addressof(). Add two new container classes to the test suite that overload operator &, and add test cases to the insert/front_insert/back_insert iterator tests that use these containers.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202741 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-03 19:20:40 +00:00
Marshall Clow
50fe0c7d61 Implement LWG Paper n3887: Consistent Metafunction Aliases. This adds std::tuple_element_t<> as an alias for tuple_element<>::type. Clean up the synopsis for tuple_element in <utility> as well.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202673 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-03 06:18:11 +00:00
Marshall Clow
3fef95b10d Per N3924, mark random_shuffle as deprecated in the synopsis for <algorithm>. Since we don't actually do anything when a call is deprecated, there is no functionality change. Maybe someday, we'll decide to warn when using a deprecated function.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202672 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-03 06:14:19 +00:00
Marshall Clow
ff137e9145 Implement LWG Issue #2285 - make_reverse_iterator. Also mark issues #1450 and #2205 as complete; they are just wording changes in the standard. Mark issues #2359, #2320 and #2322 as complete - libc++ implements them already.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202671 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-03 01:24:04 +00:00
Marshall Clow
02ca8af10b LWG issue #2188: Reverse iterator does not fully support targets that overload operator&. Also mark #2272 and #2299 as complete; libc++ already implements them.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202339 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-27 02:11:50 +00:00
Marshall Clow
103af3478e Implement LWG issue 2306: match_results::reference should be value_type&, not const value_type&. This is a general move by the LWG to have the reference type of read-only containers be a non-const reference; however, there are no methods that return a non-const reference to a match_result entry, so there's no worries about getting a non-const reference to a constant object.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202214 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-26 01:56:31 +00:00
Marshall Clow
8e554d93da Implement LWG issue 2301: Mark std::tie as constexpr
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202158 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-25 16:11:46 +00:00
Marshall Clow
4ffb67eca5 Fix historical #ifdef. Use __cplusplus instead of __GXX_EXPERIMENTAL_CXX0X__ when compiling with clang. No functionality change. Noteto self: It is important to run the regression tests on the copy of the code that you've changed.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@201938 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-22 15:13:48 +00:00