Commit Graph

1932 Commits

Author SHA1 Message Date
Stephan T. Lavavej c255fa5e93 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 2/7.
These tests for some guy's transparent operator functors were needlessly truncating their
double results to int. Preserving the doubleness makes compilers happier. I'm following
existing practice by adding an "// exact in binary" comment when the result isn't a whole number.
(The changes from 6 to 6.0 and so forth are stylistic, not critical.)

Fixes D27539.

llvm-svn: 289106
2016-12-08 21:38:01 +00:00
Stephan T. Lavavej d7dc18e26d [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 1/7.
Given `std::basic_streambuf<CharT>::int_type __c`, `std::basic_string<CharT> str_`,
and having checked `__c != std::basic_streambuf<CharT>::traits_type::eof()` (substituting typedefs
for clarity), the line `str_.push_back(__c);` is safe according to humans, but truncates according
to compilers. `str_.push_back(static_cast<CharT>(__c));` avoids that problem.

Fixes D27538.

llvm-svn: 289105
2016-12-08 21:37:47 +00:00
Eric Fiselier 4262748e0f Add more test cases to packaged_task copyability test
llvm-svn: 289034
2016-12-08 10:02:04 +00:00
Eric Fiselier 009259da8a Avoid C++17 guaranteed copy elision when testing for non-copyability
llvm-svn: 289033
2016-12-08 09:57:00 +00:00
Casey Carter 6da13b6b79 std::get<0>([std::variant constant expression]) *is* noexcept.
Differential review: http://reviews.llvm.org/D27436

llvm-svn: 288760
2016-12-06 02:28:19 +00:00
Stephan T. Lavavej d4b83e6dfd [libcxx] [test] D27269: Fix MSVC x64 warning C4267 "conversion from 'size_t' to 'int' [or 'unsigned int'], possible loss of data", part 3/4.
test/std/containers/sequences/vector.bool/copy.pass.cpp
test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
Change "unsigned s = x.size();" to "typename C::size_type s = x.size();"
because that's what it returns.

test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp
Include <cstddef>, then change "unsigned n = T::length(s);"
to "std::size_t n = T::length(s);" because that's what char_traits returns.

test/std/strings/basic.string/string.cons/substr.pass.cpp
Change unsigned to typename S::size_type because that's what str.size() returns.

test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
This was needlessly truncating std::size_t to unsigned.
It's being used to compare and initialize std::size_t.

llvm-svn: 288753
2016-12-06 01:14:51 +00:00
Stephan T. Lavavej f41847c401 [libcxx] [test] D27268: Fix MSVC x64 warning C4267 "conversion from 'size_t' to 'int' [or 'unsigned int'], possible loss of data", part 2/4.
Use static_cast<int> when storing size_t in int (or passing size_t to int).

Also, remove a spurious semicolon in test/support/archetypes.hpp.

test/support/count_new.hpp
Additionally, change data members (and parameters) to size_t.

llvm-svn: 288752
2016-12-06 01:14:43 +00:00
Stephan T. Lavavej baa547b996 [libcxx] [test] D27267: Fix MSVC x64 warning C4267 "conversion from 'size_t' to 'int' [or 'unsigned int'], possible loss of data", part 1/4.
Replace "int n = str_.size();" with "int n = static_cast<int>(str_.size());".

int is the correct type to use, because we're eventually calling
"base::pbump(n+1);" where base is std::basic_streambuf.
N4606 27.6.3.3.3 [streambuf.put.area]/4 declares: "void pbump(int n);"

llvm-svn: 288751
2016-12-06 01:14:29 +00:00
Stephan T. Lavavej fe4ca8c539 [libcxx] [test] D27266: Remove spurious semicolons.
llvm-svn: 288750
2016-12-06 01:14:06 +00:00
Stephan T. Lavavej e9c728899f [libcxx] [test] D27025: Fix MSVC warning C4389 "signed/unsigned mismatch", part 12/12.
Various changes:

test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
This is comparing value_type to unsigned. value_type is sometimes int and sometimes struct S (implicitly constructible from int).
static_cast<value_type>(unsigned) silences the warning and doesn't do anything bad (as the values in question are small).

test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
This is comparing an int remote-element to size_t. The values in question are small and non-negative,
so either type is fine. I think that converting int to size_t is marginally better here than the reverse.

test/std/containers/sequences/deque/deque.cons/size.pass.cpp
DefaultOnly::count is int (and non-negative). When comparing to unsigned, use static_cast<unsigned>.

test/std/strings/basic.string/string.access/index.pass.cpp
We're comparing char to '0' through '9', but formed with the type size_t. Add static_cast<char>.

test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
Include <cstddef> for pedantic correctness (this test was already mentioning std::size_t).

"v[i] == (i & 1)" was comparing bool to size_t. Saying "v[i] == ((i & 1) != 0)" smashes the RHS to bool.

llvm-svn: 288749
2016-12-06 01:13:51 +00:00
Stephan T. Lavavej 6859c20ac9 [libcxx] [test] D27024: Fix MSVC warning C4389 "signed/unsigned mismatch", part 11/12.
Change "unsigned n = 0;" to "int n = 0;". It's being compared to int elements and ptrdiff_t distances.

test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
This one's a little special, but not really. "*i == n" is comparing MoveOnly to n.
MoveOnly is implicitly constructible from int, so int is the correct type to use here.

llvm-svn: 288748
2016-12-06 01:13:40 +00:00
Stephan T. Lavavej e17a155c61 [libcxx] [test] D27023: Fix MSVC warning C4389 "signed/unsigned mismatch", part 10/12.
Add static_cast<int>. In these cases, the values are guaranteed to be small-ish,
and they're being compared to int elements.

test/std/containers/sequences/deque/deque.capacity/access.pass.cpp
Use int instead of unsigned to iterate from 0 to 10.

llvm-svn: 288747
2016-12-06 01:13:29 +00:00
Stephan T. Lavavej 68a694b800 [libcxx] [test] D27022: Fix MSVC warning C4389 "signed/unsigned mismatch", part 9/12.
Add static_cast<std::size_t> to more comparisons. (Performed manually, unlike part 8/12.)

Also, include <cstddef> when it wasn't already being included.

llvm-svn: 288746
2016-12-06 01:13:14 +00:00
Stephan T. Lavavej fbfb2ab63e [libcxx] [test] D27021: Fix MSVC warning C4389 "signed/unsigned mismatch", part 8/12.
Add static_cast<std::size_t> when comparing distance() to size().

These replacements were performed programmatically with regex_replace():

const vector<pair<regex, string>> reg_fmt = {
    { regex(R"(assert\((\w+)\.size\(\) == std::distance\((\w+, \w+)\)\))"),
        "assert($1.size() == static_cast<std::size_t>(std::distance($2)))" },
    { regex(R"(assert\(distance\((\w+\.begin\(\), \w+\.end\(\))\) == (\w+)\.size\(\)\))"),
        "assert(static_cast<std::size_t>(distance($1)) == $2.size())" },
    { regex(R"(assert\(std::distance\((\w+\.\w*begin\(\), \w+\.\w*end\(\))\) == (\w+)\.size\(\)\))"),
        "assert(static_cast<std::size_t>(std::distance($1)) == $2.size())" },
};

Also, include <cstddef> when it wasn't already being included.

llvm-svn: 288745
2016-12-06 01:12:34 +00:00
Eric Fiselier 9642b36e91 Add support for writing -verify shell tests
llvm-svn: 288743
2016-12-06 01:02:15 +00:00
Eric Fiselier 8e27c2b970 Allow enabling/disabling testing with module using env LIBCXX_USE_MODULES=1
The Clang modules implementation breaks enough that libc++ needs an easy way
to enable/disable using modules on the Zorg builders. Editing Zorg itself
requires a buildmaster restart which only happens weekly. This patch
allows LIBCXX_USE_MODULES to be used to enable/disable the feature,
allowing the buildslave to disable it as need be.

llvm-svn: 288736
2016-12-06 00:01:04 +00:00
Eric Fiselier daf21c3f69 Adjust libc++ test infastructure to fully support modules
This patch overhalls the libc++ test format/configuration in order to fully support modules. By "fully support" I mean get almost all of the tests passing. The main hurdle for doing this is handling tests that `#define _LIBCPP_FOO` macros to test a different configuration. This patch deals with these tests in the following ways:

1. For tests that define single `_LIBCPP_ABI_FOO` macros have been annotated with `// MODULES_DEFINES: _LIBCPP_ABI_FOO`. This allows the test suite to define the macro on the command line so it uses a different set of modules.
2. Tests for libc++'s debug mode (which define custom `_LIBCPP_ASSERT`) are automatically detected by the test suite and are compiled and run with modules disabled.

This patch also cleans up how the `CXXCompiler` helper class handles enabling/disabling language features.

NOTE: This patch uses `LIT` features which were only committed to LLVM today. If this patch breaks running the libc++ tests you probably need to update LLVM.
llvm-svn: 288728
2016-12-05 23:16:07 +00:00
Roger Ferrer Ibanez 4cb4b36aa2 Handle tests for noexcept that expect a false value
Under libcpp-no-exceptions, noexcept is trivially true. Some tests expect in
the usual setting to return false, so adjust them to expect true under
libcpp-no-exceptions.

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

llvm-svn: 288660
2016-12-05 11:05:09 +00:00
Eric Fiselier 0c6d89d614 Turn off testsuite warnings by default with GCC
llvm-svn: 288576
2016-12-03 03:29:45 +00:00
Eric Fiselier 46fcbb4da4 Work around more -Wshadow warnings
llvm-svn: 288573
2016-12-03 02:26:28 +00:00
Eric Fiselier f9353d89be Revert workaround for Clang bug. Thanks to Richard for the quick fix
llvm-svn: 288566
2016-12-03 01:28:01 +00:00
Eric Fiselier 572e6deeb7 Fix -Wshadow warnings and enable warnings by default for C++ >= 11
llvm-svn: 288564
2016-12-03 01:21:40 +00:00
Eric Fiselier 33f947057d XFAIL variant tests for apple-clang
llvm-svn: 288559
2016-12-03 00:33:03 +00:00
Eric Fiselier 465bd0fc00 Enable warnings by default for C++ >= 11 and fix -Wshadow occurances
llvm-svn: 288557
2016-12-03 00:27:13 +00:00
Eric Fiselier d7a50d1d6b Work around Clang 3.8 bugs
llvm-svn: 288556
2016-12-03 00:13:33 +00:00
Eric Fiselier 918f32fc7b Make variant's index part of the hash value
llvm-svn: 288554
2016-12-02 23:38:31 +00:00
Eric Fiselier 0d3d8de014 Implement C++17 <variant>. Patch from Michael Park!
This patch was reviewed as https://reviews.llvm.org/D23263.

llvm-svn: 288547
2016-12-02 23:00:05 +00:00
Eric Fiselier 13b6cc4b08 Work around a bug in Clang's implementation of noexcept function types
llvm-svn: 288544
2016-12-02 22:30:52 +00:00
Eric Fiselier ffd5732170 Fix copy/paste errors in new variant tests
llvm-svn: 288538
2016-12-02 21:32:35 +00:00
Eric Fiselier 96be8df23e Add tests for libc++'s constexpr variant copy/move extension
llvm-svn: 288536
2016-12-02 21:17:51 +00:00
Roger Ferrer Ibanez de344ac83b Protect sequences test under libcpp-no-exceptions
Replace throw with TEST_THROW and protect tests that do throw. Also add missing assert(false).

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

llvm-svn: 288383
2016-12-01 17:36:41 +00:00
Roger Ferrer Ibanez f3fce920ff Protect futures test under libcpp-no-exceptions
Skip tests that expect an exception be thrown.

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

llvm-svn: 288382
2016-12-01 17:34:57 +00:00
Roger Ferrer Ibanez c9a8a5596f Protect optional test under libcpp-no-exceptions
Replace throw with TEST_THROW and skip tests that throw exceptions

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

llvm-svn: 288379
2016-12-01 17:33:36 +00:00
Roger Ferrer Ibanez 9f1bcb65aa Protect std::ostream::sentry test under libcpp-no-exceptions
Skip test that throws an exception.

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

llvm-svn: 288378
2016-12-01 17:31:38 +00:00
Roger Ferrer Ibanez 86663cd0ef Protect std::array tests under noexceptions
Skip tests that expect exceptions be thrown. Also add missing asserts.

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

llvm-svn: 288165
2016-11-29 17:10:29 +00:00
Roger Ferrer Ibanez 9d03c03858 Protect std::string tests under libcpp-no-exceptions
Skip tests that expect an exception be thrown and/or disable
unreachable catch handlers.

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

llvm-svn: 288158
2016-11-29 16:40:19 +00:00
Roger Ferrer Ibanez f2e50651f6 Protect std::{,unordered_}map tests under noexceptions
Skip tests that use exceptions

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

llvm-svn: 288157
2016-11-29 16:37:48 +00:00
Roger Ferrer Ibanez d7306fb85a Protect locale tests under noexceptions
Skip tests that expect exceptions be thrown.

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

llvm-svn: 288156
2016-11-29 16:31:40 +00:00
Roger Ferrer Ibanez 21ad28cfb4 Protect test for dynarray under libcpp-no-exceptions
This test expects an exception be thrown.

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

llvm-svn: 288155
2016-11-29 16:27:45 +00:00
Marshall Clow 13320a50e5 Implement conjuntion/disjuntion/negation for LFTS v2. Same code and tests for the ones in std::
llvm-svn: 287988
2016-11-26 18:45:03 +00:00
Marshall Clow 3b3352dead Implement the 'detection idiom' from LFTS v2
llvm-svn: 287981
2016-11-26 15:49:40 +00:00
Roger Ferrer Ibanez d056b5be51 Reverting wrong diff
I managed to confuse me with two reviews of the same thing and ended commiting the wrong one.

llvm-svn: 287868
2016-11-24 11:28:02 +00:00
Roger Ferrer Ibanez 929282836a Protect tests for std::uninitialized_{copy,fill} under libcpp-no-exceptions
Skip tests that expect an exception be thrown.

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

llvm-svn: 287866
2016-11-24 11:17:09 +00:00
Roger Ferrer Ibanez c65daf3e4a Protect std::string tests under libcpp-no-exceptions
Skip tests that expect an exception be thrown and/or disable
unreachable catch handlers.

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

llvm-svn: 287865
2016-11-24 11:15:09 +00:00
Stephan T. Lavavej d72ece6462 [libcxx] [test] D27027: Strip trailing whitespace.
llvm-svn: 287829
2016-11-23 22:03:28 +00:00
Stephan T. Lavavej 640660aa3f [libcxx] [test] D27026: Fix copy-paste silliness; ULL can't ever be 32-bit.
llvm-svn: 287828
2016-11-23 22:02:59 +00:00
Stephan T. Lavavej 8eb5ce8652 [libcxx] [test] D27020: Fix MSVC warning C4245 "conversion from 'X' to 'Y', signed/unsigned mismatch", part 7/12.
When initializing unsigned integers to their maximum values, change "const T M(~0);" to "const T M(static_cast<T>(-1));".

~0 and -1 are equivalent, but I consider the -1 form to be significantly clearer (and more consistent with other tests).

llvm-svn: 287827
2016-11-23 22:02:53 +00:00
Stephan T. Lavavej bbdf9b7d2b [libcxx] [test] D27019: Fix MSVC warning C4245 "conversion from 'X' to 'Y', signed/unsigned mismatch", part 6/12.
Add static_cast when initializing unsigned integers with negative numbers (in order to obtain big values).

llvm-svn: 287826
2016-11-23 22:02:44 +00:00
Stephan T. Lavavej 562f28a6ed [libcxx] [test] D27018: Fix MSVC warning C4018 "signed/unsigned mismatch", part 5/12.
Various changes:

test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp
Change M from unsigned to int. It's compared against "int x",
and we binary_search() for it within a vector<int>.

test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp
test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp
Add static_cast<unsigned> when comparing int to unsigned.

test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
Change unsigned indices to int when we're being given int as a bound.

llvm-svn: 287825
2016-11-23 22:02:35 +00:00
Stephan T. Lavavej 73876facd5 [libcxx] [test] D27016: Fix MSVC warning C4018 "signed/unsigned mismatch", part 4/12.
Change "int j;" indices to "std::size_t j;".

Also, include <cstddef> when it wasn't already being included.

llvm-svn: 287824
2016-11-23 22:02:27 +00:00
Stephan T. Lavavej afe99ae092 [libcxx] [test] D27015: Fix MSVC warning C4018 "signed/unsigned mismatch", part 3/12.
Change unsigned to int in parameters.

llvm-svn: 287823
2016-11-23 22:02:16 +00:00
Stephan T. Lavavej a11d322f0d [libcxx] [test] D27014: Fix MSVC warning C4018 "signed/unsigned mismatch", part 2/12.
Add static_cast<std::size_t> when comparing int to std::size_t.

Also, include <cstddef> when it wasn't already being included.

llvm-svn: 287822
2016-11-23 22:01:58 +00:00
Stephan T. Lavavej e898b484f6 [libcxx] [test] D27013: Fix MSVC warning C4018 "signed/unsigned mismatch", part 1/12.
Change loop indices from int to std::size_t.

Also, include <cstddef> when it wasn't already being included.

llvm-svn: 287820
2016-11-23 22:01:19 +00:00
Eric Fiselier 341c9dd9c4 Fix __hash_table::max_size() on 32 bit systems
llvm-svn: 287749
2016-11-23 09:16:12 +00:00
Casey Carter ca1c5e0fb6 Don't "LIBCPP_ONLY(stuff;)" at namespace scope.
Differential review: https://reviews.llvm.org/D27029

llvm-svn: 287732
2016-11-23 01:44:53 +00:00
Eric Fiselier 55b31b4e69 [libcxx] Fix max_size() across all containers
Summary: The `max_size()` method of containers should respect both the allocator's reported `max_size` and the range of the `difference_type`. This patch makes all containers choose the smallest of those two values.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

llvm-svn: 287729
2016-11-23 01:18:56 +00:00
Eric Fiselier 80e66ac1d3 Add <variant> tests but disable them for libc++
llvm-svn: 287728
2016-11-23 01:02:51 +00:00
Eric Fiselier 7216b6bc38 Attempt to fix stdint/cstdint modules try 2
llvm-svn: 287690
2016-11-22 20:05:19 +00:00
Eric Fiselier 67a7e935a3 Revert r287435 because of OS X test failures
llvm-svn: 287531
2016-11-21 11:26:10 +00:00
Eric Fiselier 43b5523069 Mark variadic lock guard tests as XFAIL with modules, since they have to define macros to expose the new ABI
llvm-svn: 287513
2016-11-21 01:10:52 +00:00
Eric Fiselier 11869aeb49 Adjust uses_alloc_types helpers for later changes
llvm-svn: 287512
2016-11-21 00:41:32 +00:00
Eric Fiselier 72d302b9ed Fix stdint/cstdint modules
llvm-svn: 287435
2016-11-19 03:29:03 +00:00
Eric Fiselier 3a528e2936 Mark test as unsupported in C++03
llvm-svn: 287417
2016-11-19 01:38:00 +00:00
Eric Fiselier 074d46d55f [libcxx] Implement locale.h to fix modules build
Summary:
Because `locale.h` isn't part of the libc++ modules the class definitions it provides are exported as part of `__locale` (since it happens to be build first). This breaks `<clocale>` which exports `std::lconv` without including `<__locale>`.

This patch implements `locale.h` to fix this issue, it also adds support for testing libc++ with modules.




Reviewers: mclow.lists, rsmith, EricWF

Subscribers: cfe-commits

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

llvm-svn: 287413
2016-11-19 01:14:15 +00:00
Stephan T. Lavavej ae3c4eec5a [libcxx] [test] D26812: In random tests, use real static_asserts and silence a warning.
In C++11 mode and newer, use real static_asserts.
In C++03 mode, min() and max() aren't constexpr, so use plain asserts.

One test triggers MSVC's warning C4310 "cast truncates constant value".
The code is valid, and yet the warning is valid, so I'm silencing it
through push-disable-pop.

llvm-svn: 287391
2016-11-18 22:45:32 +00:00
Stephan T. Lavavej 09c311b9a4 [libcxx] [test] D26816: Fix non-Standard assumptions when testing sample().
sample() isn't specified with a reproducible algorithm, so expecting
exact output is non-Standard. Mark those tests with LIBCPP_ASSERT.

In test_small_population(), we're guaranteed to get all of the elements,
but not necessarily in their original order. When PopulationCategory is
forward, we're guaranteed stability (and can therefore test equal()).
Otherwise, we can only test is_permutation(). (As it happens, both libcxx
and MSVC's STL provide stability in this scenario for input-only iterators.)

llvm-svn: 287383
2016-11-18 21:54:43 +00:00
Stephan T. Lavavej b04c795e24 [libcxx] [test] D26815: Fix an assumption about the state of moved-from std::functions.
The Standard doesn't provide any guarantees beyond "valid but unspecified" for
moved-from std::functions. libcxx moves from small targets and leaves them
there, while MSVC's STL empties out the source. Mark these assertions as
libcxx-specific.

llvm-svn: 287382
2016-11-18 21:54:38 +00:00
Stephan T. Lavavej e57a2a3144 [libcxx] [test] D26813: allocator<const T> is non-Standard.
N4582 17.6.3.5 [allocator.requirements] says that allocators are given
cv-unqualified object types, and N4582 20.9.9 [default.allocator]
implies that allocator<const T> is ill-formed (due to colliding
address() overloads). Therefore, tests for allocator<const T>
should be marked as libcxx-specific (if not removed outright).

llvm-svn: 287381
2016-11-18 21:54:31 +00:00
Eric Fiselier 371ecc6398 Remove files missed in r287250
llvm-svn: 287251
2016-11-17 19:24:34 +00:00
Eric Fiselier 66ddd34e8d Test changes for P0504R0 "Revisiting in-place tag types for any/optional/variant". Patch from Casey Carter
llvm-svn: 287249
2016-11-17 19:23:35 +00:00
Eric Fiselier c2b49f5abb Fix -verify tests for older ccache versions
llvm-svn: 287109
2016-11-16 14:48:42 +00:00
Justin Lebar 20cb820880 [libcxx] Mark xonstexpr-fns.pass.cpp as XFAIL: gcc.
This fails with gcc because __builtin_isnan and friends, which
libcpp_isnan and friends call, are not themselves constexpr-evaluatable.

llvm-svn: 287041
2016-11-15 22:03:29 +00:00
Justin Lebar 2d3482287b [CUDA] Mark __libcpp_{isnan,isinf,isfinite} as constexpr.
Summary:
This makes these functions available on host and device, which is
necessary to compile <complex> for the device.

Reviewers: hfinkel, EricWF

Subscribers: cfe-commits

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

llvm-svn: 287012
2016-11-15 19:15:57 +00:00
Vedant Kumar 50d161ce0f Revert "P0503R0, adopted in Issaquah, rewords some requirements on nullptr_t and istream_iterator. No code changes were needed, but I updated a few tests. Also resolved P0509 and P0521, which required no changes to the library or tests."
This reverts commit r286884, because it breaks the Xcode 7 builders:

  http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/1583

Here is a PR that tracks the issue:
https://llvm.org/bugs/show_bug.cgi?id=31016

llvm-svn: 287004
2016-11-15 18:48:36 +00:00
Stephan T. Lavavej 6d279e8e98 [libcxx] [test] D26627: Fix ordering assumptions in unordered container tests.
llvm-svn: 286984
2016-11-15 17:00:38 +00:00
Stephan T. Lavavej 64bac8b5fe [libcxx] [test] D26625: future_error::what() is implementation-defined.
llvm-svn: 286983
2016-11-15 17:00:32 +00:00
Stephan T. Lavavej 49188b1d3c [libcxx] [test] D26624: Fix bucket_count() assumptions.
With a max_load_factor of 1.0, the only guarantee is that
bucket_count() >= size(). (Note: setting max_load_factor without
rehashing isn't supposed to affect this, because setting
max_load_factor is currently specified to be constant time.)

llvm-svn: 286982
2016-11-15 17:00:24 +00:00
Marshall Clow f7182fe464 Missed one of the try blocks the first time :-(. Thanks to Renato for the heads up.
llvm-svn: 286932
2016-11-15 05:03:22 +00:00
Marshall Clow 48b520a7b6 P0503R0, adopted in Issaquah, rewords some requirements on nullptr_t and istream_iterator. No code changes were needed, but I updated a few tests. Also resolved P0509 and P0521, which required no changes to the library or tests.
llvm-svn: 286884
2016-11-14 20:41:17 +00:00
Marshall Clow 209fc55b01 Missed a test with exceptions disabled earlier. Oops.
llvm-svn: 286883
2016-11-14 20:38:43 +00:00
Marshall Clow 065b3af096 Implement P0516: 'Clarify That shared_future’s Copy Operations have Wide Contracts' which was adopted last week in Issaquah
llvm-svn: 286877
2016-11-14 19:58:05 +00:00
Marshall Clow 10e59fac3e Make one of the new tests fail correctly on pre-C++17 systems
llvm-svn: 286872
2016-11-14 19:35:34 +00:00
Marshall Clow 87f2f1687e Implement P0510 'Make future_error Constructible' adopted in Issaquah
llvm-svn: 286864
2016-11-14 18:56:24 +00:00
Marshall Clow 1c7fe126ee Fixes for LWG 2598, 2686, 2739, 2742, 2747, and 2759, which were adopted last week in Issaquah
llvm-svn: 286858
2016-11-14 18:22:19 +00:00
Stephan T. Lavavej 4dc0ed8390 [libcxx] [test] D26314: Fix MSVC warning C4189 "local variable is initialized but not referenced".
test/std/depr/depr.c.headers/inttypes_h.pass.cpp
test/std/input.output/file.streams/c.files/cinttypes.pass.cpp
test/std/input.output/iostream.forward/iosfwd.pass.cpp
Add test() to avoid a bunch of void-casts, although we still need a few.

test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp
skippingws was unused (it's unclear to me whether this was mistakenly copy-pasted from round_trip() below).

test/std/localization/locale.categories/category.collate/locale.collate/types.pass.cpp
test/std/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp
test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp
test/std/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp
test/std/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp
test/std/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp
test/std/localization/locales/locale.global.templates/use_facet.pass.cpp
When retrieving facets, the references are unused.

test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp
test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp
"std::ios_base::iostate err = ios.goodbit;" was completely unused here.

test/std/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp
test/std/numerics/c.math/ctgmath.pass.cpp
test/std/numerics/rand/rand.device/entropy.pass.cpp
test/std/numerics/rand/rand.device/eval.pass.cpp
test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp
test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp
test/std/thread/futures/futures.promise/dtor.pass.cpp
test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp
test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp
These variables are verifying types but are otherwise unused.

test/std/strings/basic.string/string.capacity/reserve.pass.cpp
old_cap was unused (it's unclear to me whether it was intended to be used).

test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp
test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp
test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp
test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp
test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp
test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp
test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp
These tests contained unused characters.

llvm-svn: 286847
2016-11-14 17:35:14 +00:00
Roger Ferrer Ibanez aa35ecfecd Protect std::ios tests under libcpp-no-exceptions
Skip tests that expect an exception be thrown. Also add
some missing asserts in the original test.

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

llvm-svn: 286823
2016-11-14 13:44:50 +00:00
Roger Ferrer Ibanez 059680f3f0 Protect nested-exceptions tests under no-exceptions
Differential Revision: https://reviews.llvm.org/D26458

llvm-svn: 286813
2016-11-14 11:00:28 +00:00
Roger Ferrer Ibanez 84c152a130 Update tests for strings conversions under libcpp-no-exceptions
Differential Revision: https://reviews.llvm.org/D26139

llvm-svn: 286812
2016-11-14 10:44:26 +00:00
Roger Ferrer Ibanez 4a152f147f Protect smart-pointer tests under no exceptions
Skip tests that expect an exception be thrown under no-exceptions.

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

llvm-svn: 286809
2016-11-14 10:27:56 +00:00
Eric Fiselier 79ff8f0375 Fix GCC libc++abi build
llvm-svn: 286783
2016-11-13 22:27:00 +00:00
Eric Fiselier 2371589266 Implement LWG 2770 - Make tuple_size<T> defined for all T
llvm-svn: 286779
2016-11-13 20:43:50 +00:00
Eric Fiselier 40905833b5 Fix PR30979 - tuple<move_only> is constructible from move_only const&
llvm-svn: 286774
2016-11-13 19:54:31 +00:00
Roger Ferrer Ibanez aee391b535 Protect bitset tests under libcpp-no-exceptions
Bitset tests feature a sequence of tests of increasing bitset sizes,
but these tests rely on exceptions when the bitset size is less than
50 elements.

This change adds a flag to tell whether a test should throw. If it must
throw it will be skipped under no-exceptions.

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

llvm-svn: 286474
2016-11-10 16:54:55 +00:00
Roger Ferrer Ibanez a5672e0c4b Protect std::experimental::optional tests under libcpp-no-exceptions
In these tests there are some paths that explicitly throw, so use
the TEST_THROW macro that was proposed for this and then skip the tests
that may enter the throwing path.

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

llvm-svn: 286099
2016-11-07 08:23:59 +00:00
Stephan T. Lavavej 0f901c7ec4 [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

llvm-svn: 286007
2016-11-04 20:26:59 +00:00
Marshall Clow 720ef47200 Implement another part of P0031; adding constexpr to move_iterator
llvm-svn: 285818
2016-11-02 15:30:26 +00:00
Roger Ferrer Ibanez 50e59f3b60 Remove spurious token from #endif
llvm-svn: 285792
2016-11-02 08:36:43 +00:00
Roger Ferrer Ibanez 8c6562398e Protect tests for new/delete under libcpp-no-exceptions
Skip the tests that expect an exception be thrown and protect unreachable catch blocks.

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

llvm-svn: 285791
2016-11-02 08:14:57 +00:00
Eric Fiselier 0b460e6bf8 Fix __libcpp_is_constructible for source types with explicit conversion operators.
Previously __libcpp_is_constructible checked the validity of reference
construction using 'eat<To>(declval<From>())' but this doesn't consider
From's explicit conversion operators. This patch teaches __libcpp_is_constructible
how to handle these cases. To do this we need to check the validity
using 'static_cast<To>(declval<From>())'. Unfortunately static_cast allows
additional base-to-derived and lvalue-to-rvalue conversions, which have to be
checked for and manually rejected.

While implementing these changes I discovered that Clang incorrectly
rejects `static_cast<int&&>(declval<float&>())` even though
`int &&X(declval<float&>())` is well formed. In order to tolerate this bug
the `__eat<T>(...)` needs to be left in-place. Otherwise it could be replaced
entirely with the new static_cast implementation.

Thanks to Walter Brown for providing the test cases.

llvm-svn: 285786
2016-11-02 03:57:34 +00:00
Roger Ferrer Ibanez 8a915ed644 Protect exceptional paths under libcpp-no-exceptions
These tests are of the form

try {
   action-that-may-throw
   assert(!exceptional-condition)
   assert(some-other-facts)
 } catch (relevant-exception) {
   assert(exceptional-condition)
 }

Under libcpp-no-exceptions there is still value in verifying
some-other-facts while avoiding the exceptional case. So for these tests
just conditionally check some-other-facts if exceptional-condition is
false. When exception are supported make sure that a true
exceptional-condition throws an exception

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

llvm-svn: 285697
2016-11-01 15:46:16 +00:00
Roger Ferrer Ibanez 60d6ef63a4 Protect lock tests under libcpp-no-exceptions
Skip tests that expect an exception to be thrown.

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

llvm-svn: 285695
2016-11-01 15:00:16 +00:00
Roger Ferrer Ibanez 8cba0befb4 Protect tests that expect an exception for an unknown std::random_device
Skip these tests under libcpp-no-exceptions.

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

llvm-svn: 285677
2016-11-01 08:11:12 +00:00
Roger Ferrer Ibanez c6a40d24d0 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

llvm-svn: 285572
2016-10-31 14:14:13 +00:00
Roger Ferrer Ibanez 3565c96d86 Change from "XFAIL: libcpp-no-exceptions" to "UNSUPPORTED: libcpp-no-exceptions" tests that only check exceptions and nothing else
This is a follow up of D24562.

These tests do not check anything but exceptions, so it makes sense to mark
them as UNSUPPORTED under a library built without exceptions.

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

llvm-svn: 285550
2016-10-31 08:47:53 +00:00
Eric Fiselier 7ca76565e7 Fix _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to always have default visibility.
This prevent the symbols from being both externally available and hidden, which
causes them to be linked incorrectly. This is only a problem when the address
of the function is explicitly taken since it will always be inlined otherwise.

This patch fixes the issues that caused r285456 to be reverted, and can
now be reapplied.

llvm-svn: 285531
2016-10-31 02:07:23 +00:00
Eric Fiselier 1467a197e5 Rewrite std::filesystem::path iterators and parser
This patch entirely rewrites the parsing logic for paths. Unlike the previous
implementation this one stores information about the current state; For example
if we are in a trailing separator or a root separator. This avoids the need for
extra lookahead (and extra work) when incrementing or decrementing an iterator.
Roughly this gives us a 15% speedup over the previous implementation.

Unfortunately this implementation is still a lot slower than libstdc++'s.
Because libstdc++ pre-parses and splits the path upon construction their
iterators are trivial to increment/decrement. This makes libc++ lazy parsing
100x slower than libstdc++. However the pre-parsing libstdc++ causes a ton
of extra and unneeded allocations when constructing the string. For example
`path("/foo/bar/")` would require at least 5 allocations with libstdc++
whereas libc++ uses only one. The non-allocating behavior is much preferable
when you consider filesystem usages like 'exists("/foo/bar/")'.

Even then libc++'s path seems to be twice as slow to simply construct compared
to libstdc++. More investigation is needed about this.

llvm-svn: 285526
2016-10-30 23:30:38 +00:00
Eric Fiselier d03a5ffcf6 Remove files missed in r285466
llvm-svn: 285469
2016-10-28 22:54:24 +00:00
Eric Fiselier a32a961b10 Fix test when using an installed libc++
llvm-svn: 285392
2016-10-28 11:01:12 +00:00
Eric Fiselier 64428acf41 Add more tests for optional<const T>
llvm-svn: 285384
2016-10-28 06:40:29 +00:00
Eric Fiselier 761e42fa3d Add __libcpp_version file and __libcpp_library_version function.
This patch does two seperate things. First it adds a file called
"__libcpp_version" which only contains the current libc++ version
(currently 4000). This file is not intended for use as a header. This file
is used by Clang in order to easily determine the installed libc++ version.
This allows Clang to enable/disable certain language features only when the
library supports them.

The second change is the addition of _LIBCPP_LIBRARY_VERSION macro, which
returns the version of the installed dylib since it may be different than
the headers.

llvm-svn: 285382
2016-10-28 06:06:50 +00:00
Tim Shen e776667441 [libcxx] Make regex_match backtrack when search fails
Summary:
Fixes PR19851.
alg.re.match/ecma.pass.cpp still XFAILS on linux, but after commenting out
locale-related tests, it passes. I don't have a freebsd machine to produce a
full pass.

Reviewers: mclow.lists

Subscribers: cfe-commits, emaste

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

llvm-svn: 285352
2016-10-27 21:40:34 +00:00
Stephan T. Lavavej 50b80c36fa [PATCH] D25483: [libcxx] [test] Fix non-Standard assumptions about how many elements are allocated
llvm-svn: 285346
2016-10-27 21:25:12 +00:00
Casey Carter be65b24a55 Cleanup nonportable behavior in tests for std::any
Fixes MS issues 63, 64, and 65.

test/std/utilities/any/any.class/any.cons/move.pass.cpp:
* "Moves are always destructive" is not a portable assumption; check with LIBCPP_ASSERT.

test/std/utilities/any/any.class/any.cons/value.pass.cpp:
* The standard does not forbid initializing std::any from any pointer-to-function type. Remove the non-conforming "DecayTag" test.

test/std/utilities/any/any.class/any.modifiers/swap.pass.cpp:
* Self-swap is not specified to perform no moves; check with LIBCPP_ASSERT.

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

llvm-svn: 285234
2016-10-26 20:18:13 +00:00
Casey Carter 9450d5e262 Silence unused parameter warnings in archetypes.hpp
Reviewed at: https://reviews.llvm.org/D25958

llvm-svn: 285213
2016-10-26 17:22:25 +00:00
Eric Fiselier 8f29ea36c3 Fix nullptr tests
llvm-svn: 285117
2016-10-25 20:45:17 +00:00
Eric Fiselier a905007f12 Fix non-portable tests for temp_directory_path(...)
llvm-svn: 285020
2016-10-24 20:40:35 +00:00
Eric Fiselier 4d4c79d8f5 Add missing include in string_view tests. Patch from Billy ONeil @ microsoft
llvm-svn: 285012
2016-10-24 20:11:17 +00:00
Eric Fiselier 009fb08d14 Fix shadow warnings in string_view tests. Patch from STL@microsoft.com
llvm-svn: 285011
2016-10-24 20:10:00 +00:00
Eric Fiselier d11fdad33e Backout enabling -Wshadow until I have time to fix the breakage
llvm-svn: 284952
2016-10-23 22:24:11 +00:00
Eric Fiselier 81a09f2c9e Fix libc++ specific assertion in permissions(...) tests
llvm-svn: 284945
2016-10-23 19:14:58 +00:00
Eric Fiselier b51325cefe Turn on -Wshadow so I find occurances before STL does
llvm-svn: 284944
2016-10-23 19:01:10 +00:00
Eric Fiselier 1e96d5380e Make make_from_tuple tests more portable. Patch from STL@microsoft.com
llvm-svn: 284943
2016-10-23 18:55:51 +00:00
Eric Fiselier eca753ad92 Fix unreferenced parameters. Patch from STL@microsoft.com
llvm-svn: 284942
2016-10-23 18:52:58 +00:00
Eric Fiselier d06ee7706c Fix shadowing warning. Patch from STL@microsoft.com
llvm-svn: 284941
2016-10-23 18:47:58 +00:00
Tim Shen abd1a6e687 [libcxx] Support std::regex_constants::match_not_null
Summary: Fixes PR21597.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

llvm-svn: 284881
2016-10-21 20:41:47 +00:00
Marshall Clow c1b73a1793 Adding a missing constexpr test for reverse_iterator operator[].
llvm-svn: 284731
2016-10-20 14:57:34 +00:00
Eric Fiselier db94496629 Attempt to workaround XPASS for aligned allocation tests
llvm-svn: 284691
2016-10-20 03:31:07 +00:00
Marshall Clow 1b8f260ed9 Implement constexpr support for reverse_iterator. Reviewed as https://reviews.llvm.org/D25534
llvm-svn: 284602
2016-10-19 15:12:50 +00:00
Eric Fiselier c5777f4d58 Make any_cast<void()>(nullptr) compile
llvm-svn: 284333
2016-10-16 11:56:38 +00:00
Eric Fiselier f72aaff994 Update LWG 2767 and add test case
llvm-svn: 284324
2016-10-16 03:45:06 +00:00
Eric Fiselier 015fcffd57 Update status for std::optional LWG issues and fix an optional SFINAE bug
llvm-svn: 284323
2016-10-16 03:21:35 +00:00
Eric Fiselier 50253ed1c6 Update issue status for LWG 2744
llvm-svn: 284322
2016-10-16 02:51:50 +00:00
Eric Fiselier 9c737fddba Update issue status for LWG 2768 and 2769
llvm-svn: 284321
2016-10-16 01:43:43 +00:00
Eric Fiselier ecafa8739e Implement LWG 2712 and update other issues status
llvm-svn: 284318
2016-10-16 00:47:59 +00:00
Eric Fiselier ae4c3e1699 Implement LWG 2681 and 2682
llvm-svn: 284316
2016-10-16 00:29:22 +00:00
Eric Fiselier 9ada18b339 Implement LWG 2672.
llvm-svn: 284314
2016-10-15 23:05:04 +00:00
Eric Fiselier 87ee8a0adb Implement modified LWG 2665
llvm-svn: 284313
2016-10-15 22:37:42 +00:00
Eric Fiselier bbcfec7edd Implement LWG2664 and update its status
llvm-svn: 284310
2016-10-15 21:29:44 +00:00
Eric Fiselier d2003575ce Prevent new/delete replacement tests from being optimized away.
llvm-svn: 284289
2016-10-14 22:47:08 +00:00
Eric Fiselier 797cb4f646 Clarify XFAIL comments
llvm-svn: 284282
2016-10-14 21:30:35 +00:00
Eric Fiselier 68696836d1 Work around Clang driver segfault when --coverage is used with -c and /dev/null
llvm-svn: 284225
2016-10-14 10:30:33 +00:00
Eric Fiselier 81b13934c1 XFAIL aligned allocation tests for older Clang versions
llvm-svn: 284214
2016-10-14 08:47:09 +00:00
Eric Fiselier 73bfe423fe XFAIL aligned allocation test failures with UBSAN
llvm-svn: 284210
2016-10-14 07:49:15 +00:00
Eric Fiselier 498ee00a3a Add void_t and invoke feature test macros
llvm-svn: 284209
2016-10-14 07:19:52 +00:00
Eric Fiselier 0ae4f23fdc Implement P0035R4 -- Add C++17 aligned allocation functions
Summary:
This patch implements the library side of P0035R4. The implementation is thanks to @rsmith.

In addition to the C++17 implementation, the library implementation can be explicitly turned on using `-faligned-allocation` in all dialects.


Reviewers: mclow.lists, rsmith

Subscribers: rsmith, cfe-commits

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

llvm-svn: 284206
2016-10-14 06:46:30 +00:00
Marshall Clow 6ecac73019 Implement http://wg21.link/p0302r1: Removing Allocator Support in std::function. These functions never worked, and as far as I know, no one ever called them.
llvm-svn: 284164
2016-10-13 21:06:03 +00:00
Marshall Clow bb1db210a8 Add missing include in test; NFC. Thanks to Jonathan Wakely for the report.
llvm-svn: 284120
2016-10-13 13:21:38 +00:00
Dimitry Andric ca2ab4f657 Disable trivial pair copy/move tests when unsupported
Summary:
On FreeBSD, for ABI compatibility reasons, the pair trivial copy
constructor is disabled, using the aptly-named
`_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR` define.

Disable the related tests when this define is on, so they don't fail
unexpectedly.

Reviewers: emaste, rsmith, theraven, EricWF

Subscribers: cfe-commits

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

llvm-svn: 284047
2016-10-12 20:26:47 +00:00
Eric Fiselier a9fcc1d2a4 Correctly grant rebound limited_allocators friendship.
llvm-svn: 284006
2016-10-12 11:35:37 +00:00
Eric Fiselier 609fb0cc40 Remove incorrect XFAILS
llvm-svn: 284005
2016-10-12 11:29:18 +00:00
Eric Fiselier d2c71a923e Unbreak C++03 build
llvm-svn: 284004
2016-10-12 11:20:27 +00:00
Eric Fiselier 6b42540756 Remove usages of _LIBCPP_CONSTEXPR under test/std
llvm-svn: 284002
2016-10-12 10:28:09 +00:00
Eric Fiselier 6ce45e0840 Remove usages of _ALIGNAS_TYPE
llvm-svn: 283999
2016-10-12 10:19:48 +00:00
Eric Fiselier 1b9327f332 support --param=std=gnu++XX
llvm-svn: 283997
2016-10-12 09:53:35 +00:00
Eric Fiselier 1c3203a2c1 Fix more C++11 constexpr issues in the tests
llvm-svn: 283996
2016-10-12 09:48:44 +00:00
Eric Fiselier 883cc25d9f Fix nasty_containers.hpp for other stdlibs
llvm-svn: 283994
2016-10-12 09:31:26 +00:00
Eric Fiselier 9b480b07f9 Fix use of C++14 constexpr in C++11
llvm-svn: 283993
2016-10-12 09:20:58 +00:00
Eric Fiselier 5e931dd232 Remove use of _VSTD::__invoke in the not_fn tests
llvm-svn: 283991
2016-10-12 09:06:12 +00:00
Eric Fiselier 411e1f8288 Protect special members of NullBase archetype to avoid exposing them
llvm-svn: 283983
2016-10-12 08:09:22 +00:00
Eric Fiselier a9e659619f 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

llvm-svn: 283980
2016-10-12 07:46:20 +00:00
Eric Fiselier fc647db3ee Revert Add <optional>. Will recommit with better commit message
llvm-svn: 283978
2016-10-12 06:48:31 +00:00
Eric Fiselier 6ee4001cc9 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.

llvm-svn: 283977
2016-10-12 06:45:11 +00:00
Eric Fiselier 49a278fb6d Fix two more tests that hang when testing against libstdc++
llvm-svn: 283976
2016-10-12 04:56:23 +00:00
Eric Fiselier 76e316f995 Prevent the test suite from hanging when run against libstdc++
llvm-svn: 283975
2016-10-12 04:29:50 +00:00
Eric Fiselier e04aebe904 Add mork workarounds for running the test suite against libstdc++
llvm-svn: 283960
2016-10-12 00:28:14 +00:00
Eric Fiselier 612c00df31 Make it easier to run the libc++ test suite against libstdc++
llvm-svn: 283958
2016-10-12 00:00:37 +00:00
Eric Fiselier e6364a35fd Fix LWG2683 - filesystem::copy() should always clear the user-provided error_code
llvm-svn: 283951
2016-10-11 22:18:09 +00:00
Eric Fiselier 9595fb21dd Fix std::pair on FreeBSD
Summary:
FreeBSD ships an old ABI for std::pair which requires that it have non-trivial copy/move constructors. Currently the non-trivial copy/move is achieved by providing explicit definitions of the constructors. This is problematic because it means the constructors don't SFINAE properly. In order to SFINAE copy/move constructors they have to be explicitly defaulted and hense non-trivial.

This patch attempts to provide SFINAE'ing copy/move constructors for std::pair while still making them non-trivial. It does this by adding a base class with a non-trivial copy constructor and then allowing pair's constructors to be generated by the compiler. This also allows the constructors to be constexpr.


Reviewers: emaste, theraven, rsmith, dim

Subscribers: cfe-commits

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

llvm-svn: 283944
2016-10-11 21:22:21 +00:00
Eric Fiselier e778d10c0f Fix incorrect exception handling behavior in the uninitialized algorithms
llvm-svn: 283941
2016-10-11 21:13:44 +00:00
Marshall Clow 089d54b540 Add tests to check that swap(std::function, std::function) is noexcept. This is LWG#2062, but we already do this. No changes to the library, just adding tests.
llvm-svn: 283780
2016-10-10 16:47:48 +00:00
Marshall Clow 610ad3a598 Add tests for LWG2544. We already implement this; just adding tests to make sure that we keep doing it.
llvm-svn: 283749
2016-10-10 14:10:45 +00:00
Eric Fiselier ac473034fc Provide a constexpr addressof with GCC 7.
__builtin_addressof was added to the GCC trunk in the past week. This patch
teaches libc++ about it so it can correctly provide constexpr addressof.

Unfortunately this patch will break users of earlier GCC 7 builds, since
we expect __builtin_addressof but one won't be provided. One option would be
to only use __builtin_addressof for GCC 7.1 and above, but that means
waiting for another release.

Instead I've specifically chosen to break older GCC 7 versions. Since GCC 7
has yet to be released, and the 7.0 release is a development release, I
believe that anybody currently using GCC 7.0 will have no issue upgrading.

llvm-svn: 283715
2016-10-10 05:34:18 +00:00
Eric Fiselier 054fc4cef6 Fix linker script generation for in-tree builds
llvm-svn: 283700
2016-10-09 21:34:03 +00:00
Eric Fiselier f03ffb2c9b Remove all _LIBCPP_VERSION tests from under test/std
llvm-svn: 283644
2016-10-08 01:32:56 +00:00
Eric Fiselier e58baed3a3 Purge all usages of _LIBCPP_STD_VER under test/std/algorithm
llvm-svn: 283643
2016-10-08 01:25:23 +00:00
Eric Fiselier b10fc37096 Add missing <memory> include in test
llvm-svn: 283633
2016-10-08 00:59:16 +00:00
Eric Fiselier 653179b77b Add missing include in test_allocator.h
llvm-svn: 283632
2016-10-08 00:57:56 +00:00
Eric Fiselier 69a4f66114 [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

llvm-svn: 283631
2016-10-08 00:56:22 +00:00
Eric Fiselier 609e669e1a Fix shadow warnings. Patch from STL@microsoft.com
llvm-svn: 283618
2016-10-07 22:10:35 +00:00
Eric Fiselier b18fd9654f 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.

llvm-svn: 283606
2016-10-07 21:27:45 +00:00
Eric Fiselier 89c9191447 Remove MSVC workarounds. Patch from STL@microsoft.com
llvm-svn: 283580
2016-10-07 18:51:33 +00:00
Asiri Rathnayake 08eb2148ff [libcxx] Recover no-exceptions XFAILs - I
First batch of changes to get some of these XFAILs working in the
no-exceptions libc++ variant.

Changed some XFAILs to UNSUPPORTED where the test is all about exception
handling. In other cases, used the test macros TEST_THROW and
TEST_HAS_NO_EXCEPTIONS to conditionally exclude those parts of the test
that concerns exception handling behaviour.

Reviewers: EricWF, mclow.lists

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

llvm-svn: 283441
2016-10-06 11:15:41 +00:00
Marshall Clow 23c725ebdf Comment out failing test while I figure out who is at fault
llvm-svn: 283360
2016-10-05 18:47:18 +00:00
Marshall Clow d836a9d5f1 Make tests for is_empty better. No functional change.
llvm-svn: 283339
2016-10-05 17:01:16 +00:00
Marshall Clow 67be6ff839 Add another append test for basic_string
llvm-svn: 283331
2016-10-05 15:47:13 +00:00
Eric Fiselier 015839a555 [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

llvm-svn: 283260
2016-10-04 21:25:51 +00:00
Marshall Clow 53abcbd8a9 Add tests to make sure that is_constructible<cv-void> is false. We already checked 'unqualified void'. This was brought up by LWG#2738
llvm-svn: 283161
2016-10-03 23:39:52 +00:00
Logan Chien 45e8ba88c3 [lit] Allow more file extensions for test cases.
This commit splits the file extensions before determining the test
format.  This allows libc++abi to add assembly-based test cases.

llvm-svn: 283118
2016-10-03 16:00:22 +00:00
Eric Fiselier 2c8c71f13e Remove all instances of _LIBCPP_HAS_NO_RVALUE_REFERENCES from test/std/utilities
llvm-svn: 283032
2016-10-01 10:46:01 +00:00
Eric Fiselier f18891050b Replace test_throw.h header with a single test macro
llvm-svn: 283030
2016-10-01 10:34:13 +00:00
Eric Fiselier c24e6dd3c8 [libc++] Extension: Make `move` and `forward` constexpr in C++11.
Summary:
`std::move` and `std::forward` were not marked constexpr in C++11.  This can be very damaging because it makes otherwise constant expressions non-constant. For example:

```
#include <utility>
template <class T>
struct Foo {
  constexpr Foo(T&& tx) :  t(std::move(tx)) {}
  T t;
};
[[clang::require_constant_initialization]] Foo<int> f(42); // Foo should be constant initialized but C++11 move is not constexpr. As a result `f` is an unsafe global.
```

This patch applies `constexpr` to `move` and `forward` as an extension in C++11. Normally the library is not allowed to add `constexpr` because it may be observable to the user. In particular adding constexpr may cause valid code to stop compiling. However these problems only happen in more complex situations, like making `__invoke(...)` constexpr. `forward` and `move` are simply enough that applying `constexpr` is safe. 

Note that libstdc++ has offered this extension since at least 4.8.1.

Most of the changes in this patch are simply test cleanups or additions. The main changes in the tests are:

* Fold all `forward_N.fail.cpp` tests into a single `forward.fail.cpp` test using -verify.
* Delete most `move_only_N.fail.cpp` tests because they weren't actually testing anything.
* Fold `move_copy.pass.cpp` and `move_only.pass.cpp` into a single `move.pass.cpp` test.
* Add return type and noexcept tests for `forward` and `move`.




Reviewers: rsmith, mclow.lists, EricWF

Subscribers: K-ballo, loladiro

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

llvm-svn: 282439
2016-09-26 20:55:02 +00:00
Eric Fiselier 221f689f3b Update -verify test to use new static assert message
llvm-svn: 282352
2016-09-25 08:30:05 +00:00
Eric Fiselier 54613ab4d4 [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

llvm-svn: 282347
2016-09-25 03:34:28 +00:00
Marshall Clow a8fd1e4be0 Fix a few static_asserts that need extra parens on -03
llvm-svn: 282343
2016-09-24 23:52:21 +00:00
Marshall Clow 54f0981ebd Implement proposed resolution for LWG#2758. Reviewed as D24446. Normally, I would wait for these to be voted upon at a committee meeting (November), but the current draft standard is broken, and this should fix it. (And if it doesn't, we want to know about it soonest)
llvm-svn: 282342
2016-09-24 22:45:42 +00:00
Marshall Clow 450370f3c8 Fix incorrect include in is_error_code_enum.pass.cpp
llvm-svn: 282332
2016-09-24 18:16:53 +00:00
Marshall Clow e69a08ba6d Implement is_error_code_v and is_error_condition_v for c++17. Rework the tests for is_error_code and is_error_condition, since they were really lacking. Thanks to Alisdair for the heads-up that we were missing these.
llvm-svn: 282331
2016-09-24 17:36:14 +00:00
Marshall Clow c669522a26 Fix failure on 03 bot
llvm-svn: 282134
2016-09-22 03:25:22 +00:00
Marshall Clow a48055cee3 Add missing _v traits. is_bind_expression_v, is_placeholder_v and uses_allocator_v
llvm-svn: 282126
2016-09-22 00:23:15 +00:00
Asiri Rathnayake a6199170ac [libcxx] Add missing c++98 xfail. NFC.
This is the only test failing in c++98 mode at the moment.

llvm-svn: 281731
2016-09-16 14:32:19 +00:00