Commit Graph

46 Commits

Author SHA1 Message Date
Marshall Clow
1bef51a0b5 Introduce a new test macro TEST_HAS_C11_FEATURES which is set when the underlying C library has C11 features. In C++17, we use those features. <__config> defines a similar macro, _LIBCPP_HAS_C11_FEATURES, but we don't want to use that in the library-independent parts of the tests, so define the new one. Also add a libc++-specific test to make sure the two stay in sync.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@338411 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-31 18:23:57 +00:00
Alexander Richardson
2be41bb90b Stop wrapping __has_include in another macro
Summary:
This is not guaranteed to work since the characters after '__has_include('
have special lexing rules that can't possibly be applied when
__has_include is generated by a macro. It also breaks the crash reproducers
generated by -frewrite-includes (see https://llvm.org/pr37990).

Reviewers: EricWF, rsmith, mclow.lists
Reviewed By: mclow.lists
Differential Revision: https://reviews.llvm.org/D49067

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@337824 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-24 12:40:56 +00:00
Eric Fiselier
24258c4417 Implement P0768r1: Library support for the Spaceship Operator.
this patch adds the <compare> header and implements all of it
except for [comp.alg].

As I understand it, the header is needed by the compiler in
when implementing the semantics of operator<=>. For that reason
I feel it's important to land this header early, despite
all compilers lacking support.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@329460 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-06 21:37:23 +00:00
Eric Fiselier
b06c8f07b2 Use DoNotOptimize to prevent new/delete elision.
The new/delete tests, in particular those which test replacement
functions, often fail when the optimizer is enabled because the
calls to new/delete may be optimized away, regardless of their side-effects.

This patch converts the tests to use DoNotOptimize in order to prevent
the elision.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@328245 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-22 21:28:09 +00:00
Eric Fiselier
6d7a11eb53 Correct TEST_HAS_NO_ALIGNED_ALLOCATION macro definition
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@328185 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-22 06:21:07 +00:00
Eric Fiselier
a831287399 Fix PR22634 - std::allocator doesn't respect over-aligned types.
This patch fixes std::allocator, and more specifically, all users
of __libcpp_allocate and __libcpp_deallocate, to support over-aligned
types.

__libcpp_allocate/deallocate now take an alignment parameter, and when
the specified alignment is greater than that supported by malloc/new,
the aligned version of operator new is called (assuming it's available).

When aligned new isn't available, the old behavior has been kept, and the
alignment parameter is ignored.

This patch depends on recent changes to __builtin_operator_new/delete which
allow them to be used to call any regular new/delete operator. By using
__builtin_operator_new/delete when possible, the new/delete erasure optimization
is maintained.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@328180 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-22 04:42:56 +00:00
Billy Robert O'Neal III
7e250fcdc1 Change (void) casts to TEST_IGNORE_NODISCARD, as requested by Eric. Reviewed as https://reviews.llvm.org/D40065
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318804 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-21 21:37:26 +00:00
Marshall Clow
7afe61ad1d Add case for c++2a to libc++ and test macros
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@308159 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-17 03:02:27 +00:00
Casey Carter
bed65743b4 [test] s/uexpectedly/unexpectedly/
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@304236 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-30 20:12:55 +00:00
Eric Fiselier
737c3bf25e Add <experimental/coroutine>
This patch adds the library portions of the coroutines PDTS,
which should now be supported by Clang.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@303836 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-25 04:36:24 +00:00
Casey Carter
f0346a5663 [test] support machinery changes for EDG & C1XX /Za
This change works around a couple of bugs:

1. EDG doesn't like explicit constexpr in a derived class. This program:

  struct Base {};
  struct Derived : Base {
      constexpr Derived() = default;
  };

  triggers "error: defaulted default constructor cannot be constexpr."

2. C1XX with /Za has no idea which constructor needs to be valid for copy elision.

The change also conditionally disables parts of the msvc_stdlib_force_include.hpp header that conflict with external configuration when _LIBCXX_IN_DEVCRT is defined.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302707 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10 19:10:49 +00:00
Casey Carter
49abbf545e [test] Name the local variable in the C1XX implementation of DoNotOptmize
Differential Revision: https://reviews.llvm.org/D32510

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302162 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 15:54:09 +00:00
Eric Fiselier
d3b3b1f4a1 Add TEST_NOEXCEPT_FALSE to support D31738
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300191 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13 10:17:23 +00:00
Eric Fiselier
39683f1377 Fix incorrectly qualified return type from unique_ptr::get_deleter().
For reference deleter types the const qualifier on the return type
of get_deleter() should be ignored, and a non-const deleter should
be returned.

This patch fixes a bug where "const deleter_type&" is incorrectly
formed.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300121 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 22:43:49 +00:00
Marshall Clow
570f32c8dd Can't test for noexcept on C++03; std::hash<nullptr_t> isn't available until C++17
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298580 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23 06:20:18 +00:00
Eric Fiselier
0da4cb892b [libc++] Work around C1XX bug which breaks poisoned hash tests.
Summary: This is my attempt to work around the C1XX bug described to me by @BillyONeal.

Reviewers: BillyONeal, STL_MSFT, CaseyCarter

Reviewed By: BillyONeal

Subscribers: cfe-commits, BillyONeal

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298554 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-22 22:41:41 +00:00
Eric Fiselier
76880f55bf Fix DoNotOptimize on MSVC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@297532 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-11 00:07:08 +00:00
Eric Fiselier
25f28d0c9e Prevent UBSAN from generating unsigned overflow diagnostics in the hashing internals
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294391 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-08 00:10:10 +00:00
Eric Fiselier
478f902c62 Refactor unique_ptr/shared_ptr deleter test types into single header.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292577 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 04:39:17 +00:00
Eric Fiselier
50ca3248fb Use __is_identifier to detect Clang extensions instead of __has_extension.
When -pedantic-errors is specified `__has_extension(<feature>)` is always
false when it would otherwise be true. This causes C++03 <atomic> to break
along with other issues.

This patch avoids the above problem by using __is_identifier(...) instead since
it is not affected by -pedantic-errors. For example instead of checking for
__has_extension(c_atomics) we now check `!__is_identifier(_Atomic)`, which
is only true when _Atomic is not a keyword provided by the compiler.

This patch applies similar changes to the detection logic for __decltype and
__nullptr as well.

Note that it does not apply this change to the C++03
`static_assert` macro since -Wc11-extensions warnings generated by expanding
that macro will appear in user code, and will not be suppressed as part of a
system header.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@291995 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-14 04:27:58 +00:00
Eric Fiselier
e5bca2ba66 Fix more uses of dynamic exception specifications in C++17
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289356 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-11 02:47:36 +00:00
Stephan T. Lavavej
aa1d62b4af [libcxx] [test] Add LIBCPP_ASSERT_NOEXCEPT/LIBCPP_ASSERT_NOT_NOEXCEPT, remove an unused variable.
test/support/test_macros.h
For convenience/greppability, add macros for libcxx-specific static_asserts about noexceptness.

(Moving the definitions of ASSERT_NOEXCEPT/ASSERT_NOT_NOEXCEPT isn't technically necessary
because they're macros, but I think it's better style to define stuff before using it.)

test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp
There was a completely unused `TrackedCallable obj;`.

apply() isn't depicted with conditional noexcept in C++17.

test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
Now that we have LIBCPP_ASSERT_NOEXCEPT, use it.

Fixes D27622.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289264 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-09 19:53:08 +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
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
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
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
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
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
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
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
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
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
6e9a694dce Add Filesystem TS -- Complete
Add the completed std::experimental::filesystem implementation and tests.
The implementation supports C++11 or newer.

The TS is built as part of 'libc++experimental.a'. Users of the TS need to
manually link this library. Building and testing the TS can be disabled using
the CMake option '-DLIBCXX_ENABLE_FILESYSTEM=OFF'.

Currently 'libc++experimental.a' is not installed by default. To turn on the
installation of the library use '-DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=ON'.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273034 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 19:46:40 +00:00
Eric Fiselier
d24c465bea Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER.
This is a huge cleanup that helps make the libc++ test suite more portable.
Patch from STL@microsoft.com. Thanks STL!


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272716 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-14 21:31:42 +00:00
Eric Fiselier
3cc263dda1 Remove C++11 feature macros in tests. Use TEST_STD_VER instead.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@269669 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 17:05:14 +00:00
Eric Fiselier
375e2f669c Guard libc++ specific c.__invariants() tests in LIBCPP_ASSERT macros
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267947 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 22:28:23 +00:00
Eric Fiselier
5ccbc48774 Fix some non-standard parts of our test suite. Reported by STL
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267131 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22 10:33:56 +00:00
Eric Fiselier
76d2446cf4 Use __make_integer_seq builtin for std::make_integer_sequence. Patch by K-ballo.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255162 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-09 22:03:06 +00:00
Eric Fiselier
d95ca09be4 Attempt to prevent flaky thread.mutex tests by once again increasing timing tolerances
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@248993 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 08:34:37 +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
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
Eric Fiselier
8f1d85fde5 Add test macros header to remove dependance on __config macros.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@238267 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 00:28:30 +00:00