Commit Graph

2567 Commits

Author SHA1 Message Date
Stephan T. Lavavej cb0d20519e [libcxx] [test] Strip trailing whitespace. NFC.
llvm-svn: 334676
2018-06-14 00:12:20 +00:00
Stephan T. Lavavej 896e499e38 [libcxx] [test] Update msvc_stdlib_force_include.hpp.
MSVC's STL removed _SCL_SECURE_NO_WARNINGS.

MSVC's STL implemented feature-test macros.

llvm-svn: 334675
2018-06-14 00:12:14 +00:00
Volodymyr Sapsai d1df7b7ee7 Mark the test using <experimental/memory_resource> to require c++experimental.
When built against the old libc++ version the test was causing linker error

Undefined symbols for architecture x86_64:
  "std::experimental::fundamentals_v1::pmr::new_delete_resource()", referenced from:
      void test_evil<WidgetV0, WidgetV0>() in construct_piecewise_pair_evil.pass.cpp.o
      void test_evil<WidgetV0, WidgetV1>() in construct_piecewise_pair_evil.pass.cpp.o
      void test_evil<WidgetV0, WidgetV2>() in construct_piecewise_pair_evil.pass.cpp.o
      void test_evil<WidgetV0, WidgetV3>() in construct_piecewise_pair_evil.pass.cpp.o
      void test_evil<WidgetV1, WidgetV0>() in construct_piecewise_pair_evil.pass.cpp.o
      void test_evil<WidgetV1, WidgetV1>() in construct_piecewise_pair_evil.pass.cpp.o
      void test_evil<WidgetV1, WidgetV2>() in construct_piecewise_pair_evil.pass.cpp.o
      ...

llvm-svn: 334431
2018-06-11 19:42:27 +00:00
Eric Fiselier c797bb23b8 Fix test failures after r334053.
llvm-svn: 334056
2018-06-06 00:13:49 +00:00
Eric Fiselier 8cef7fd75a Fix PR37694 - std::vector doesn't correctly move construct allocators.
C++2a[container.requirements.general]p8 states that when move constructing
a container, the allocator is move constructed. Vector previously copy
constructed these allocators. This patch fixes that bug.

Additionally it cleans up some unnecessary allocator conversions
when copy constructing containers. Libc++ uses
__internal_allocator_traits::select_on_copy_construction to select
the correct allocator during copy construction, but it unnecessarily
converted the resulting allocator to the user specified allocator
type and back. After this patch list and forward_list no longer
do that.

Technically we're supposed to be using allocator_traits<allocator_type>::select_on_copy_construction,
but that should seemingly be addressed as a separate patch, if at all.

llvm-svn: 334053
2018-06-05 22:32:52 +00:00
JF Bastien 766128e697 Filesystem tests: un-confuse write time
Summary:
The filesystem test was confused about access versus write / modification time. The spec says:

  file_time_type last_write_time(const path& p, error_code& ec) noexcept;
  Returns: The time of last data modification of p, determined as if by the value of the POSIX stat structure member st_mtime obtained as if by POSIX stat(). The signature with argument ec returns file_time_type::min() if an error occurs.

The test was looking at st_atime, not st_mtime, when comparing the result from last_write_time. That was probably due to using a pair instead of naming things nicely or using types. I opted to rename things so it's clearer.

This used to cause test bot failures.

<rdar://problem/40648859>

Reviewers: EricWF, mclow.lists, aemerson

Subscribers: christof, cfe-commits

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

llvm-svn: 333723
2018-06-01 04:59:48 +00:00
JF Bastien 2fec6dc56e Mark deduction guide tests as failing on apple-clang-9
As discussed here: http://lists.llvm.org/pipermail/cfe-dev/2018-May/058116.html
The tests fail on clang-5, as well as apple-clang-9. Mark them as such.

llvm-svn: 333479
2018-05-29 23:28:04 +00:00
Marshall Clow 3a92ecc8e6 Fix embarrasing typo in uncaught_exceptions. Update tests to really test this. Thanks to Peter Klotz for calling my attention to this.
llvm-svn: 333467
2018-05-29 22:25:42 +00:00
Eric Fiselier bd2e949869 LWG 2969 "polymorphic_allocator::construct() shouldn't pass resource()"
Patch from Arthur O'Dwyer.

