Commit Graph

298 Commits

Author SHA1 Message Date
Stephan T. Lavavej
e619862dbf [libcxx] [test] Replace _LIBCPP_STD_VER with TEST_STD_VER.
This replaces every occurrence of _LIBCPP_STD_VER in the tests with
TEST_STD_VER. Additionally, for every affected
file, #include "test_macros.h" is being added explicitly if it wasn't
already there.

https://reviews.llvm.org/D26294

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@286007 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-04 20:26:59 +00:00
Roger Ferrer Ibanez
1c0757acd1 Fix archetypes.hpp under libcpp-no-extensions and std level < 14
Under -fno-exceptions TEST_THROW becomes abort / __builtin_abort which returns
void. This causes a type mismatch in the conditional operator when testing the
library in C++98,03,11 modes.

Use a comma operator to workaround this problem.

Differential Revision: https://reviews.llvm.org/D26147



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@285572 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-31 14:14:13 +00:00
Casey Carter
b035d8f064 Silence unused parameter warnings in archetypes.hpp
Reviewed at: https://reviews.llvm.org/D25958



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@285213 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-26 17:22:25 +00:00
Eric Fiselier
317120240b Fix unreferenced parameters. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284942 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-23 18:52:58 +00:00
Eric Fiselier
846edfb837 Update issue status for LWG 2744
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284322 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-16 02:51:50 +00:00
Eric Fiselier
c69d8ca589 Correctly grant rebound limited_allocators friendship.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284006 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 11:35:37 +00:00
Eric Fiselier
de8e3d3a4f Unbreak C++03 build
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284004 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 11:20:27 +00:00
Eric Fiselier
4775578c61 Remove usages of _ALIGNAS_TYPE
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283999 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 10:19:48 +00:00
Eric Fiselier
6f6a9607c2 Fix more C++11 constexpr issues in the tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283996 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 09:48:44 +00:00
Eric Fiselier
159b45f505 Fix nasty_containers.hpp for other stdlibs
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283994 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 09:31:26 +00:00
Eric Fiselier
bf148f02bc Fix use of C++14 constexpr in C++11
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283993 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 09:20:58 +00:00
Eric Fiselier
028a2091ea Protect special members of NullBase archetype to avoid exposing them
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283983 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 08:09:22 +00:00
Eric Fiselier
35ce4859dd Implement N4606 optional
Summary:
Adapt implementation of Library Fundamentals TS optional into an implementation of N4606 optional.

  - Update relational operators per http://wg21.link/P0307
  - Update to requirements of http://wg21.link/P0032
  - Extension: Implement trivial copy/move construction/assignment for `optional<T>` when `T` is trivially copyable.

