Commit Graph

2907 Commits

Author SHA1 Message Date
Marshall Clow
078dd9752d Add a catch for std::length_error for the case where the string can't handle 2GB. (like say 32-bit big-endian)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@325147 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-14 18:05:25 +00:00
Dimitry Andric
e64dcb66c0 Make the ctype_byname::widen test cases pass on FreeBSD.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@325028 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-13 17:43:24 +00:00
Stephan T. Lavavej
a2b7665eb2 [libcxx] [test] Strip trailing whitespace, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324959 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-12 22:54:35 +00:00
Eric Fiselier
9e6ac074ee 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.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324799 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-10 02:53:47 +00:00
Marshall Clow
5bfbd7dacc The apple versions of clang don't support deduction guides yet.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324640 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-08 19:33:03 +00:00
Marshall Clow
88ba9758ff Once more, with feeling. Spell 'clang-4.0' correctly this time
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324624 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-08 17:06:08 +00:00
Marshall Clow
0eec3e8b24 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
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324619 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-08 16:25:57 +00:00
Mikhail Maltsev
171ed2198d [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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324596 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-08 11:33:48 +00:00
Marshall Clow
4c153004af Temporarily comment out deduction guide tests while I figure out what to do with old bots
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324573 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-08 07:20:45 +00:00
Marshall Clow
5b1e87e52d Implement deduction guide for basic_string as described in P0433
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324569 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-08 06:34:03 +00:00
Marshall Clow
60020e6384 Improve a test. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324566 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-08 05:47:40 +00:00
Eric Fiselier
c0acd34e9a 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324545 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-07 23:50:25 +00:00
Marshall Clow
088e6015b2 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324531 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-07 21:30:17 +00:00
Eric Fiselier
2e1fa09f68 Fix -verify static assert messages for older Clang versions
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324529 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-07 21:25:25 +00:00
Eric Fiselier
6cb35ede81 [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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324526 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-07 21:06:13 +00:00
Marshall Clow
31810d9c0b 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
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324423 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-06 23:13:48 +00:00
Nirav Dave
610fc67809 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324309 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-06 03:03:37 +00:00
Marshall Clow
b50d2443d5 Remove <experimental/string_view>; use <string_view> instead. See https://libcxx.llvm.org/TS_deprecation.html
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324290 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-05 23:43:34 +00:00
Eric Fiselier
4d0f42850b 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324192 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-04 07:35:36 +00:00
Eric Fiselier
9611902923 Remove debug println from rec.dir.itr.increment test
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324190 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-04 03:26:55 +00:00
Eric Fiselier
0b47a655ac 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324189 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-04 03:10:53 +00:00
Eric Fiselier
af1fd7c75f 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324187 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-04 02:43:32 +00:00
Eric Fiselier
7d251c57ac correct comment about C++03 assignment operators
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324186 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-04 02:22:33 +00:00
Eric Fiselier
122c064a76 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324185 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-04 02:17:02 +00:00
Eric Fiselier
f3224ac007 [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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324182 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-04 01:03:08 +00:00
Eric Fiselier
b173b26b9e Work around GCC constexpr initialization bug
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324165 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-03 01:48:21 +00:00
Eric Fiselier
b232793189 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324164 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-03 01:45:35 +00:00
Eric Fiselier
d33aaa939c 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324153 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-02 22:39:59 +00:00
Richard Smith
b2189c01fa Disable test in C++<11 mode due to use of alignas.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324033 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-01 23:31:22 +00:00
Richard Smith
dfb1351077 Make std::get_temporary_buffer respect overaligned types when possible
Patch by Chris Kennelly!

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


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324020 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-01 22:24:45 +00:00
Marshall Clow
b21316f66c Remove std::experimental::sample; use std::sample instead. See https://libcxx.llvm.org/TS_deprecation.html
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323979 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-01 16:36:08 +00:00
Marshall Clow
14698bce22 Remove <experimental/numeric>; use <numeric> instead. See https://libcxx.llvm.org/TS_deprecation.html
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323975 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-01 15:49:27 +00:00
Marshall Clow
f8d223fe63 Remove <experimental/any>; use <any> instead. See https://libcxx.llvm.org/TS_deprecation.html
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323972 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-01 15:21:14 +00:00
Marshall Clow
95db3d2871 Remove <experimental/optional>; use <optional> instead. See https://libcxx.llvm.org/TS_deprecation.html
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323971 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-01 14:54:25 +00:00
Marshall Clow
75075c6be0 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323945 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-01 03:55:27 +00:00
Marshall Clow
37e4c9b159 Implement LWG2870: Default value of parameter theta of polar should be dependent
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323918 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-31 21:42:39 +00:00
Marshall Clow
4bbcce7ef8 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
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323719 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-30 00:47:43 +00:00
Peter Collingbourne
27c341db41 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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323563 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-26 21:23:27 +00:00
Peter Collingbourne
6b5c08ab34 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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323490 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-26 01:19:23 +00:00
Eric Fiselier
8864da5e78 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323390 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-25 00:02:48 +00:00
Marshall Clow
cc7048888e Implement LWG2783: stack::emplace() and queue::emplace() should return decltype(auto)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323385 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-24 22:42:25 +00:00
Eric Fiselier
8286acce44 [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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323380 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-24 22:14:01 +00:00
Mikhail Maltsev
e54a22f809 [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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323322 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-24 12:45:18 +00:00
Marshall Clow
a351d793ab include <cstdint> to get uint32_t
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323306 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-24 05:38:51 +00:00
Marshall Clow
a11e68f83b Implement P0463R1: 'Endian just Endian'. Reviewed as https://reviews.llvm.org/D35472
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323296 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-24 01:53:24 +00:00
Peter Collingbourne
f493c2fed6 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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323170 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-23 02:07:27 +00:00
Marshall Clow
5b12e3bdb4 Last batch of P0202 constexpr additions: includes/set_intersection/exchange
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323159 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 23:10:40 +00:00
Marshall Clow
63be4189d8 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
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323152 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 21:43:04 +00:00
Marshall Clow
a15161a030 Still more P0202 constexpr-ifying. This batch is: for_each/for_each_n/lexicographical_compare
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323147 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 20:44:33 +00:00
Marshall Clow
c84b496981 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323137 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 18:38:18 +00:00