In the TS, `uses_allocator` construction for `pair` tried to use an allocator
type of `memory_resource*`, which is incorrect because `memory_resource*` is
not an allocator type. LWG 2969 fixed it to use `polymorphic_allocator` as the
allocator type instead.

https://wg21.link/lwg2969

(D47090 included this in `<memory_resource>`; at Eric's request, I've split
this out into its own patch applied to the existing
`<experimental/memory_resource>` instead.)

Reviewed as https://reviews.llvm.org/D47109

llvm-svn: 333384
2018-05-29 00:08:47 +00:00
Marshall Clow c58f9b787f Fix up the final bits of breakage due to clang v5 generating bad implicit template deduction guides - specifically for copy-ctors
llvm-svn: 333381
2018-05-28 19:20:21 +00:00
Marshall Clow aefe07a4c1 Mark the template deduction tests as UNSUPPORTED on clang 5, because it deduces the wrong type.
llvm-svn: 333376
2018-05-28 15:42:47 +00:00
JF Bastien f764dbd023 Revert "Add nonnull; use it for atomics"
That's r333325, as well as follow-up "Fix GCC handling of ATOMIC_VAR_INIT"
r333327.

Marshall asked to revert:

Let's have a discussion about how to implement this so that it is more friendly
to people with installed code bases. We've had *extremely* loud responses to
unilaterally adding warnings - especially ones that can't be easily disabled -
to the libc++ code base in the past.

llvm-svn: 333351
2018-05-26 19:44:45 +00:00
JF Bastien 925faf274c Fix GCC handling of ATOMIC_VAR_INIT
r333325 from D47225 added warning checks, and the test was written to be C++11 correct by using ATOMIC_VAR_INIT (note that the committee fixed that recently...). It seems like GCC can't handle ATOMIC_VAR_INIT well because it generates 'type 'std::atomic<int>' cannot be initialized with an initializer list' on bot libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03. Drop the ATOMIC_VAR_INITs since they weren't required to test the diagnostics.

llvm-svn: 333327
2018-05-26 00:13:53 +00:00
JF Bastien 1be7517aa9 Add nonnull; use it for atomics
Summary:
The atomic non-member functions accept pointers to std::atomic / std::atomic_flag as well as to the non-atomic value. These are all dereferenced unconditionally when lowered, and therefore will fault if null. It's a tiny gotcha for new users, especially when they pass in NULL as expected value (instead of passing a pointer to a NULL value). We can therefore use the nonnull attribute to denote that:

  - A warning should be generated if the argument is null
  - It is undefined behavior if the argument is null (because a dereference will segfault)

This patch adds support for this attribute for clang and GCC, and sticks to the subset of the syntax both supports. In particular, work around this GCC oddity:
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60625

The attributes are documented:

  - https://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html
  - https://clang.llvm.org/docs/AttributeReference.html#nullability-attributes

I'm authoring a companion clang patch for the __c11_* and __atomic_* builtins, which currently only warn on a subset of the pointer parameters.

In all cases the check needs to be explicit and not use the empty nonnull list, because some of the overloads are for atomic<T*> and the values themselves are allowed to be null.

<rdar://problem/18473124>

Reviewers: arphaman, EricWF

Subscribers: aheejin, christof, cfe-commits

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

llvm-svn: 333325
2018-05-25 23:43:53 +00:00
JF Bastien 41b4ba1f1e Fix optional<char> test breakage
It seems GCC and clang disagree. Talked to mclow on IRC, disabling for now.

llvm-svn: 333317
2018-05-25 21:32:27 +00:00
JF Bastien 39281931ec Fix array deduction guide test breakage
No matching constructor

llvm-svn: 333315
2018-05-25 21:17:43 +00:00
JF Bastien fc53b60a14 Fix optional deduction guide test breakage
llvm-svn: 333308
2018-05-25 20:43:57 +00:00
Marshall Clow 3854964531 Add one more test for optional
llvm-svn: 333252
2018-05-25 02:22:54 +00:00
Marshall Clow f35b4bc395 Add deduction guides for optional
llvm-svn: 333251
2018-05-25 02:08:49 +00:00
Akira Hatanaka 7b9bee064a Do not define template specialization __libcpp_is_floating_point<__fp16>
if the compiler is not clang.

gcc doesn't allow using __fp16 on non-ARM targets.

