Commit Graph

1166 Commits

Author SHA1 Message Date
Marshall Clow
70e8f59884 Fix a crasher found by libFuzzer
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245849 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-24 15:57:09 +00:00
Eric Fiselier
bb2f28e15d Recommit rL245802: Cleanup fancy pointer rebinding in list using __rebind_pointer.
Currently we need an #ifdef branch every time we use pointer traits to rebind a pointer because
it is done differently in C++11 and C++03. This patch introduces the __rebind_pointer utility to
clean this up.

Also add a test that list and it's iterators can be instantiated with incomplete element types.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245806 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-23 02:56:05 +00:00
Eric Fiselier
d686dda62e Revert r245802. It violates the incomplete type requirements.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245805 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-23 02:39:20 +00:00
Eric Fiselier
a276cb01be Cleanup fancy pointer rebinding in list using __rebind_pointer.
Currently we need an #ifdef branch every time we use pointer traits to rebind a pointer because
it is done differently in C++11 and C++03. This patch introduces the __rebind_pointer utility to
clean this up. 

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245802 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-23 02:34:18 +00:00
Eric Fiselier
de56f74611 [libcxx] Add "install-libcxx" target.
Summary: Currently you can't install libc++ from within the LLVM tree without installing all of LLVM. This patch adds an install rule for libc++.

Reviewers: mclow.lists, danalbert, jroelofs, EricWF

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245470 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 17:41:53 +00:00
Eric Fiselier
00f4a49b0b [libcxx] Allow use of <atomic> in C++03. Try 3.
Summary:
After putting this question up on cfe-dev I have decided that it would be best to allow the use of `<atomic>` in C++03. Although static initialization is a concern the syntax required to get it is C++11 only. Meaning that C++11 constant static initialization cannot silently break in C++03, it will always cause a syntax error. Furthermore `ATOMIC_VAR_INIT` and `ATOMIC_FLAG_INIT` remain defined in C++03 even though they cannot be used because C++03 usages will cause better error messages.

The main change in this patch is to replace `__has_feature(cxx_atomic)`, which only returns true when C++ >= 11, to `__has_extension(c_atomic)` which returns true whenever clang supports the required atomic builtins.


This patch adds the following macros:
* `_LIBCPP_HAS_C_ATOMIC_IMP`      - Defined on clang versions which provide the C `_Atomic` keyword.
* `_LIBCPP_HAS_GCC_ATOMIC_IMP` - Defined on GCC > 4.7. We must use the fallback atomic implementation.
* `_LIBCPP_HAS_NO_ATOMIC_HEADER` - Defined when it is not safe to include `<atomic>`.

`_LIBCPP_HAS_C_ATOMIC_IMP` and `_LIBCPP_HAS_GCC_ATOMIC_IMP` are mutually exclusive, only one should be defined. If neither is defined then `<atomic>` is not implemented and including `<atomic>` will issue an error.

Reviewers: chandlerc, jroelofs, mclow.lists

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245463 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 17:21:46 +00:00
Dimitry Andric
8966350d61 Fix warnings about pessimizing return moves for C++11 and higher
Summary:
Throughout the libc++ headers, there are a few instances where
_VSTD::move() is used to return a local variable.  Howard commented in
r189039 that these were there "for non-obvious reasons such as to help
things limp along in C++03 language mode".

However, when compiling these headers with warnings on, and in C++11 or
higher mode (like we do in FreeBSD), they cause the following complaints
about pessimizing moves:

    In file included from tests.cpp:26:
    In file included from tests.hpp:29:
    /usr/include/c++/v1/map:1368:12: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]
        return _VSTD::move(__h);  // explicitly moved for C++03
               ^
    /usr/include/c++/v1/__config:368:15: note: expanded from macro '_VSTD'
    #define _VSTD std::_LIBCPP_NAMESPACE
                  ^

Attempt to fix this by adding a _LIBCPP_EXPLICIT_MOVE() macro to
__config, which gets defined to _VSTD::move for pre-C++11, and to
nothing for C++11 and later.

I am not completely satisfied with the macro name (I also considered
_LIBCPP_COMPAT_MOVE and some other variants), so suggestions are
welcome. :)

