Commit Graph

2124 Commits

Author SHA1 Message Date
Eric Fiselier 92499e455e Remove test_atomic.h header
Because <atomic> can now be used in C++03 there is no need for the test_atomic.h header.
This commit removes the header and converts all usages to use <atomic> instead.

llvm-svn: 245468
2015-08-19 17:37:34 +00:00
Alexey Samsonov 0fc7892b77 Replace __asan_set_error_exit_code() with __sanitizer_set_death_callback()
Summary: We are going to remove the former soon.

Reviewers: EricWF

Subscribers: cfe-commits

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

llvm-svn: 245467
2015-08-19 17:28:01 +00:00
Eric Fiselier 749adeba3d [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

llvm-svn: 245463
2015-08-19 17:21:46 +00:00
Dimitry Andric 251c629117 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

llvm-svn: 245421
2015-08-19 06:43:33 +00:00
Eric Fiselier 9c039962ca Use TestAtomic instead of std::atomic so the test can run in C++03
llvm-svn: 245415
2015-08-19 05:00:36 +00:00
Eric Fiselier 1df02ee1f9 Mark std::packaged_task tests as unsupported in C++03.
std::packaged_task requires variadic templates and is #ifdef out in C++03.
This patch silences the tests in C++03. This patch also rewrites the .fail.cpp tests so that they use clang verify.

llvm-svn: 245413
2015-08-19 04:10:15 +00:00
Eric Fiselier 21851d2b45 Remove commented out TODOs. They defined unneeded methods.
llvm-svn: 245411
2015-08-19 03:48:08 +00:00
Eric Fiselier 9a5e62bf75 Fix use of static_assert macro with nested commas
llvm-svn: 245410
2015-08-19 03:38:41 +00:00
Eric Fiselier 10967a6ea6 [libcxx] Add Atomic test helper and fix TSAN failures.
Summary:
This patch attempts to fix the last 3 TSAN failures on the libc++ bot (http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-tsan/builds/143). This patch also adds a `Atomic` test type that can be used where `<atomic>` cannot.

`wait.exception.pass.cpp` and `wait_for.exception.pass.cpp` were failing because the test replaced `std::terminate` with `std::exit`. `std::exit` would asynchronously run the TLS and static destructors and this would cause a race condition. See PR22606 and D8802 for more details. 

This is fixed by using `_Exit` to prevent cleanup.

`notify_all_at_thread_exit.pass.cpp` exercises the same race condition but for different reasons. I fixed this test by manually joining the thread before beginning program termination.

Reviewers: EricWF, mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 245389
2015-08-18 23:29:59 +00:00
Eric Fiselier e8fd164569 Move atomic_support.h and config_elast.h into src/include
llvm-svn: 245354
2015-08-18 21:08:54 +00:00
Marshall Clow 29f11b381f Broke C++03 compatibility in 245330. Fix that.
llvm-svn: 245336
2015-08-18 19:51:37 +00:00
Eric Fiselier 0d28f78401 [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

llvm-svn: 245335
2015-08-18 19:41:51 +00:00
Eric Fiselier 4504cf2c8d [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

llvm-svn: 245334
2015-08-18 19:40:38 +00:00
Eric Fiselier 556f9340f7 [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

llvm-svn: 245333
2015-08-18 19:39:35 +00:00
Marshall Clow 1378a5aec3 implement more of N4258 - Cleaning up noexcept in the standard library. Specifically add new noexcept stuff to vector and string's move-assignment operations
llvm-svn: 245330
2015-08-18 18:57:00 +00:00
Marshall Clow 05ddbffbf3 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
llvm-svn: 245239
2015-08-17 21:14:16 +00:00
Eric Fiselier 62d526bd81 Fix CMake error whet llvm-config reports a non-existent source directory.
llvm-svn: 244717
2015-08-12 06:36:19 +00:00
Joerg Sonnenberger 08142fa6c7 Protect template argument from user interference.
llvm-svn: 244462
2015-08-10 16:58:04 +00:00
Marshall Clow 5d74bd1045 Update some links so that they don't point at the (private) WG21 Wiki
llvm-svn: 244047
2015-08-05 14:36:42 +00:00
Tanya Lattner 29f6af3657 Update references to lists.llvm.org
llvm-svn: 244003
2015-08-05 03:59:14 +00:00
Marshall Clow 2d265aee08 Change char_traits<char16_t>::eof() to return 0xFFFF instead of 0xDFFF. Fixes PR#24342
llvm-svn: 243937
2015-08-04 01:38:34 +00:00
Eric Fiselier 16bd6cbdf0 Remove -Werror when using check_cxx_compiler_flag because it was causing compiler-rt breakages.
llvm-svn: 243784
2015-07-31 21:09:38 +00:00
Eric Fiselier 5e6aa9bdeb Print message when configuring for standalone build.
llvm-svn: 243737
2015-07-31 06:08:32 +00:00
Eric Fiselier 32ad52170c Fix failing unique_ptr tests.
When I was refactoring the unique_ptr.single.ctor tests I added a test
deleter, 'NCDeleter', to deleter.h. Other tests that include deleter.h
redefine the NCDeleter type causing test failures.

llvm-svn: 243733
2015-07-31 04:34:25 +00:00
Eric Fiselier a0832b5743 Start cleanup of unique_ptr tests.
One of the last sections of tests that still fail in C++03 are the unique_ptr
tests. This patch begins cleaning up the tests and fixing C++03 failures.

The main changes of this patch:
  - The "Deleter" type in "deleter.h" tried to be "move-only" in C++03. However
    the move simulation no longer works (see "__rv"). "Deleter" is now copy
    constructible in C++03. However copying "Deleter" will "move" the test value
    instead of copying it.

  - Reduce the unique.ptr.single.ctor tests files from ~25 to 4. There is no
    reason the tests were split through so many files.

llvm-svn: 243730
2015-07-31 02:43:52 +00:00
Eric Fiselier 5265a3ed71 Mark any as done and comment out extra methods until speaking to Marshall
llvm-svn: 243729
2015-07-31 02:29:11 +00:00
Eric Fiselier 3461dbc0a7 [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

llvm-svn: 243728
2015-07-31 02:24:58 +00:00
Eric Fiselier 66d86b7cad Add -Wno-error by default to work around failing compiler-rt builds
llvm-svn: 243725
2015-07-31 01:25:01 +00:00
Eric Fiselier 10ed6c361c Reapply working parts of CMake cleanup.
This patch adds the working parts of r243503. The difference with this patch
is that it doesn't include the HandleLLVMOptions.cmake file.

llvm-svn: 243698
2015-07-30 22:30:34 +00:00
Marshall Clow a6438ca12a 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.
llvm-svn: 243674
2015-07-30 18:26:34 +00:00
Marshall Clow 40631133b4 Change some #ifdefs to #if - thanks to Dexon for thge catch.
llvm-svn: 243641
2015-07-30 13:56:00 +00:00
Eric Fiselier b98aa4359a Revert recent CMake changes again due to failing compiler-rt builds
llvm-svn: 243593
2015-07-29 23:46:55 +00:00
Eric Fiselier 5f6d160b5b Attempt to fix build issues introduced by
r243574

llvm-svn: 243591
2015-07-29 23:23:18 +00:00
Nick Lewycky dd2eb13ac4 Fix typo in unused variable name.
llvm-svn: 243586
2015-07-29 22:38:23 +00:00
Eric Fiselier ff16b9ac90 Recommit r243503 "[libcxx] Cleanup CMake configuration and integrate with LLVM"
This change was reverted in r243550 because it broke clang-format builds
(see PR24306).

This patch recommits a fixed version of the original.

llvm-svn: 243574
2015-07-29 21:07:28 +00:00
Hans Wennborg 1e33bbecb9 Revert r243503 "[libcxx] Cleanup CMake configuration and integrate with LLVM"
This caused clang-format to stop linking on Mac; see PR24306.

llvm-svn: 243550
2015-07-29 18:32:21 +00:00
Marshall Clow adfdae18c8 Fix a self-move bug in inplace_merge. Thanks to Ted and Dexon for the report and the suggested fix.
llvm-svn: 243530
2015-07-29 16:25:45 +00:00
Eric Fiselier 7eb30deff1 [libcxx] Cleanup CMake configuration and integrate with LLVM
Summary:
This patch contains the following changes:

1. Require that libc++ can find a LLVM source directory. This is done the same way as `libc++abi` currently does.
2. Cleanup ugly configuration code in CMakeLists.txt by using `add_flags`, `add_flags_if`, and `add_flags_if_supported` macros.

The goals for this patch are:

1. Help libc++ be more consistent with how LLVM handles CMake options (see PR23670 PR23671).
2. Make it easier to use sanitizers using the `LLVM_USE_SANITIZER` option.
3. Make libc++'s CMakeLists.txt file easier to understand and change.
4. Move towards allowing libc++ to create Sphinx documentation (see http://efcs.ca/libcxx-docs). 
5. Move towards allowing  libc++ to use other LLVM utilities such as `not` and `FileCheck`.

  

Reviewers: mclow.lists, jroelofs, danalbert

Subscribers: cfe-commits

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

llvm-svn: 243503
2015-07-29 00:03:51 +00:00
Eric Fiselier 99a47ef90e Remove sanitizer XFAILs on a test.
llvm-svn: 243499
2015-07-28 23:27:03 +00:00
Marshall Clow bcbc37d8a1 Consolidate a bunch of #ifdef _LIBCPP_NO_EXCEPTIONS .. #endif blocks into a single template function. NFC
llvm-svn: 243415
2015-07-28 13:30:47 +00:00
Eric Fiselier 10e51f84d4 Mark async tests as UNSUPPORTED in C++03 because it requires variadics
llvm-svn: 243393
2015-07-28 07:49:15 +00:00
Eric Fiselier abd52cad84 Fix a handful of tests that fail in C++03
llvm-svn: 243392
2015-07-28 07:31:50 +00:00
Eric Fiselier e62bda70aa 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.

llvm-svn: 243370
2015-07-28 02:15:53 +00:00
Eric Fiselier fda20d94e7 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.

llvm-svn: 243368
2015-07-28 01:52:08 +00:00
Eric Fiselier 522b1d14ef Checking more __invoke tests.
Before I start trying to fix __invoke in C++03 it needs better test coverage.
This patch adds a large amount of tests for __invoke.

llvm-svn: 243366
2015-07-28 01:25:36 +00:00
Marshall Clow 983d178108 Detect and throw on a class of bad regexes that we mistakenly accepted before. Thanks to Trevor Smigiel for the report
llvm-svn: 243030
2015-07-23 18:27:51 +00:00
Justin Bogner 2ea8daaee1 Mark this test as XFAIL with older compilers, since they hit PR18097
llvm-svn: 242967
2015-07-22 23:32:57 +00:00
Eric Fiselier 00f512ebdf 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.

llvm-svn: 242959
2015-07-22 22:43:27 +00:00
Eric Fiselier 48cf128785 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.

llvm-svn: 242951
2015-07-22 22:23:49 +00:00
Eric Fiselier e345173146 Remove more commented out code. That is what version control is for.
llvm-svn: 242872
2015-07-22 04:37:12 +00:00