llvm-svn: 333108
2018-05-23 17:50:41 +00:00
Akira Hatanaka ad3be5c454 Teach __libcpp_is_floating_point that __fp16 and _Float16 are
floating-point types.

rdar://problem/40377353

llvm-svn: 333103
2018-05-23 17:31:09 +00:00
Marshall Clow edd5e29cfe Implement deduction guides for basic_regex
llvm-svn: 333050
2018-05-23 01:57:02 +00:00
Volodymyr Sapsai b9c0b637cc [libcxx] [test] Mark the test as unsupported by apple-clang-8.1.
llvm-svn: 333011
2018-05-22 18:46:16 +00:00
Marshall Clow acd629cd3c Missed the tests for the deduction guides for prority_queue
llvm-svn: 332931
2018-05-22 02:19:38 +00:00
Marshall Clow 5b8b8b5dce Deduction guides for the container adaptors - queue, stack, and priority_queue
llvm-svn: 332927
2018-05-22 01:57:53 +00:00
Marshall Clow df8f754792 Implement deduction guides for vector
llvm-svn: 332901
2018-05-21 21:30:12 +00:00
Marshall Clow 4a227e582b Deduction guides for list
llvm-svn: 332818
2018-05-20 14:05:31 +00:00
Marshall Clow e076700b77 Implement deduction guides for forward_list
llvm-svn: 332811
2018-05-19 16:02:05 +00:00
Marshall Clow 926b0b2bf5 Remove expression '1L + INT_MAX', because it overflows on machines where int/long are the same size
llvm-svn: 332797
2018-05-19 03:09:05 +00:00
Marshall Clow dbb6f8a817 Implement deduction guides for <deque>
llvm-svn: 332785
2018-05-18 23:44:13 +00:00
Marshall Clow 929b4ce7aa Disable 'missing-braces' warning
llvm-svn: 332779
2018-05-18 22:21:33 +00:00
Marshall Clow 0ca8c0895c Implement deduction guides for <array>; Reviewed as https://reviews.llvm.org/D46964
llvm-svn: 332768
2018-05-18 21:01:04 +00:00
Billy Robert O'Neal III 8b3e138aad [libcxx] [test] Remove unused local typedef in test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
llvm-svn: 332571
2018-05-17 04:59:34 +00:00
Billy Robert O'Neal III 610e0fd5d5 Add void casts to suppress nodiscard on linear_congruential_engine.
llvm-svn: 332567
2018-05-17 02:58:26 +00:00
Volodymyr Sapsai 57e7470ab6 Update XFAIL so apple-clang-9.0 is the last version not implementing Core 2094.
The test is passing with apple-clang-9.1. rdar://problem/40222003

llvm-svn: 332282
2018-05-14 19:45:24 +00:00
Stephan T. Lavavej 79a7361367 [libcxx] [test] Update msvc_stdlib_force_include.hpp.
llvm-svn: 332159
2018-05-11 23:57:32 +00:00
Eric Fiselier f9fc9513bf Fix failing test due to incorrect use of noexcept
llvm-svn: 332066
2018-05-11 00:33:20 +00:00
Eric Fiselier 11a18a7902 Fix PR37407 - callable traits don't correctly check complete types.
Checking for complete types is really rather tricky when you consider
the amount of specializations required to check a function type. This
specifically caused PR37407 where we incorrectly diagnosed
noexcept function types as incomplete (but there were plenty of other
cases that would cause this).

This patch removes the complete type checking for now. I'm going
to look into adding a clang builtin to correctly do this for us.

llvm-svn: 332040
2018-05-10 20:59:35 +00:00
Volodymyr Sapsai cdb50bc93b Revert "Emit an error when mixing <stdatomic.h> and <atomic>"
It reverts commit r331379 because turned out `__ALLOW_STDC_ATOMICS_IN_CXX__`
doesn't work well in practice.

llvm-svn: 331818
2018-05-08 22:50:35 +00:00
Stephan T. Lavavej 00d83601b4 [libcxx] [test] Fix whitespace, NFC.
Strip trailing whitespace and untabify.

llvm-svn: 331576
2018-05-05 01:40:27 +00:00
Stephan T. Lavavej eb0fa1c054 [libcxx] [test] Fix MSVC x64 truncation warning.
warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data