Audit P/Rs for optional LWG issues:
  - 2756 "C++ WP optional<T> should 'forward' T's implicit conversions" Implemented, which also resolves 2753 "Optional's constructors and assignments need constraints" (modulo my refusal to explicitly delete the move operations, which is a design error that I'm working on correcting in the 2756 P/R).
  - 2736 "nullopt_t insufficiently constrained" Already conforming. I've added a test ensuring that `nullopt_t` is not copy-initializable from an empty braced-init-list, which I believe is the root intent of the issue, to avoid regression.
  - 2740 "constexpr optional<T>::operator->" Already conforming.
  - 2746 "Inconsistency between requirements for emplace between optional and variant" No P/R, but note that the author's '"suggested resolution" is already implemented.
  - 2748 "swappable traits for optionals" Already conforming.
  - 2753 "Optional's constructors and assignments need constraints" Implemented.

Most of the work for this patch was done by Casey Carter @ Microsoft. Thank you Casey!



Reviewers: mclow.lists, CaseyCarter, EricWF

Differential Revision: https://reviews.llvm.org/D22741

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283980 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 07:46:20 +00:00
Eric Fiselier
ead5d404cc Revert Add <optional>. Will recommit with better commit message
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283978 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 06:48:31 +00:00
Eric Fiselier
fbc80168bb Add <optional> header.
This patch is largely thanks to Casey Carter @ Microsoft. He did the initial
work of porting our experimental implementation and tests over to namespace
std.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283977 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 06:45:11 +00:00
Eric Fiselier
ef9e52bc90 Add missing include in test_allocator.h
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283632 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-08 00:57:56 +00:00
Eric Fiselier
124ed406e5 [libc++] Fix stack_allocator
Summary:
To quote STL the problems with stack allocator are"

>"stack_allocator<T, N> is seriously nonconformant to N4582 17.6.3.5 [allocator.requirements].
> First, it lacks a rebinding constructor. (The nested "struct rebind" isn't sufficient.)
> Second, it lacks templated equality/inequality.
> Third, it completely ignores alignment.
> Finally, and most severely, the Standard forbids its existence. Allocators are forbidden from returning memory "inside themselves". This requirement is implied by the Standard's requirements for rebinding and equality. It's permitted to return memory from a separate buffer object on the stack, though."

This patch attempts to address all of those issues.

First, instead of storing the buffer inside the allocator I've change `stack_allocator` to accept the buffer as an argument.

Second, in order to fix rebinding I changed the parameter list from `<class T, size_t NumElements>` to `<class T, size_t NumBytes>`. This allows allocator rebinding
between types that have different sizes. 

Third, I added copy and rebinding constructors and assignment operators.

And finally I fixed the allocation logic to always return properly aligned storage.



Reviewers: mclow.lists, howard.hinnant, STL_MSFT

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D25154

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283631 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-08 00:56:22 +00:00
Eric Fiselier
2c429bee79 Fix various issues in std::any and the related tests.
* Fix self-swap. Patch from Casey Carter.

* Remove workarounds and tests for types with deleted move constructors. This
  was originally added as part of a LWG proposed resolution that has since
  changed.

* Re-apply most recent PR for LWG 2769.

* Re-apply most recent PR for LWG 2754. Specifically fix the SFINAE checks to
  use the decayed type.

* Fix tests to allow moved-from std::any's to have a non-empty state. This is
  the behavior of MSVC's std::any.

* Various whitespace and test fixes.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283606 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-07 21:27:45 +00:00
Eric Fiselier
45a9570f5d Remove MSVC workarounds. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283580 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-07 18:51:33 +00:00
Eric Fiselier
8f972f6538 [libcxx] [test] Guard __has_include usage with a macro
Summary: There's a macro scheme already being used for __has_feature etc. Use it for __has_include too, which makes MSVC happy (it doesn't support __has_include yet, and unguarded use explodes horribly).

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D25251

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283260 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-04 21:25:51 +00:00
Eric Fiselier
cdac787ae8 Replace test_throw.h header with a single test macro
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283030 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-01 10:34:13 +00:00
Eric Fiselier
4e3e15ad99 [libc++] Remove various C++03 feature test macros
Summary:
Libc++ still uses per-feature configuration macros when configuring for C++11. However libc++ requires a feature-complete C++11 compiler so there is no reason to check individual features. This patch starts the process of removing the feature specific macros and replacing their usage with `_LIBCPP_CXX03_LANG`.

This patch removes the __config macros:

* _LIBCPP_HAS_NO_TRAILING_RETURN
* _LIBCPP_HAS_NO_TEMPLATE_ALIASES
* _LIBCPP_HAS_NO_ADVANCED_SFINAE
* _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
* _LIBCPP_HAS_NO_STATIC_ASSERT

As a drive I also changed our C++03 static_assert to use _Static_assert if available.

I plan to commit this without review if nobody voices an objection.

Reviewers: mclow.lists

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D24895

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@282347 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-25 03:34:28 +00:00
Asiri Rathnayake
040945b81f [libcxx] Introduce an externally-threaded libc++ variant.
This patch further decouples libc++ from pthread, allowing libc++ to be built
against other threading systems. There are two main use cases:

- Building libc++ against a thread library other than pthreads.

- Building libc++ with an "external" thread API, allowing a separate library to
  provide the implementation of that API.

The two use cases are quite similar, the second one being sligtly more
de-coupled than the first. The cmake option LIBCXX_HAS_EXTERNAL_THREAD_API
enables both kinds of builds. One needs to place an <__external_threading>
header file containing an implementation of the "libc++ thread API" declared
in the <__threading_support> header.

For the second use case, the implementation of the libc++ thread API can
delegate to a custom "external" thread API where the implementation of this
external API is provided in a seperate library. This mechanism allows toolchain
vendors to distribute a build of libc++ with a custom thread-porting-layer API
(which is the "external" API above), platform vendors (recipients of the
toolchain/libc++) are then required to provide their implementation of this API
to be linked with (end-user) C++ programs.

Note that the second use case still requires establishing the basic types that
get passed between the external thread library and the libc++ library
(e.g. __libcpp_mutex_t). These cannot be opaque pointer types (libc++ sources
won't compile otherwise). It should also be noted that the second use case can
have a slight performance penalty; as all the thread constructs need to cross a
library boundary through an additional function call.

When the header <__external_threading> is omitted, libc++ is built with the
"libc++ thread API" (declared in <__threading_support>) as the "external" thread
API (basic types are pthread based). An implementation (pthread based) of this
API is provided in test/support/external_threads.cpp, which is built into a
separate DSO and linked in when running the libc++ test suite. A test run
therefore demonstrates the second use case (less the intermediate custom API).

Differential revision: https://reviews.llvm.org/D21968

Reviewers: bcraig, compnerd, EricWF, mclow.lists

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@281179 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-11 21:46:40 +00:00
Eric Fiselier
4bc5e1f444 Fix bad locale test data when using the newest glibc
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@280608 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-04 00:48:54 +00:00
Eric Fiselier
917af0a073 Implement C++17 std::sample.
This patch implements the std::sample function added to C++17 from LFTS. It
also removes the std::experimental::sample implementation which now forwards
to std::sample.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279948 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-28 22:14:37 +00:00
Eric Fiselier
113315b9a4 Implement LWG 2711. Constrain path members.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279945 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-28 21:26:01 +00:00
Marshall Clow
d4badbbc5a Support allocators with explicit conversion constructors. Fixes bug #29000
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@278904 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 05:58:40 +00:00
Eric Fiselier
c2141dfff2 Fix new ASAN failures
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@278736 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 20:50:01 +00:00
Eric Fiselier
92741e2493 Refactor test archetypes implementation.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@278319 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11 07:04:14 +00:00
Eric Fiselier
e739d54f86 [libcxx] Add std::any
Summary:
This patch adds std::any by moving/adapting <experimental/any>.

This patch also implements the std::any parts of p0032r3 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0032r3.pdf)
and LWG 2509 (http://cplusplus.github.io/LWG/lwg-defects.html#2509).

I plan to push it in a day or two if there are no comments.


Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D22733

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@278310 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11 03:13:11 +00:00
Eric Fiselier
9639abed2e Fix copy/move constructor annotation for the uses-allocator test types.
Previously the copy/move constructors of the test types did not
properly set the arg_id to T const& or T&& respectivly.



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@277970 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-08 02:22:41 +00:00
Eric Fiselier
29bb84bd57 Silence another occurrence of MSVC's suprious unused warning. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@277572 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03 05:46:36 +00:00
Eric Fiselier
e1445fd8ed Implement the std::pair parts of "Improving pair and tuple". Completes N4387.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276605 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 04:32:07 +00:00
Eric Fiselier
c672a7453d Implement P0040r3: Extending memory management tools
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276544 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-24 03:51:39 +00:00
Eric Fiselier
b5bdc070f2 Unbreak traits tests by handling differences between version macros in clang/apple-clang.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276200 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 22:53:21 +00:00
Eric Fiselier
f5750d5c05 Add checkpoint diagnostics to help diagnose buildbot failures.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@275754 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 03:00:09 +00:00
Marshall Clow
51d7e8e381 Always use the allocator to construct/destruct elements of a deque/vector. Fixes PR#28412. Thanks to Jonathan Wakely for the report.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@275105 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11 21:38:08 +00:00
Eric Fiselier
928a58f7d2 Fix UB in uses_alloc_types.hpp
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273840 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-27 01:52:14 +00:00
Eric Fiselier
83d7ca9ea5 Implement P0163r0. Add shared_ptr::weak_type.
This patch adds the weak_type typedef in shared_ptr. It is available in
C++17 and newer.

This patch also updates the _LIBCPP_STD_VER and TEST_STD_VER macros to
have the value of 16, since 2016 is the current year.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273839 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-27 01:02:43 +00:00
Eric Fiselier
5781358757 Implement p0337r0. Delete operator= for polymorphic_allocator.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273838 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-27 00:55:25 +00:00
Eric Fiselier
8c4dc32424 Add [[noreturn]] attribute to throw_bad_alloc_helper().
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273819 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-26 19:42:59 +00:00
Eric Fiselier
cef97f9cc9 Use correct Clang feature names. I got them wrong in the previous commit
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273384 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 05:40:17 +00:00
Eric Fiselier
8905b11d2d Support old GCC exception and rtti detection macros
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273383 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 05:33:52 +00:00
Eric Fiselier
b5fb8c9e39 Add tests for RTTI/exceptions test macros.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273382 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 05:29:15 +00:00
Eric Fiselier
5cdd5437e1 Fix exception/rtti detection in tests.
So the macros TEST_HAS_NO_EXCEPTIONS and TEST_HAS_NO_RTTI were always
getting defined because I spelt __cpp_exceptions and __cpp_rtti as
__cxx_exceptions and __cxx_rtti.

Tests incoming after this patch.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273381 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 05:03:10 +00:00
Eric Fiselier
506f9d5bd3 Cleanup [list.modifiers] tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273371 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 03:46:32 +00:00
Eric Fiselier
ff58059a86 Suppress stupid and incorrect MSVC warning. patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273350 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 01:02:08 +00:00
Eric Fiselier
374a33d1b9 Allow the libc++ build/source paths to contain symlinks.
The filesystem tests were expecting the paths to the build/source directories
did not contain any symlinks. This patch resolves those symlinks before running
the test suite.



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273323 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21 21:54:23 +00:00
Jonathan Coe
ee49613ff4 Implement std::experimental::propagate_const from LFTS v2
Summary:
An implementation of std::experimental::propagate_const from Library Fundamentals Technical Specification v2.

No tests are provided for disallowed types like fancy pointers or function pointers as no code was written to handle these.

Reviewers: EricWF, mclow.lists

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


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273122 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-19 19:34:13 +00:00
Eric Fiselier
29c26b91df Fix SleepFor(...) helper when a monotonic clock is not available.
Single threaded builds often don't provide a monotonic clock, so we can't
always provide a monotonic SleepFor(...) implementation. Hopefully this
won't cause the builds to hang.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273091 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-18 18:32:26 +00:00