Reviewers: mclow.lists, howard.hinnant, EricWF

Subscribers: arthur.j.odwyer, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245421 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 06:43:33 +00:00
Eric Fiselier
a8dca5f978 Remove commented out TODOs. They defined unneeded methods.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245411 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 03:48:08 +00:00
Eric Fiselier
f99b59c784 Fix use of static_assert macro with nested commas
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245410 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 03:38:41 +00:00
Marshall Clow
d434e2a535 Broke C++03 compatibility in 245330. Fix that.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245336 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-18 19:51:37 +00:00
Eric Fiselier
8e030714ff [libcxx] Fix PR23589: std::function doesn't recognize null pointer to varargs function.
Summary:
This patch fixes __not_null's detection of nullptr by breaking it down into 4 cases.

1. `__not_null(Tp const&)`: Default case. Tp is not null.
2. `__not_null(Tp* __ptr);` Case for pointers to functions.
3. `__not_null(_Ret _Class::* __ptr);` Case for pointers to members.
4. `__not_null(function<Tp> const&);`: Cases for other std::functions.

Reviewers: mclow.lists

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245335 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-18 19:41:51 +00:00
Eric Fiselier
0376dfaca0 [libc++] Fix PR22606 - Leak pthread_key with static storage duration to ensure all of thread-local destructors are called.
Summary:
See https://llvm.org/bugs/show_bug.cgi?id=22606 for more discussion.

Most of the changes in this patch are file reorganization to help ensure assumptions about how __thread_specific_pointer is used hold. The assumptions are:

* `__thread_specific_ptr<Tp>` is only created with a `__thread_struct` pointer.
* `__thread_specific_ptr<Tp>` can only be constructed inside the `__thread_local_data()` function.

I'll remove the comments before committing. They are there for clarity during review.

Reviewers: earthdok, mclow.lists

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245334 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-18 19:40:38 +00:00
Eric Fiselier
85d45f6c0d [libcxx] Disable -Wnon-virtual-dtor warning in <locale>
Summary:
Normally people won't see warnings in libc++ headers, but if they compile with "-Wsystem-headers -Wnon-virtual-dtor" they will likely see issues in <locale>.