Requesting post-commit review.

llvm-svn: 331575
2018-05-05 01:40:24 +00:00
Volodymyr Sapsai dea80d5174 Emit an error when mixing <stdatomic.h> and <atomic>
Atomics in C and C++ are incompatible at the moment and mixing the
headers can result in confusing error messages.

Emit an error explicitly telling about the incompatibility. Introduce
the macro `__ALLOW_STDC_ATOMICS_IN_CXX__` that allows to choose in C++
between C atomics and C++ atomics.

rdar://problem/27435938

Reviewers: rsmith, EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: jkorous-apple, christof, bumblebritches57, JonChesterfield, smeenai, cfe-commits

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

llvm-svn: 331379
2018-05-02 17:56:45 +00:00
Richard Smith c4f593ba1a Fix return type of isinf(double) and isnan(double) where possible.
When using an old version of glibc, a ::isinf(double) and ::isnan(double)
function is provided, rather than just the macro required by C and C++.
Displace this function using _LIBCPP_PREFERRED_OVERLOAD where possible.

The only remaining case where we should get the wrong return type is now
glibc + libc++ + a non-clang compiler.

llvm-svn: 331241
2018-05-01 03:05:40 +00:00
Billy Robert O'Neal III 6e083f628a [libcxx] [test] Remove non-portable assertions from filebuf tests
seekoff.pass.cpp:
libc++'s tests are asserting things about the buffer passed to pubsetbuf. [filebuf.virtuals]/12 says that what the filebuf does with the buffer you give it is completely implementation defined. The MSVC++ implementation takes that buffer and hands it off to the CRT (by calling ::setvbuf) and the CRT doesn't necessarily follow the pattern this test wants.
This change simply makes asserts against the buffer's contents use LIBCPP_ASSERT instead of assert.

pbackfail.pass.cpp:
libc++'s tests are asserting about what characters will and will not be available in the putback area. [filebuf.virtuals]/9 says "The function can alter the number of putback positions available as a result of any call." This change LIBCPP_ASSERTS libc++'s behavior, but checks invariants of the putback area independently.

llvm-svn: 330999
2018-04-26 22:18:33 +00:00
Marshall Clow 57e782535e Move old test into test/libcxx, and implement new version of test for ostreambuf_iterator::failed. Fixes PR#37245. Thanks to Billy O'Neill for the bug report.
llvm-svn: 330955
2018-04-26 16:16:45 +00:00
Volodymyr Sapsai aa208791bb [libcxx] func.wrap.func.con: Unset function before destroying anything
Be defensive against a reentrant std::function::operator=(nullptr_t), in case
the held function object has a non-trivial destructor.  Destroying the function
object in-place can lead to the destructor being called twice.

Patch by Duncan P. N. Exon Smith. C++03 support by Volodymyr Sapsai.

rdar://problem/32836603

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits, arphaman

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

llvm-svn: 330885
2018-04-25 23:38:41 +00:00
Marshall Clow 0badc676cf Disable the test I just added when testing C++03.
llvm-svn: 330838
2018-04-25 16:09:47 +00:00
Marshall Clow 3df56fdd9b Fix static initialization of std::atomic_flag; Fixes PR#37226. Thanks to Ricky Zhou for the report and test case.
llvm-svn: 330828
2018-04-25 14:27:29 +00:00
Billy Robert O'Neal III 078611eed5 [libcxx] [test] Remove nonportable that errc::is_a_directory produces "Is a directory" from ios_base::failure tests
These io_error asserts that std::errc::is_a_directory has message "Is a directory". On MSVC++ it reports "is a directory" (with a lowercase I). That doesn't matter for the ios_failure component being tested, so just implement in terms of system_category().message().

Reviewed as https://reviews.llvm.org/D45715

llvm-svn: 330791
2018-04-25 01:58:55 +00:00
Tim Shen 403c667b4b Re-commit r330627 "[libcxx] implement <experimental/simd> declarations based on P0214R7."
There are 3 changes:
* Renamed genertor.pass.cpp to generator.pass.cpp
* Removed nothing_to_do.pass.cpp
* Mark GCC 4.9 as UNSUPPORTED for the test files that have negative
  narrowing conversion SFINAE test (see GCC PR63723).

llvm-svn: 330655
2018-04-23 21:54:06 +00:00