Commit Graph

2526 Commits

Author SHA1 Message Date
Marshall Clow a4122be549 Fix improperly failing test - and the code it was testing. Thanks to Stephan Lavavej for the catch.
llvm-svn: 328225
2018-03-22 18:27:28 +00:00
Eric Fiselier 5d4624983d Correct TEST_HAS_NO_ALIGNED_ALLOCATION macro definition
llvm-svn: 328185
2018-03-22 06:21:07 +00:00
Eric Fiselier f2918d1c24 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.

llvm-svn: 328180
2018-03-22 04:42:56 +00:00
Marshall Clow 4a6f3c4710 Implement LWG3034: P0767R1 breaks previously-standard-layout types
llvm-svn: 328064
2018-03-21 00:36:05 +00:00
Marshall Clow e0742c4abf Implement LWG3035: std::allocator's constructors should be constexpr.
llvm-svn: 328059
2018-03-20 23:02:53 +00:00
Mike Edwards 8e94aeb5f8 [libcxx][test] Adding apple-clang-9 to UNSUPPORTED in iter_alloc_deduction.fail.cpp.
After two failed attempts last week to make this work I am
going back to a known good method of making this test pass on
macOS...adding the current apple-clang version to the
UNSUPPORTED list.

During a previous patch review (https://reviews.llvm.org/D44103)
it was suggested to just XFAIL libcpp-no-deduction-guides
as was done to iter_alloc_deduction.pass.cpp. However
this caused a an unexpected pass on:
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std/builds/214

I then attempted to just mark libcpp-no-deduction-guides
as UNSUPPORTED, however this caused an additional bot
failure.  So I reverted everything (https://reviews.llvm.org/rCXX327191).

To solve this and get work unblocked I am adding
apple-clang-9 to the original UNSUPPORTED list.

llvm-svn: 327304
2018-03-12 18:06:37 +00:00
Mike Edwards b9abf3d299 [libcxx][test] Reverting r327178 and r327190.
Reverting changes made to iter_alloc_deduction.fail.cpp
as my changes seem to be making several Linux bots angry.

llvm-svn: 327191
2018-03-10 00:53:05 +00:00
Mike Edwards 231e19ce52 [libcxx][test] Marking libcpp-no-deduction-guides unsupported.
This fixes linux bot failures with r327178.

llvm-svn: 327190
2018-03-10 00:19:25 +00:00
Mike Edwards d0f595d77c XFAIL: libcpp-no-deduction-guides in libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp
Summary: Refactor the previous version method of marking each apple-clang version as UNSUPPORTED and just XFAIL'ing the libcpp-no-deduction-guides instead.  This brings this test inline with the same style as iter_alloc_deduction.pass.cpp

Reviewers: EricWF, dexonsmith

Reviewed By: EricWF

Subscribers: EricWF, vsapsai, vsk, cfe-commits

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

llvm-svn: 327178
2018-03-09 22:13:12 +00:00
Vedant Kumar fb36d079e5 Low-hanging fruit optimization in string::__move_assign().
shrink_to_fit() ends up doing a lot work to get information that we
already know since we just called clear(). This change seems concise
enough to be worth the couple extra lines and my benchmarks show that it
is indeed a pretty decent win. It looks like the same thing is going on
twice in __copy_assign_alloc(), but I didn't want to go overboard since
this is my first contribution to llvm/libc++.

Patch by Timothy VanSlyke!

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

llvm-svn: 327064
2018-03-08 21:15:26 +00:00
Marshall Clow 4fe52c7178 Include <system_error> since we use it. Thanks to Andrey Maksimov for the catch.
llvm-svn: 326958
2018-03-07 22:51:16 +00:00
Marshall Clow a9daa969c1 One more test for P0767:
llvm-svn: 326802
2018-03-06 15:01:55 +00:00
Marshall Clow 042f07eed8 Implement P0767R1 - Deprecate POD
llvm-svn: 326801
2018-03-06 15:01:19 +00:00
Volodymyr Sapsai ff9595a002 [libcxx] Fix last_write_time test for filesystems that don't support very small times.
APFS minimum supported file write time is -2^63 nanoseconds, which doesn't go
as far as `file_time_type::min()` that is equal to -2^63 microseconds on macOS.

This change doesn't affect filesystems that support `file_time_type` range only
for in-memory file time representation but not for on-disk representation. Such
filesystems are considered as `SupportsMinTime`.

rdar://problem/35865151

Reviewers: EricWF, Hahnfeld

Subscribers: jkorous-apple, mclow.lists, cfe-commits, christof

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

llvm-svn: 326383
2018-02-28 23:27:40 +00:00
Stephan T. Lavavej c1fcd97ede [libcxx] [test] Fix MSVC warnings and errors.
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp
test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp
test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp
test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp
test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp
test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp
Fix MSVC x64 truncation warnings.
warning C4267: conversion from 'size_t' to 'int', possible loss of data

test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
Fix MSVC uninitialized memory warning.
warning C6001: Using uninitialized memory 'vl'.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp
Include <cassert> for the assert() macro.

Fixes D43273.

llvm-svn: 326120
2018-02-26 20:47:46 +00:00
Alexander Richardson 504d23551e Allow passing additional compiler/linker flags for the tests
Summary:
These flags can be specified using the CMake variables
LIBCXX_TEST_LINKER_FLAGS and LIBCXX_TEST_COMPILER_FLAGS.
When building the tests for CHERI I need to pass additional
flags (such as -mabi=n64 or -mabi=purecap) to the compiler
for our test configurations

Reviewers: EricWF

Reviewed By: EricWF

Subscribers: christof, mgorny, cfe-commits

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

llvm-svn: 325914
2018-02-23 15:19:48 +00:00
Marshall Clow 3c83937370 Add another test case to the deduction guide for basic_string.
llvm-svn: 325740
2018-02-22 05:14:20 +00:00
Mikhail Maltsev 477b5f688c [libcxx] Improve accuracy of complex asinh and acosh
Summary:
Currently std::asinh and std::acosh use std::pow to compute x^2. This
results in a significant error when computing e.g. asinh(i) or
acosh(-1).

This patch expresses x^2 directly via x.real() and x.imag(), like it
is done in libstdc++/glibc, and adds tests that checks the accuracy.

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: christof, cfe-commits

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

llvm-svn: 325510
2018-02-19 15:41:36 +00:00
Eric Fiselier 9491643c4b Fix test failure on compilers w/o deduction guides
llvm-svn: 325205
2018-02-15 02:41:19 +00:00
Marshall Clow 36c4862a37 Add a catch for std::length_error for the case where the string can't handle 2GB. (like say 32-bit big-endian)
llvm-svn: 325147
2018-02-14 18:05:25 +00:00
Dimitry Andric 267e0f4d5f Make the ctype_byname::widen test cases pass on FreeBSD.
llvm-svn: 325028
2018-02-13 17:43:24 +00:00
Stephan T. Lavavej 6b1ae9b854 [libcxx] [test] Strip trailing whitespace, NFC.
llvm-svn: 324959
2018-02-12 22:54:35 +00:00
Eric Fiselier 9bfdb770cc Use multi-key tree search for {map, set}::{count, equal_range}
Patch from ngolovliov@gmail.com
Reviewed as: https://reviews.llvm.org/D42344

As described in llvm.org/PR30959, the current
implementation of std::{map, key}::{count, equal_range} in libcxx is
non-conforming. Quoting the C++14 standard [associative.reqmts]p3

> The phrase “equivalence of keys” means the equivalence relation imposed by
> the comparison and not the operator== on keys. That is, two keys k1 and k2 are
> considered to be equivalent if for the comparison object comp,
> comp(k1, k2) == false && comp(k2, k1) == false.

In the same section, the requirements table states the following:

> a.equal_range(k) equivalent to make_pair(a.lower_bound(k), a.upper_bound(k))
> a.count(k) returns the number of elements with key equivalent to k

The behaviour of libstdc++ seems to conform to the standard here.

llvm-svn: 324799
2018-02-10 02:53:47 +00:00
Marshall Clow 7f7891c427 The apple versions of clang don't support deduction guides yet.
llvm-svn: 324640
2018-02-08 19:33:03 +00:00
Marshall Clow 6aafc8b308 Once more, with feeling. Spell 'clang-4.0' correctly this time
llvm-svn: 324624
2018-02-08 17:06:08 +00:00
Marshall Clow 2a81d30471 Clean up string's deduction guides tests. Mark old versions of clang as unsupported, b/c they don't have deduction guides, even in C++17 mode
llvm-svn: 324619
2018-02-08 16:25:57 +00:00
Mikhail Maltsev 2b20304def [libcxx] Avoid spurious construction of valarray elements
Summary:
Currently libc++ implements some operations on valarray by using the
resize method. This method has a parameter with a default value.
Because of this, valarray may spuriously construct and destruct
objects of valarray's element type.
    
This patch fixes this issue and adds corresponding test cases.


Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: rogfer01, cfe-commits

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

llvm-svn: 324596
2018-02-08 11:33:48 +00:00
Marshall Clow b0c4bb74a8 Temporarily comment out deduction guide tests while I figure out what to do with old bots
llvm-svn: 324573
2018-02-08 07:20:45 +00:00
Marshall Clow 6d9f750dec Implement deduction guide for basic_string as described in P0433
llvm-svn: 324569
2018-02-08 06:34:03 +00:00
Marshall Clow a217e505c3 Improve a test. NFC
llvm-svn: 324566
2018-02-08 05:47:40 +00:00
Eric Fiselier 1a78ae3c89 Fix size and alignment of array<T, 0>.
An array T[1] isn't necessarily the same say when it's
a member of a struct. This patch addresses that problem and corrects
the tests to deal with it.

llvm-svn: 324545
2018-02-07 23:50:25 +00:00
Marshall Clow fc940277cb Fix PR#31454 - 'basic_string<T>::push_back() crashes if sizeof(T)>sizeof(long long)'. We were mishandling the small-string optimization calculations for very large 'characters'. This may be an ABI change (change the size of) strings of very large 'characters', but since they never worked, I'm not too concerned.
llvm-svn: 324531
2018-02-07 21:30:17 +00:00
Eric Fiselier ebf8a0985f Fix -verify static assert messages for older Clang versions
llvm-svn: 324529
2018-02-07 21:25:25 +00:00
Eric Fiselier 59cdf90ac8 [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.
Summary:
This patch fixes llvm.org/PR35491 and LWG2157  (https://cplusplus.github.io/LWG/issue2157)

The fix attempts to maintain ABI compatibility by replacing the array with a instance of `aligned_storage`.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: lichray, cfe-commits

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

llvm-svn: 324526
2018-02-07 21:06:13 +00:00
Marshall Clow a3d37f0716 Remove more of the std::experimental bits that are now in std::. All the _v type aliases, conjunction/disjunction, apply, etc. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 324423
2018-02-06 23:13:48 +00:00
Nirav Dave 936ff58476 Revert "[libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types."
Revert "Fix initialization of array<const T, 0> with GCC."
Revert "Make array<const T, 0> non-CopyAssignable and make swap and fill ill-formed."

This reverts commit r324182, r324185, and r324194 which were causing issues with zero-length std::arrays.

llvm-svn: 324309
2018-02-06 03:03:37 +00:00
Marshall Clow 372d4183cb Remove <experimental/string_view>; use <string_view> instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 324290
2018-02-05 23:43:34 +00:00
Eric Fiselier e3690ba586 Implement LWG 3014 - Fix more noexcept issues in filesystem.
This patch removes the noexcept declaration from filesystem
operations which require creating temporary paths or
creating a directory iterator. Either of these operations
can throw.

llvm-svn: 324192
2018-02-04 07:35:36 +00:00
Eric Fiselier b96def4eb1 Remove debug println from rec.dir.itr.increment test
llvm-svn: 324190
2018-02-04 03:26:55 +00:00
Eric Fiselier be71d336bd Implement LWG2989: path's streaming operators allow everything under the sun.
Because path can be constructed from a ton of different types, including string
and wide strings, this caused it's streaming operators to suck up all sorts
of silly types via silly conversions. For example:

using namespace std::experimental::filesystem::v1;
std::wstring w(L"wide");
std::cout << w; // converts to path.

This patch tentatively adopts the resolution to LWG2989 and fixes the issue
by making the streaming operators friends of path.

llvm-svn: 324189
2018-02-04 03:10:53 +00:00
Eric Fiselier 0f8c8f59df Address LWG 2849 and fix missing failure condition in copy_file.
Previously copy_file didn't handle the case where the input and
output were the same file.

llvm-svn: 324187
2018-02-04 02:43:32 +00:00
Eric Fiselier e1c661f344 correct comment about C++03 assignment operators
llvm-svn: 324186
2018-02-04 02:22:33 +00:00
Eric Fiselier 192622dc49 Make array<const T, 0> non-CopyAssignable and make swap and fill ill-formed.
The standard isn't exactly clear how std::array should handle zero-sized arrays
with const element types. In particular W.R.T. copy assignment, swap, and fill.

This patch takes the position that those operations should be ill-formed,
and makes changes to libc++ to make it so.

This follows up on commit r324182.

llvm-svn: 324185
2018-02-04 02:17:02 +00:00
Eric Fiselier afeda5c251 [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.
Summary:
This patch fixes llvm.org/PR35491 and LWG2157  (https://cplusplus.github.io/LWG/issue2157)

The fix attempts to maintain ABI compatibility by replacing the array with a instance of `aligned_storage`.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: lichray, cfe-commits

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

llvm-svn: 324182
2018-02-04 01:03:08 +00:00
Eric Fiselier f892166a1d Work around GCC constexpr initialization bug
llvm-svn: 324165
2018-02-03 01:48:21 +00:00
Eric Fiselier 9b5ff7a6bc Work around Clang bug introduced in r324062
When Clang encounters an already invalid class declaration, it can
emit incorrect diagnostics about the exception specification on
some of its members. This patch temporarily works around that
incorrect diagnostic.

The clang bug was introduced in r324062.

llvm-svn: 324164
2018-02-03 01:45:35 +00:00
Eric Fiselier bfbafa541a Fix has_unique_object_representation after Clang commit r324134.
Clang previously reported an empty union as having a unique object
representation. This was incorrect and was fixed in a recent Clang commit.

This patch fixes the libc++ tests.

llvm-svn: 324153
2018-02-02 22:39:59 +00:00
Richard Smith c7ef5656ff Disable test in C++<11 mode due to use of alignas.
llvm-svn: 324033
2018-02-01 23:31:22 +00:00
Richard Smith 4e3195c9b3 Make std::get_temporary_buffer respect overaligned types when possible
Patch by Chris Kennelly!

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

llvm-svn: 324020
2018-02-01 22:24:45 +00:00
Marshall Clow 14082fcc42 Remove std::experimental::sample; use std::sample instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 323979
2018-02-01 16:36:08 +00:00
Marshall Clow 91af9048b2 Remove <experimental/numeric>; use <numeric> instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 323975
2018-02-01 15:49:27 +00:00
Marshall Clow 5d8babe30d Remove <experimental/any>; use <any> instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 323972
2018-02-01 15:21:14 +00:00
Marshall Clow 040533215a Remove <experimental/optional>; use <optional> instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 323971
2018-02-01 14:54:25 +00:00
Marshall Clow 1a6493b4e0 Add static_asserts to basic_ios and basic_stream_buf to ensure that that the traits match the character type. This is a requirement on the user - now we get consistent failures at compile time instead of incomprehensible error messages or runtime failures. This is also LWG#2994 - not yet adopted.
llvm-svn: 323945
2018-02-01 03:55:27 +00:00
Marshall Clow 0551d83ed5 Implement LWG2870: Default value of parameter theta of polar should be dependent
llvm-svn: 323918
2018-01-31 21:42:39 +00:00
Marshall Clow aafb3151a8 Add tests to make sure that <string_view> provides std::size/data/empty in C++17 mode. This is LWG#3009, coming up for a vote in JAX - but we already do it, just don't have tests
llvm-svn: 323719
2018-01-30 00:47:43 +00:00
Peter Collingbourne 939b16233b Fix the BinaryPredicate form of std::is_permutation to not rely on operator==
According to [1], forms 2 and 4 of std::is_permutation should use the passed in
binary predicate to compare elements. operator== should only be used for forms
1 and 3 which do not take a binary predicate.

This CL fixes forms 2 and 4 which relied on operator== for some comparisons.

[1] http://en.cppreference.com/w/cpp/algorithm/is_permutation

Patch by Thomas Anderson!

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

llvm-svn: 323563
2018-01-26 21:23:27 +00:00
Peter Collingbourne 0aa71a4f86 libcxx: Move #include_next <math.h> out of header guard in wrapper header.
Code on Windows expects to be able to do:

 #define _USE_MATH_DEFINES
 #include <math.h>

and receive the definitions of mathematical constants, even if <math.h>
has previously been included. To support this scenario, re-include
<math.h> every time the wrapper header is included.

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

llvm-svn: 323490
2018-01-26 01:19:23 +00:00
Eric Fiselier d053b59730 Fix PR35564 - std::list splice/erase incorrectly throw in debug mode.
There was a bug in the implementation of splice where the container
sizes were updated before decrementing one of the iterators. Afterwards,
the result of decrementing the iterator was flagged as UB by the debug
implementation because the container was reported to be empty.

This patch fixes that bug by delaying the updating of the container
sizes until after the iterators have been correctly constructed.

llvm-svn: 323390
2018-01-25 00:02:48 +00:00
Marshall Clow e34f5ffe4b Implement LWG2783: stack::emplace() and queue::emplace() should return decltype(auto)
llvm-svn: 323385
2018-01-24 22:42:25 +00:00
Eric Fiselier 292617e700 [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference binding in std::tuple.
Summary:
See https://bugs.llvm.org/show_bug.cgi?id=20855

Libc++ goes out of it's way to diagnose `std::tuple` constructions which are UB due to lifetime bugs caused by reference creation. For example:

```
// The 'const std::string&' is created *inside* the tuple constructor, and its lifetime is over before the end of the constructor call.
std::tuple<int, const std::string&> t(std::make_tuple(42, "abc"));
```

However, we are over-aggressive and we incorrectly diagnose cases such as:

```
void foo(std::tuple<int const&, int const&> const&);
foo(std::make_tuple(42, 42));
```

This patch fixes the incorrectly diagnosed cases, as well as converting the diagnostic to use the newly added Clang trait `__reference_binds_to_temporary`. The new trait allows us to diagnose cases we previously couldn't such as:

```
std::tuple<int, const std::string&> t(42, "abc");
```

Reviewers: rsmith, mclow.lists

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 323380
2018-01-24 22:14:01 +00:00
Mikhail Maltsev 48c63d879b [libcxx] Correctly handle invalid regex character class names
Summary:
Currently when a regular expression contains an invalid character
class name std::regex constructors throw an std::regex_error with
std::regex_constants::error_brack code.

This patch changes the code to std::regex_constants::error_ctype and
adds a test.

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 323322
2018-01-24 12:45:18 +00:00
Marshall Clow ae21466138 include <cstdint> to get uint32_t
llvm-svn: 323306
2018-01-24 05:38:51 +00:00
Marshall Clow a277d024f7 Implement P0463R1: 'Endian just Endian'. Reviewed as https://reviews.llvm.org/D35472
llvm-svn: 323296
2018-01-24 01:53:24 +00:00
Peter Collingbourne 4801624ee3 libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* filenames on Windows.
This is an MSVC standard library extension. It seems like a reasonable
enough extension to me because wchar_t* is the native format for
filenames on that platform.

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

llvm-svn: 323170
2018-01-23 02:07:27 +00:00
Marshall Clow 8da1a487ae Last batch of P0202 constexpr additions: includes/set_intersection/exchange
llvm-svn: 323159
2018-01-22 23:10:40 +00:00
Marshall Clow e8ea8296fc Another batch of P0202 constepr algirithms. remove/remove_if/remove_copy/remove_copy_if/reverse_copy, and tests (commented out) for rotate_copy, because that depends on std::copy
llvm-svn: 323152
2018-01-22 21:43:04 +00:00
Marshall Clow 1b9a4ffd6b Still more P0202 constexpr-ifying. This batch is: for_each/for_each_n/lexicographical_compare
llvm-svn: 323147
2018-01-22 20:44:33 +00:00
Marshall Clow cbe768ec69 Add (commented out) constexpr tests for copy/copy_backwards/copy_if/copy_n. These will be enabled when that part of P0202 is implemented. NFC at this time.
llvm-svn: 323137
2018-01-22 18:38:18 +00:00
Marshall Clow ac471d6db2 Really comment out the constexpr tests.
llvm-svn: 323072
2018-01-22 01:51:49 +00:00
Marshall Clow 85642c2bea implement (but leave commented out) the constexpr tests from P0202 for std::merge. merge requires std::copy, which isn't constexpr yet.
llvm-svn: 323070
2018-01-22 00:11:44 +00:00
Marshall Clow 4bfb9313c1 More P0202 constexpr work. This commit adds fill/fill_n/generate/generate_n/unique/unique_copy. I removed a specialization of fill_n that recognized when we were dealing with raw pointers and 1 byte trivially-assignable types and did a memset, because the compiler will do that optimization for us.
llvm-svn: 323050
2018-01-20 20:14:32 +00:00
Marshall Clow 12c7423ff9 More P0202 constexpr-ifying in <algorithm>. This commit handles replace/replace_if/replace_copy/replace_copy_if.
llvm-svn: 322975
2018-01-19 18:07:29 +00:00
Marshall Clow 99894b61ba More P0202 constexpr-ifying in <algorithm>. This commit handles 'transform'.
llvm-svn: 322970
2018-01-19 17:45:39 +00:00
Eric Fiselier decf22e50f Fix most GCC test failures.
This patch fixes almost all currently failing tests when
using GCC ToT.

The specific changes are:

(A) Workaround gcc.gnu.org/PR83921 which rejects variables w/o initializers
in constexpr contexts -- even when the variable is an empty class. This
bug has been worked around at all callsites by adding an initializer.
Additionally a new test, constexpr_init.pass.cpp, has been added to
test that Clang doesn't suffer from these bugs.

(B) Fix streambuf.assign/swap.pass.cpp. This test was never actually
calling the swap method as intended. In fact, the swap function it
intended to call was ill-formed when instantiated. GCC diagnosed
this ill-formedness w/o needing an instantiation.

(C) size_delete11.pass.cpp was fixed by adding c++2a to the list of
unsupported dialects.

llvm-svn: 322810
2018-01-18 03:41:06 +00:00
Eric Fiselier 6b3e48b46a Fix nodiscard failure tests on compilers w/o -verify.
Previously .fail.cpp tests for nodiscard were run with -Wunused-result
being a warning, not an error, when the compiler didn't support -verify.

When -verify isn't enabled this change judiciously adds -Werror=unused-result
when to only the failure tests containing the // expected-error string for nodiscard.

As a drive-by change, this patch also adds a missing // UNSUPPORTED: c++2a to
a test which was only supposed to run in C++ <= 11.

llvm-svn: 322776
2018-01-17 22:48:09 +00:00
Marshall Clow 12f0a77902 More constexpr algorithms from P0202. search/search_n
llvm-svn: 322566
2018-01-16 15:48:27 +00:00
Marshall Clow d57c03ddca More constexpr algorithms from P0202: lower_bound, upper_bound, equal_range, binary_search
llvm-svn: 322529
2018-01-16 02:34:41 +00:00
Marshall Clow a38c495f22 Actually CALL the constexpr tests.
llvm-svn: 322528
2018-01-16 02:11:13 +00:00
Marshall Clow 6538e28d5d More constexpr (re P0202) - equal and mismatch
llvm-svn: 322527
2018-01-16 02:04:10 +00:00
Marshall Clow da97ec6c10 Fix constexpr failure on C++11-based buildbots.
llvm-svn: 322507
2018-01-15 19:59:09 +00:00
Marshall Clow 056f15e3c5 More constexpr from P0202. count and count_if. Also fix a comment that Morwenn noted.
llvm-svn: 322506
2018-01-15 19:40:34 +00:00
Marshall Clow 404ee020f0 Some of the tests from earlier today had 'int' as the return type when it should have been 'bool'. Fix that. It doesn't change the behavior of any of the tests, but it's more accurate.
llvm-svn: 322505
2018-01-15 19:32:32 +00:00
Marshall Clow 8694428e36 More P0202 constexpr-ifying. All the find_XXX algorithms in this commit.
llvm-svn: 322504
2018-01-15 19:26:05 +00:00
Marshall Clow 674f9128b7 partition_point gets the P0202 treatment
llvm-svn: 322493
2018-01-15 17:53:34 +00:00
Marshall Clow 706ffef713 More constexpr algorithms from P0202. any_of/all_of/none_of.
llvm-svn: 322492
2018-01-15 17:20:36 +00:00
Marshall Clow 49c7643c39 First part of P0202: Adding constexpr modifiers to functions in <algorithm> and <utility>. This commit is all the is_XXX algorithms.
llvm-svn: 322489
2018-01-15 16:16:32 +00:00
Ekaterina Vaartis b848122b5e Add error code handling to remove_all test
As mentioned by EricWF in revision D41830

llvm-svn: 322351
2018-01-12 05:02:06 +00:00
Volodymyr Sapsai a051024cac [libcxx] Make std::basic_istream::get 0-terminate input array in case of error.
It covers the cases when the sentry object returns false and when an exception
was thrown. Corresponding standard paragraph is C++14 [istream.unformatted]p9:
  [...] In any case, if n is greater than zero it then stores a null
  character into the next successive location of the array.

rdar://problem/35566567

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 322326
2018-01-11 23:23:49 +00:00
Marshall Clow 0e22bf8cb9 Implement an _is_allocator type trait for use in deduction guides.
llvm-svn: 322306
2018-01-11 19:36:22 +00:00
Ekaterina Vaartis e44cbaf704 Make std::experimental::filesystem::remove and remove_all return false or 0 if the file doesn't exist
Differential Revision: https://reviews.llvm.org/D41830

llvm-svn: 322293
2018-01-11 17:04:29 +00:00
Marshall Clow 6b40646bec Fix misspelled macro name - thanks to andrew@ispras.ru for the catch
llvm-svn: 322196
2018-01-10 16:25:04 +00:00
Stephan T. Lavavej 04576cc060 [libcxx] [test] Improve MSVC portability.
test/support/msvc_stdlib_force_include.hpp
When testing MSVC's STL with C1XX, simulate a couple more compiler feature-test macros.

When testing MSVC's STL, simulate a few library feature-test macros.

test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
The vector_size attribute is a non-Standard extension that's supported by Clang and GCC,
but not C1XX. Therefore, guard this with `__has_attribute(vector_size)`.

Additionally, while these tests pass when MSVC's STL is compiled with Clang,
I don't consider this to be a supported scenario for our library,
so also guard this with defined(_LIBCPP_VERSION).

test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
N4713 23.14.10 [func.not_fn]/1 depicts only `call_wrapper(call_wrapper&&) = default;`
and `call_wrapper(const call_wrapper&) = default;`. According to
15.8.2 [class.copy.assign]/2 and /4, this makes call_wrapper non-assignable.
Therefore, guard the assignability tests as libc++ specific.

Add a (void) cast to tolerate not_fn() being marked as nodiscard.

Fixes D41213.

llvm-svn: 322144
2018-01-10 00:39:46 +00:00
Petr Hosek 0f03c79b6d [libcxx] Support the use of compiler-rt in lit tests
Don't link tests against libgcc when compiler-rt is being used.

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

llvm-svn: 322044
2018-01-08 23:36:53 +00:00
Marshall Clow e426a832dd Apparently 'C++14' is different than 'c++14'
llvm-svn: 322034
2018-01-08 22:16:30 +00:00
Billy Robert O'Neal III b6e3c55465 Change add_ten to add_one to avoid triggering ubsan integer overflow.
llvm-svn: 322021
2018-01-08 19:45:16 +00:00
Marshall Clow d835e59211 Add the C++17 extensions to std::search. Include the default searcher, but not the Boyer-Moore or Boyer-Moore-Horspool searcher (yet). BUT put the BM and BMH tests in place, marked to XFAIL. The other searchers will follow soon
llvm-svn: 322019
2018-01-08 19:18:00 +00:00
Dimitry Andric 672f7adce5 Add pre-C++11 is_constructible wrappers for 3 arguments
Summary:
After rL319736 for D28253 (which fixes PR28929), gcc cannot compile `<memory>` anymore in pre-C+11 modes, complaining:

```
In file included from /usr/include/c++/v1/memory:648:0,
                 from test.cpp:1:
/usr/include/c++/v1/memory: In static member function 'static std::__1::shared_ptr<_Tp> std::__1::shared_ptr<_Tp>::make_shared(_A0&, _A1&, _A2&)':
/usr/include/c++/v1/memory:4365:5: error: wrong number of template arguments (4, should be at least 1)
     static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in make_shared" );
     ^
In file included from /usr/include/c++/v1/memory:649:0,
                 from test.cpp:1:
/usr/include/c++/v1/type_traits:3198:29: note: provided for 'template<class _Tp, class _A0, class _A1> struct std::__1::is_constructible'
 struct _LIBCPP_TEMPLATE_VIS is_constructible
                             ^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/v1/memory:648:0,
                 from test.cpp:1:
/usr/include/c++/v1/memory:4365:5: error: template argument 1 is invalid
     static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in make_shared" );
     ^
/usr/include/c++/v1/memory: In static member function 'static std::__1::shared_ptr<_Tp> std::__1::shared_ptr<_Tp>::allocate_shared(const _Alloc&, _A0&, _A1&, _A2&)':
/usr/include/c++/v1/memory:4444:5: error: wrong number of template arguments (4, should be at least 1)
     static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in allocate_shared" );
     ^
In file included from /usr/include/c++/v1/memory:649:0,
                 from test.cpp:1:
/usr/include/c++/v1/type_traits:3198:29: note: provided for 'template<class _Tp, class _A0, class _A1> struct std::__1::is_constructible'
 struct _LIBCPP_TEMPLATE_VIS is_constructible
                             ^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/v1/memory:648:0,
                 from test.cpp:1:
/usr/include/c++/v1/memory:4444:5: error: template argument 1 is invalid
     static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in allocate_shared" );
     ^
```

This is also reported in https://bugs.freebsd.org/224946 (FreeBSD is apparently one of the very few projects that regularly builds programs against libc++ with gcc).

The reason is that the static assertions are invoking `is_constructible` with three arguments, while gcc does not have the built-in `is_constructible` feature, and the pre-C++11 `is_constructible` wrappers in `<type_traits>` only provide up to two arguments.

I have added additional wrappers for three arguments, modified the `is_constructible` entry point to take three arguments instead, and added a simple test to is_constructible.pass.cpp.

Reviewers: EricWF, mclow.lists

Reviewed By: EricWF

Subscribers: krytarowski, cfe-commits, emaste

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

llvm-svn: 321963
2018-01-07 16:45:11 +00:00
Billy Robert O'Neal III 231d15e086 Add casts to prevent narrowing warnings.
llvm-svn: 321923
2018-01-06 02:50:03 +00:00
Billy Robert O'Neal III 1e1195dce5 [libcxx] [test] Remove nonstandard things and resolve warnings in Xxx_scan tests
Reviewed as https://reviews.llvm.org/D41748

* These tests use function objects from functional, back_inserter from iterator, and equal from algorithm, so add those headers.
* The use of iota targeting vector<unsigned char> with an int parameter triggers warnings on MSVC++ assigning an into a unsigned char&; so change the parameter to unsigned char with a static_cast.
* Avoid naming unary_function in identity here as that is removed in '17. (This also fixes naming _VSTD, _NOEXCEPT_, and other libcxx-isms)
* Change the predicate in the transform tests to add_ten so that problems with multiple application are caught.

llvm-svn: 321922
2018-01-06 02:18:20 +00:00