In the libc++ implementation `time_get' has a private base class, `__time_get_c_storage`, with virtual methods but a non-virtual destructor. 
`time_get` itself can safely be used as a polymorphic base class because it inherits a virtual destructor from `locale::facet`. To placate the compiler we change `__time_get_c_storage`'s destructor from public to protected, ensuring that it will never be deleted polymorphically.

Reviewers: mclow.lists

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245333 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-18 19:39:35 +00:00
Marshall Clow
af961ed8cf implement more of N4258 - Cleaning up noexcept in the standard library. Specifically add new noexcept stuff to vector and string's move-assignment operations
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245330 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-18 18:57:00 +00:00
Marshall Clow
fc93ce7349 Make regex and any assert when they should throw an exception _but_ the user has decreed 'no exceptions'. This matches the behavior of string and vector
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245239 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-17 21:14:16 +00:00
Joerg Sonnenberger
ba865ff66b Protect template argument from user interference.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@244462 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-10 16:58:04 +00:00
Marshall Clow
9a3c689b8a Change char_traits<char16_t>::eof() to return 0xFFFF instead of 0xDFFF. Fixes PR#24342
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243937 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-04 01:38:34 +00:00
Eric Fiselier
65a1d45c0a Mark any as done and comment out extra methods until speaking to Marshall
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243729 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-31 02:29:11 +00:00
Eric Fiselier
7175a07921 [libcxx] Add <experimental/any> v2.
Summary:
This patch adds the second revision of <experimental/any>. 
I've been working from the LFTS draft found at this link. https://rawgit.com/cplusplus/fundamentals-ts/v1/fundamentals-ts.html#any



Reviewers: danalbert, jroelofs, K-ballo, mclow.lists

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243728 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-31 02:24:58 +00:00
Marshall Clow
0934c750ed Fix PR#24267. use numeric_limits::max instead of ~0 for 'all ones', since that might give wrong answers on a 1's complement machine.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243674 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-30 18:26:34 +00:00
Nick Lewycky
e1be30b7e1 Fix typo in unused variable name.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243586 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-29 22:38:23 +00:00
Marshall Clow
a37957634c Fix a self-move bug in inplace_merge. Thanks to Ted and Dexon for the report and the suggested fix.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243530 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-29 16:25:45 +00:00
Marshall Clow
2576c29dab Consolidate a bunch of #ifdef _LIBCPP_NO_EXCEPTIONS .. #endif blocks into a single template function. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243415 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28 13:30:47 +00:00
Eric Fiselier
bfb46e486d Cleanup C++03 __invoke for Bullets 3 and 4.
The key changes in this patch are:

1. Remove the zero-argument overload in mem_fn. A member function must always
   be invoked with at least one argument, the class instance. The zero-argument
   operator()() in mem_fn would cause mem_fn to fail to compile when because
   the call to '__invoke(pm)' is not well formed.

2. Prevent evaluation of '__apply_cv<Tp, Ret>' when 'Ret' is a function type.
   'Ret' is a function type whenever 'Ret Tp::*' is a pointer to member function.
   Attempting to add cv and ref qualifiers to a function type can cause a hard
   compile error.

3. Remove the dummy overload __invoke(Rp Tp::*). It was present to help work
   around #1. It will be replaced with a different '__invoke' overload that
   represents a bad call to invoke.

After applying this patch the test func.wrap.func.inv/invoke.pass.cpp now
passes.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243370 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28 02:15:53 +00:00
Eric Fiselier
12ddf2cbd2 Get C++03 __invoke working for bullet 5 of INVOKE.
This patch does a couple of things to get __invoke working for free-functions
and call objects.

1. Turn all uses of declval<Tp>() into declval<Tp&>(). The C++03 __invoke only
   supports lvalues but it will be used when the compiler supports rvalue
   references but not variadic templates. This change makes sure we don't
   generate an rvalue.

2. Call objects for bullet 5 are now passed by reference and not value. Copying
   the functor is incorrect. It will fail to compile for non-copyable functors
   and it will discard cv-qualifiers on the call object, possibly leading to the
   wrong function being called. I suspect that the reason the call object
   was originally taken by value was to support temporary call objects.
   However __invoke is only used internally and it is never given a temporary.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243368 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28 01:52:08 +00:00
Marshall Clow
568bd0222f Detect and throw on a class of bad regexes that we mistakenly accepted before. Thanks to Trevor Smigiel for the report
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243030 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 18:27:51 +00:00
Eric Fiselier
db8c4fd8c7 Merge C++03 and C++11 implementations of mem_fn and __mem_fn.
The implementation of mem_fn doesn't actually require any  C++11 support.
For some reason there were 17 overloads for mem_fn in C++03 when only one
is needed. This patch removes the extra overloads and uses the same implementation
of mem_fn in C++03 and C++11.

__mem_fn does require variadics to implement the call operator. Instead of
having two entirely different implementations of the __mem_fn struct, this patch
uses the same __mem_fn struct but provides different call operators when
variadics are not available.

The only thing left in <__functional_03> is the C++03 implementation of
std::function.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242959 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 22:43:27 +00:00
Eric Fiselier
5b3a4593da Remove almost everything in <__functional_base_03>
This patch removes a large amount of duplicate code found in both
<__functional_base> and <__functional_base_03>. The only code that remains
in <__functional_base_03> is the C++03 implementation of __invoke and
__invoke_return.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242951 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 22:23:49 +00:00
Eric Fiselier
9962ddfa24 Remove more commented out code. That is what version control is for.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242872 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 04:37:12 +00:00
Eric Fiselier
45f63bc07e Cleanup <__functional_03>
<__functional_03> provides the C++03 definitions for std::memfun and
std::function. However the interaction between <functional> and <__functional_03>
is ugly and duplicates code needlessly. This patch cleans up how the two
headers work together.

The major changes are:

- Provide placeholders, is_bind_expression and is_placeholder in <functional>
  for both C++03 and C++11.

- Provide bad_function_call, function fwd decl,
  __maybe_derive_from_unary_function and __maybe_derive_from_binary_function
  in <functional> for both C++03 and C++11.

- Move the <__functional_03> include to the bottom of <functional>. This makes
  it easier to see how <__functional_03> interacts with <functional>

- Remove a commented out implementation of bind in C++03. It's never going
  to get implemented.

- Mark almost all std::bind tests as unsupported in C++03. std::is_placeholder
  works in C++03 and C++11. std::is_bind_expression is provided in C++03 but
  always returns false.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242870 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 04:14:38 +00:00
Eric Fiselier
7cc7106776 Fix initializer list order in <regex> to be correct
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242864 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 01:29:41 +00:00
Marshall Clow
bbe4245e63 Implement the default searcher for std::experimental::search.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242682 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 16:39:28 +00:00
Marshall Clow
166dadbcbe Implement the plugin-based version of std::search. There are no searchers yet; those are coming soon.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242679 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 15:40:27 +00:00
Eric Fiselier
18dbed9596 Fix warnings in deque tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242632 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-19 00:31:54 +00:00
Eric Fiselier
02bb4bdb49 Fix warnings in array and assoc containers
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242629 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-18 23:56:04 +00:00
Eric Fiselier
47c5dae573 Remove unused typedefs in random and regex
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242628 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-18 22:57:14 +00:00
Eric Fiselier
692177d022 Enable and fix warnings during the build.
Although CMake adds warning flags, they are ignored in the libc++ headers
because the headers '#pragma system header' themselves.

This patch disables the system header pragma when building libc++ and fixes
the warnings that arose.

The warnings fixed were:
1. <memory> - anonymous structs are a GNU extension
2. <functional> - anonymous structs are a GNU extension.
3. <__hash_table> - Embedded preprocessor directives have undefined behavior.
4. <string> - Definition is missing noexcept from declaration.
5. <__std_stream> - Unused variable.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242623 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-18 20:40:46 +00:00
Eric Fiselier
7d439a455d Add missing instrumentation in vector::insert - Patch from Anna Zaks
This patch was reviewed as D10859. http://reviews.llvm.org/D10859


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242617 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-18 18:22:12 +00:00
Eric Fiselier
12c6d9cd93 [libcxx] Get is_*_destructible tests passing in C++03.
Summary: This patch adds proper guards to the is_destructible tests depending on the standard version so that they pass in c++03.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242612 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-18 16:43:58 +00:00
Marshall Clow
40853eac80 Bump libc++ version # to 3.8
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242541 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-17 16:36:44 +00:00
Marshall Clow
7efdd69688 Set the libc++ version # to 3.7. Will bump to 3.8 soon
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242421 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-16 17:22:24 +00:00
Marshall Clow
cd6ed54fed Make sure that __libcpp_compressed_pair_imp default-constructs its' members, rather than value-initializing them. Fixes PR#24137
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242377 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-16 03:05:06 +00:00
Eric Fiselier
22dff5382a Implement n4169 - Add invoke function template
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242195 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 20:16:15 +00:00
Eric Fiselier
26edd804ba Fix PR24114 - std::atomic for non-Clang is not a literal type
Add _LIBCPP_CONSTEXPR to the implementation of __gcc_atomic_t.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242172 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 17:50:27 +00:00
Marshall Clow
119ed47999 Move bits from N4258. Mark vector's move-constructor unconditionally noexcept in C++1z
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242148 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 14:46:32 +00:00
Marshall Clow
7d914d1bff Implement the first part of N4258: 'Cleaning up noexcept in the Library'. This patch deals with swapping containers, and implements a more strict noexcept specification (a conforming extension) than the standard mandates.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242056 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13 20:04:56 +00:00
Eric Fiselier
f301a117e1 [libcxx] LWG2420 bits for bind<void> - Patch from K-Ballo
Implemented LWG2420 bits for bind<void>

Review: http://reviews.llvm.org/D10997


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@241967 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-10 23:29:18 +00:00
Eric Fiselier
8f7fe5cd8e Use __is_identifier to detect __decltype and not the clang version.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@241939 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-10 20:26:38 +00:00
Marshall Clow
0ce05a9f86 The rest of N4279 and LWG#2464 - for unordered_map
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@241555 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 05:45:35 +00:00
Marshall Clow
f3a1a187a1 Implement N4279 and LWG#2664 for <map>. Reviewed as http://reviews.llvm.org/D10669
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@241539 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 03:37:33 +00:00