Commit Graph

3424 Commits

Author SHA1 Message Date
Eric Fiselier e297b527a1 Fix count_new.hpp to work w/o dynamic exception specifications
llvm-svn: 289355
2016-12-11 02:20:17 +00:00
Eric Fiselier 0d542d350d [libc++] Fix support for multibyte thousands_sep and decimal_point in moneypunct_byname and numpunct_byname.
Summary:
The underlying C locales provide the `thousands_sep` and `decimal_point` as strings, possible with more than one character. We currently don't handle this case even for `wchar_t`.

This patch properly converts the mbs -> wide character for `moneypunct_byname<wchar_t>`. For the `moneypunct_byname<char>` case we attempt to narrow the WC and if that fails we also attempt to translate it to some reasonable value. For example we translate U00A0 (non-breaking space) into U0020 (regular space). If none of these conversions succeed then we simply allow the base class to provide a fallback value.


Reviewers: mclow.lists, EricWF

Subscribers: vangyzen, george.burgess.iv, cfe-commits

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

llvm-svn: 289347
2016-12-11 00:20:59 +00:00
Stephan T. Lavavej aec1876601 [libcxx] [test] Fix string_view tests.
test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
Passing -1 to size_t triggers signed/unsigned mismatch warnings because it's
a value-modifying conversion. Add static_cast<size_t> to soothe the compiler.
(This file refers to size_t unqualified.)

test/std/strings/string.view/string.view.ops/substr.pass.cpp
Add <algorithm> for std::min() and <stdexcept> for std::out_of_range.

N4618 21.4.2.4 [string.view.access]/1: "Requires: pos < size()."
/4: "[ Note: Unlike basic_string::operator[], basic_string_view::operator[](size())
has undefined behavior instead of returning charT(). -end note ]"

Fixes D27633.

llvm-svn: 289283
2016-12-09 22:35:53 +00:00
Stephan T. Lavavej 8a597d653a [libcxx] [test] Add LIBCPP_ASSERT_NOEXCEPT/LIBCPP_ASSERT_NOT_NOEXCEPT, remove an unused variable.
test/support/test_macros.h
For convenience/greppability, add macros for libcxx-specific static_asserts about noexceptness.

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

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

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

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

Fixes D27622.

llvm-svn: 289264
2016-12-09 19:53:08 +00:00
Eric Fiselier fb1fb81406 Update doc version to 4.0
llvm-svn: 289206
2016-12-09 12:33:49 +00:00
Eric Fiselier 642d9a1e48 [NFC] Change whitespace to force docs rebuild
llvm-svn: 289205
2016-12-09 12:32:02 +00:00
Eric Fiselier 41b4d6c8ff Fix missing const on set::count. Patch from Andrey Khalyavin
llvm-svn: 289204
2016-12-09 12:17:31 +00:00
Eric Fiselier 43a7f2c53b Refactor uses_allocator test types for upcoming fixes
llvm-svn: 289197
2016-12-09 09:51:09 +00:00
Eric Fiselier 0ef3b1b10a Put C++ ABI headers in a special build directory instead of the top level.
This patch changes where the C++ ABI headers are put during the build. Previously
    they were put in the top level include directory (not the libc++ header directory).
    However that just polutes the top level directory. Instead this patch creates a special
    directory to put them in. The reason they can't be put under c++/v1 until after the build
    is because libc++ uses the in-source headers, so we can't add the include path of the libc++
    headers in the object dir.

    Additionally this patch teaches the test suite how to find the ABI headers,
    and adds a demangling utility to help debug tests with.

llvm-svn: 289195
2016-12-09 09:31:01 +00:00
Eric Fiselier 217c5d36bb fix misspelling in .clang-format
llvm-svn: 289178
2016-12-09 03:18:45 +00:00
Eric Fiselier 949e47daed Turn off header sorting and comment formatting
llvm-svn: 289177
2016-12-09 03:17:25 +00:00
Eric Fiselier bd688258ba Fix PR27374 - Remove the implicit reduced-arity-extension in tuple.
This patch removes libc++'s tuple extension which allowed it to be
constructed from fewer initializers than elements; with the remaining
elements being default constructed. However the implicit version of
this extension breaks conforming code. For example:

    int fun(std::string);
    int fun(std::tuple<std::string, int>);
    int x = fun("hello"); // ambigious

Because existing code may already depend on this extension it can be re-enabled
by defining _LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION.

Note that the explicit version of this extension is still supported,
although it's somewhat less useful than the implicit one.

