Commit Graph

907 Commits

Author SHA1 Message Date
Eric Fiselier
b9536101dc NFC. Move definition of _LIBCPP_ASSERT into __debug header and remove external include guards.
Things done in this patch:

1. Make __debug include __config since it uses macros from it.

2. The current method of defining _LIBCPP_ASSERT is prone to redefinitions. Move
the null _LIBCPP_ASSERT definition into the __debug header to prevent this.

3. Remove external <__debug> include gaurds. <__debug> guards almost all of its
contents internally. There is no reason to be doing it externally.

This patch should not change any functionality.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@215332 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-10 23:53:08 +00:00
Eric Fiselier
67740670f9 NFC. Remove trailing whitespace and tabs.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@215326 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-10 20:56:31 +00:00
Dan Albert
e8b4232e33 Emulate clang atomic built-ins on gcc > 4.7
gcc 4.7 and above has atomic built-ins which slightly different APIs
from those provided by clang. Add proxy functions that wrap the gcc
built-ins to produce a symbol that is API equivalent to the clang
built-ins. This allows libc++'s atomic library to be used with gcc-4.7
and newer.

Patch contributed by Albert Wong.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@215305 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-09 23:51:51 +00:00
Marshall Clow
095c3dd23e Apply a similar fix to <forward_list> as I did for <list> in r215210. Again, thanks to Ion Gaztañaga for noticing this problem w.r.t LWG#526
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@215213 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 15:58:00 +00:00
Marshall Clow
fca038e133 While reading LWG#526, Ion Gaztañaga noticed that libc++ didn't correctly handle list::remove(const value_type &x), if x was an element of the list. Added a test for this, and a fix. Thanks to Ion for the report.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@215210 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 15:35:52 +00:00
Marshall Clow
ea8ed833fe dit pointed out on IRC that '__i = _VSTD::next(__i)' was a very long-winded way of writing '++__i'. Since I hate being thought of as long-winded (this checkin comment notwithstanding), I fixed it. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@214834 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-05 01:34:12 +00:00
Marshall Clow
529d303340 Fix a problem with reference_wrapper in C++03 that was causing counting predicates to fail. Add a test to make sure it works. However, most of the reference_wrapper tests still fail in C++03 mode, due to a lack of decltype. No change there.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@214760 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-04 19:20:17 +00:00
Marshall Clow
f0f1bca861 Fix PR#202520 - predicate called too many times in list::remove_if. Add tests for list, forward_list, and the std::remove_if algorithm
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@214736 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-04 17:32:25 +00:00
Dan Albert
3ab406107d Make Android's ctype_base::mask unsigned.
Keeping the regex code sane is much easier if we match the other
platforms and use an unsigned mask.



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@214442 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 21:04:08 +00:00
Eric Fiselier
6f8821df70 [libcxx] Remove use of default function template parameters in type traits. Fixes DR20484
Summary: This patch moves the SFINAE for __is_destructor_welformed out of the function template parameters. type_traits must compile in c++03 mode since it is included in c++03 headers. 

Test Plan: No tests have been added.

Reviewers: danalbert, mclow.lists

Reviewed By: danalbert

Subscribers: K-ballo, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@214422 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 19:09:26 +00:00
Marshall Clow
15269a8796 Fix numeric_limits<XXX>::is_modulo for signed arithmetic types. We were reporting true, for all arithmetic types, which is incorrect. Fix the tests which were wrong, too. This fixes PR#20158.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@214371 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 01:18:05 +00:00
Marshall Clow
05d116eb87 std::once_flag was forward declared with _LIBCPP_TYPE_VIS decoration, and the defined with _LIBCPP_TYPE_VIS_ONLY decoration. Make them match
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@214219 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-29 21:05:31 +00:00
Dan Albert
1757386944 Base regex code on char_class_type.
__get_classname() and __bracket_expression were assuming that
char_class_type was ctype_base::mask rather than using
regex_traits<_CharT>::char_class_type.

This change allows char_class_type to be defined to something other than
ctype_base::mask so that the implementation will still work for
platforms with an 8-bit ctype mask (such as Android and OpenBSD).


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@214201 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-29 19:23:39 +00:00
Marshall Clow
0d1965d8c2 Fix PR#20471. Add a cast in __align_it to ensure that the bit twiddling is done at the correct size. A better solution, IMHO, would be to declare vector<bool>::__bits_per_word as 'size_type', rather than 'unsigned', but that's a possible ABI change.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@214088 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-28 15:02:42 +00:00
Eric Fiselier
3ee7233c80 [libcxx] expose experimental::erased_type for all standard versions.
Summary: The polymorphic allocator implementation would greatly benefit by defining virtual functions in the dynlib instead of inline. In order to do that some types are going to have to be available outside of c++1y. This is the first step.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213889 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-24 19:17:38 +00:00
Eric Fiselier
9020c08989 D4451: Fix copy/move issues casude by __tuple_leafs's converting constructor
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213888 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-24 18:48:34 +00:00
Dan Albert
2a52a3237f Fix ctype_base::xdigit for Android.
Android's ctype implementation comes from openbsd, which for some reason
doesn't consider numbers to be hex digits.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213785 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-23 19:32:03 +00:00
Marshall Clow
de2404b16c Update the synopsis and comments with the results of LWG #2255. No code to back it up at the moment; just comments
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213768 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-23 16:58:25 +00:00
David Majnemer
cb8757aca7 Fix std::make_heap's worst case time complexity
std::make_heap is currently implemented by iteratively applying a
siftup-type algorithm.  Since sift-up is O(ln n), this gives
std::make_heap a worst case time complexity of O(n ln n).