llvm-svn: 289158
2016-12-08 23:57:08 +00:00
Stephan T. Lavavej f2e24f568b [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 7/7.
test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp
Add static_cast<char> because basic_istream::get() returns int_type (N4606 27.7.2.3 [istream.unformatted]/4).

test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
Add static_cast<char> because toupper() returns int (C11 7.4.2.2/1).

test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp
This test is intentionally writing doubles to ostream_iterator<int>.
It's silencing -Wliteral-conversion for Clang, so I'm adding C4244 silencing for MSVC.

test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
Given `extern float zero;`, the expression `1./zero` has type double, which emits a truncation warning
when being passed to test<float>() taking float. The fix is to say `1.f/zero` which has type float.

test/std/numerics/complex.number/cmplx.over/arg.pass.cpp
test/std/numerics/complex.number/cmplx.over/norm.pass.cpp
These tests were constructing std::complex<double>(x, 0), emitting truncation warnings when x is long long.
Saying static_cast<double>(x) avoids this.

test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp
This was using `int s` to construct and seed a linear_congruential_engine<T, stuff>, where T is
unsigned short/unsigned int/unsigned long/unsigned long long. That emits a truncation warning in the
unsigned short case. Because the range [0, 20) is tiny and we aren't doing anything else with the index,
we can just iterate with `T s`.

test/std/re/re.traits/value.pass.cpp
regex_traits<wchar_t>::value()'s first parameter is wchar_t (N4606 28.7 [re.traits]/13). This loop is
using int to iterate through ['g', 0xFFFF), emitting a truncation warning from int to wchar_t
(which is 16-bit for some of us). Because the bound is exclusive, we can just iterate with wchar_t.

test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
This test is a little strange. It's trying to verify that basic_string's (InIt, InIt) range constructor
isn't confused by "N copies of C" when N and C have the same integral type. To do this, it was
testing (100, 65), but that eventually emits truncation warnings from int to char. There's a simple way
to avoid this - passing (static_cast<char>(100), static_cast<char>(65)) also exercises the disambiguation.
(And 100 is representable even when char has a signed range.)

test/std/strings/string.view/string.view.hash/string_view.pass.cpp
Add static_cast<char_type> because `'0' + i` has type int.

test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
What's more horrible than nested bind()? pow() overloads! This operator()(T a, T b) was assuming that
std::pow(a, b) can be returned as T. (In this case, T is int.) However, N4606 26.9.1 [cmath.syn]/2
says that pow(int, int) returns double, so this was truncating double to int.
Adding static_cast<T> silences this.

test/std/utilities/function.objects/unord.hash/integral.pass.cpp
This was iterating `for (int i = 0; i <= 5; ++i)` and constructing `T t(i);` but that's truncating
when T is short. (And super truncating when T is bool.) Adding static_cast<T> silences this.

test/std/utilities/utility/exchange/exchange.pass.cpp
First, this was exchanging 67.2 into an int, but that's inherently truncating.
Changing this to static_cast<short>(67) avoids the truncation while preserving the
"what if T and U are different" test coverage.
Second, this was exchanging {} with the explicit type float into an int, and that's also
inherently truncating. Specifying short is just as good.

test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
Add static_cast<short>. Note that this affects template argument deduction for make_pair(),
better fulfilling the test's intent. For example, this was saying
`typedef std::pair<int, short> P1; P1 p1 = std::make_pair(3, 4);` but that was asking
make_pair() to return pair<int, int>, which was then being converted to pair<int, short>.
(pair's converting constructors are tested elsewhere.)
Now, std::make_pair(3, static_cast<short>(4)) actually returns pair<int, short>.
(There's still a conversion from pair<nullptr_t, short> to pair<unique_ptr<int>, short>.)

Fixes D27544.

llvm-svn: 289111
2016-12-08 21:38:57 +00:00
Stephan T. Lavavej 4e19c47556 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 6/7.
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
(Affects 64-bit architectures.) Include <cstddef> so we can take/return std::ptrdiff_t
(instead of int) in random_shuffle()'s RNG. (C++14 D.12 [depr.alg.random.shuffle]/2 says that
difference_type is used, and we're shuffling a plain array.)

test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
(Affects 64-bit architectures.) Include <iterator> because we're already using iterator_traits.
Then, store the result of subtracting two RanIts as difference_type instead of long
(which truncates on LLP64 architectures like MSVC x64).

test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp
test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
(Affects 64-bit architectures.) Include <cstddef> so we can store the result of
subtracting two pointers as std::ptrdiff_t (instead of int).

test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp
(Affects 32-bit architectures.) Sometimes, size_t is too small. That's the case here,
where tellg() returns pos_type (N4606 27.7.2.3 [istream.unformatted]/39). Implementations can
have 64-bit pos_type (to handle large files) even when they have 32-bit size_t.

Fixes D27543.

llvm-svn: 289110
2016-12-08 21:38:44 +00:00
Stephan T. Lavavej a0d87857e0 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7.
Instead of storing double in double and then truncating to int, store int in long
and then widen to long long. This preserves test coverage (as these tests are
interested in various tuple conversions) while avoiding truncation warnings.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
Since we aren't physically truncating anymore, t1 is equal to p0.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
One edit is different from the usual pattern. Previously, we were storing
double in double and then converting to A, which has an implicitly converting
constructor from int. Now, we're storing int in int and then converting to A,
avoiding the truncation.

Fixes D27542.

llvm-svn: 289109
2016-12-08 21:38:32 +00:00
Stephan T. Lavavej 84ade982a2 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 4/7.
Change char to long and remove some char casts. This preserves test coverage for tuple's
heterogeneous comparisons, while avoiding int-to-char truncation warnings.

Fixes D27541.

llvm-svn: 289108
2016-12-08 21:38:23 +00:00
Stephan T. Lavavej 7abade3769 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 3/7.
Add static_cast<short> when constructing pair<Whatever, short> from (Something, int).

Fixes D27540.

llvm-svn: 289107
2016-12-08 21:38:14 +00:00
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
Eric Fiselier 4879815600 Fix PR30323: numeric_limits<T>::max_digits10 when using 16 bit ints.
Summary: Also see https://llvm.org/bugs/show_bug.cgi?id=30323

Reviewers: mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 289029
2016-12-08 07:30:01 +00:00
Eric Fiselier 900efb2f1a Fix _LIBCPP_VERSION tests with modules on Darwin
llvm-svn: 289028
2016-12-08 06:37:41 +00:00
Eric Fiselier 2c482d3f01 Revert r288787: Add missing stdbool.h module.
Reverting because I didn't properly test this patch. Although it's probably
correct to add a stdbool_h module I thought the change fixed more than it did.
I'll re-commit after more investigation.

llvm-svn: 288789
2016-12-06 09:48:32 +00:00
Eric Fiselier d9cbffb0df Add missing stdbool.h module. The test suite now passes on OS X with modules
llvm-svn: 288787
2016-12-06 09:41:50 +00:00
Eric Fiselier 4facc13108 Fix stdio module build on OS X
llvm-svn: 288778
2016-12-06 07:40:46 +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
Eric Fiselier 25af0418da Fix C++03 modules build
llvm-svn: 288755
2016-12-06 01:34:24 +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 e1f72557c2 Add module definitions for <experimental/foo> headers
llvm-svn: 288735
2016-12-05 23:55:34 +00:00
Eric Fiselier ca648c9787 Add module definitions for string_view
llvm-svn: 288733
2016-12-05 23:53:23 +00:00
Eric Fiselier 392aa10811 Add modules for any/optional/variant
llvm-svn: 288730
2016-12-05 23:33:19 +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
Shoaib Meenai fc6100c195 [libc++] Add _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
It's useful to be able to disable visibility annotations entirely; for
example, if we're building libc++ static to include in another library,
and we don't want any libc++ functions getting exported out of that
library. This is a generalization of _LIBCPP_DISABLE_DLL_IMPORT_EXPORT.

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

llvm-svn: 288690
2016-12-05 19:40:12 +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 11b932b0d9 Update status page for variant implementation
llvm-svn: 288625
2016-12-04 22:14:53 +00:00
Eric Fiselier 02460bac8b Choose better hash values for std::monostate and valueless variants.
Previously these hashes were 0 and -1 respectively. These seem like common
sentinel values and should be avoided to prevent needless collisions.

This patch changes those values to different arbitrary numbers, which should
hopefully cause less collisions. Because I couldn't help myself I choose the
fundamental constants for gravity and the speed of light.

llvm-svn: 288623
2016-12-04 21:37:37 +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 613dc646d3 Make make_exception_ptr abort with -fno-exceptions
llvm-svn: 288575
2016-12-03 03:22:11 +00:00
Eric Fiselier 9a0b4abbba Mark various <variant> items as complete
llvm-svn: 288574
2016-12-03 02:47:40 +00:00
Eric Fiselier 46fcbb4da4 Work around more -Wshadow warnings
llvm-svn: 288573
2016-12-03 02:26:28 +00:00
Eric Fiselier 63322af698 Fix <variant> w/o exception support
llvm-svn: 288571
2016-12-03 01:58:07 +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 5877920183 Fix C++03 build
llvm-svn: 288555
2016-12-02 23:41:18 +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 cb3ef1561d Fix generated warnings in <variant>
llvm-svn: 288552
2016-12-02 23:17:33 +00:00
Eric Fiselier c7a28dee10 Update darwin ABI list for <variant>
llvm-svn: 288551
2016-12-02 23:14:18 +00:00
Eric Fiselier aa97dee358 Update ABI lists for <variant>
llvm-svn: 288550
2016-12-02 23:11:28 +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
Aditya Kumar b9775795a8 [libcxx] remove unused code
The macro _LIBCPP_UNROLL_LOOPS isn't used anywhere
so the code was dead.

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

llvm-svn: 288143
2016-11-29 14:43:42 +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
Shoaib Meenai 4304955545 [libc++] Remove unneeded visibility pragmas
The function definitions being guarded by the pragma were all static, so
they wouldn't be exported anyway. In any case, we should prefer the
visibility macros. No functional change.

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

llvm-svn: 287768
2016-11-23 16:11:15 +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 198955536e Allow libc++ to use modules in C++03.
Libc++ internal uses <atomic> in C++03 code but the module map forbids its use.
This causes the libc++ 'std' module to fail to build in C++03.

This patch removes the requirement to fix this issue.

llvm-svn: 287693
2016-11-22 20:15:39 +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 3028189ee3 Cleanup module.modulemap
llvm-svn: 287687
2016-11-22 20:00:21 +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