The C++ standard mandates that std::make_heap make no more than O(3n)
comparisons, this makes our std::make_heap out of spec.

Fix this by introducing an implementation of __sift_down and switch
std::make_heap to create the heap using it.
This gives std::make_heap linear time complexity in the worst case.

This fixes PR20161.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213615 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-22 06:07:09 +00:00
Marshall Clow
db5e54d2a3 make the same change as in 213546 for vector<bool>
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213547 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-21 15:15:15 +00:00
Marshall Clow
3c2eac62c3 In response to bug #20362, change the order of operations in vector move assignment so that if the allocator move assignment throws, we aren't left with two objects pointing at the same memory. This is not a complete fix; I am unconvinced that a complete fix is possible. With this change in place, we will leak the old contents of the vector. LWG issue #2106, when adopted, will make this problem illegal. Thanks to Thomas Koeppe for the report and analysis.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213546 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-21 15:11:13 +00:00
Marshall Clow
d5549ccac1 Fix bug #20335 - memory leak when move-constructing a string with unequal allocator. Thanks to Thomas Koeppe for the report
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213269 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-17 15:32:20 +00:00
Eric Fiselier
b1a40264dc [libcxx] Add <experimental/utility> header for LFTS.
Summary:
This patch adds the `<experimental/utility>` header as specified in the latest draft of the library fundamentals TS.

`<experimental/utility>` only contains `class erased_type`. 

This patch also updates the documentation to list the `erased_type` class as "initial implementation complete".

Test Plan:
Three test cases where added:

1. Test that `_LIBCPP_VERSION` is defined.
2. Test that `<utility>` has been included.
3. Test that `erased_type` is in the correct namespace and is constexpr default constructible.

Reviewers: mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213226 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-17 05:31:31 +00:00
Eric Fiselier
8fcc27286f Change _LIBCXX_CONSTEXPR_AFTER_CXX11 to check for c++14 constexpr rules
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213225 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-17 05:16:18 +00:00
Marshall Clow
2b44e3dd49 Correctly implement LWG 2049; std::is_destructible.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213163 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-16 15:51:50 +00:00
Saleem Abdulrasool
7ef03b79f9 Change Windows decoration on some base classes
Mark the base classes for time_get_byname and time_get as _LIBCPP_TYPE_VIS_ONLY
rather than _LIBCPP_TYPE_VIS.  These base classes are templated types and cannot
be stored with export dll storage.

Fixes compilation with _LIBCPP_DLL for Windows when the time_get and
time_get_byname classes are used.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213116 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-16 01:00:26 +00:00
Marshall Clow
48e7e9f403 Support the built-in type-trait support in gcc 4.7 and later. Thanks to Albert Wong for the patch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@212727 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-10 15:38:20 +00:00
Marshall Clow
a64392627e Add support for BIONIC C library (Android). Patch from Dan Albert
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@212724 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-10 15:20:28 +00:00
Marshall Clow
484728789e string_view enhancements. Move to the correct namespace. Better constexpr support (thanks to Richard for the suggestions). Update the tests to match this. Add <experimental/__config for experimental macros/etc to live.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@212569 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-08 22:38:11 +00:00
Marshall Clow
3a61b30f3a Minor cleanup for string_view; mostly from suggestions by Richard Smith. Also, make the tests pass under c++03
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@212185 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-02 15:45:57 +00:00
Marshall Clow
2f9e714071 Fix libc++ bug #20039: 'Constructing std::function from empty compatible std::function results in half-empty state' Thanks to Agustin Berge for the report, and for his and Eric Fiselier's work on a fix.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@212070 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-30 21:27:51 +00:00
Marshall Clow
394451db81 Fix a typo in the noexcept calculation for __compressed_pair::swap. Thanks to EricWF for the bug report and the fix.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@212046 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-30 15:35:09 +00:00
Marshall Clow
81aa3a745c Patch from Albert J. Wong to make type_traits take advantage of gcc intrinsics in 4.7 and later. No functionality change when using clang.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@211755 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 01:07:56 +00:00
David Fang
44ead61237 eliminate install of duplicate headers (take 2)
Patch by Ryuta Suzuki

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@211629 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-24 20:32:11 +00:00
Marshall Clow
ba6dbf4866 Some calls to get<>() were qualified. Some were not. Qualify them all. Fixes bug #20092. Thanks to Agustín Bergé for the bug report and the fix.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@211563 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-24 00:46:19 +00:00
Marshall Clow
e4694b4129 Formatting improvements in the <string_view> synopsis suggested by RSmith. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@211191 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-18 17:44:04 +00:00
Marshall Clow
164b297099 Implement string_view from the library fundamentals TS (n4023). Also works in C++11 and 03, with reduced functionality (mostly in the area of constexpr)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@210659 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11 16:44:55 +00:00
Marshall Clow
37025e1b32 Make the helper routines in string really be constexpr. This required a bit of refacoring in algorithm as well. Give them better names while we're at it. All of these are internal rotines; no visible functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@210561 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-10 18:51:55 +00:00
Marshall Clow
20f0955062 Since we now have a value for __cplusplus for c++14, teach libc++ about it
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@210380 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-06 22:31:09 +00:00
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