Commit Graph

44 Commits

Author SHA1 Message Date
Zoe Carver
5625778f5c This patch makes swap functions constexpr. Both swap overloads, swap_ranges and iter_swap are updated (with tests).
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@365238 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-05 20:13:34 +00:00
Marshall Clow
b6e011b18b Add include for 'test_macros.h' to all the tests that were missing them. Thanks to Zoe for the (big, but simple) patch. NFC intended.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@362252 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 18:35:30 +00:00
Louis Dionne
9807685d51 [libc++] Enable deprecation warnings by default
Summary:
In r342843, I added deprecation warnings to some facilities that were
deprectated in C++14 and C++17. However, those deprecation warnings
were not enabled by default.

After discussing this on IRC, we had finally gotten consensus to enable
those warnings by default, and I'm getting around to doing that only
now.

Reviewers: mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, jdoerfert, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@355961 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-12 20:10:06 +00:00
JF Bastien
e15dd4e32e Support tests in freestanding
Summary:
Freestanding is *weird*. The standard allows it to differ in a bunch of odd
manners from regular C++, and the committee would like to improve that
situation. I'd like to make libc++ behave better with what freestanding should
be, so that it can be a tool we use in improving the standard. To do that we
need to try stuff out, both with "freestanding the language mode" and
"freestanding the library subset".

Let's start with the super basic: run the libc++ tests in freestanding, using
clang as the compiler, and see what works. The easiest hack to do this:

In utils/libcxx/test/config.py add:

  self.cxx.compile_flags += ['-ffreestanding']

Run the tests and they all fail.

Why? Because in freestanding `main` isn't special. This "not special" property
has two effects: main doesn't get mangled, and main isn't allowed to omit its
`return` statement. The first means main gets mangled and the linker can't
create a valid executable for us to test. The second means we spew out warnings
(ew) and the compiler doesn't insert the `return` we omitted, and main just
falls of the end and does whatever undefined behavior (if you're luck, ud2
leading to non-zero return code).

Let's start my work with the basics. This patch changes all libc++ tests to
declare `main` as `int main(int, char**` so it mangles consistently (enabling us
to declare another `extern "C"` main for freestanding which calls the mangled
one), and adds `return 0;` to all places where it was missing. This touches 6124
files, and I apologize.

The former was done with The Magic Of Sed.

The later was done with a (not quite correct but decent) clang tool:

  https://gist.github.com/jfbastien/793819ff360baa845483dde81170feed

This works for most tests, though I did have to adjust a few places when e.g.
the test runs with `-x c`, macros are used for main (such as for the filesystem
tests), etc.

Once this is in we can create a freestanding bot which will prevent further
regressions. After that, we can start the real work of supporting C++
freestanding fairly well in libc++.

<rdar://problem/47754795>

Reviewers: ldionne, mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, arphaman, miyuki, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@353086 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-04 20:31:13 +00:00
Marshall Clow
e7e7b2e6bd D14686: 'Protect against overloaded comma in random_shuffle and improve tests' I had to cut back on the tests with this, because they were not C++03 friendly. Thanks to gribozavr for the patch
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@352087 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-24 19:20:19 +00:00
Chandler Carruth
7c3769df62 Update more file headers across all of the LLVM projects in the monorepo
to reflect the new license. These used slightly different spellings that
defeated my regular expressions.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@351648 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 10:56:40 +00:00
Eric Fiselier
01fac08922 Tolerate Clangs new static_assert messages
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@349189 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-14 20:42:36 +00:00
Stephan T. Lavavej
c538ab0daa [libcxx] [test] Fix whitespace, NFC.
test/std almost always uses spaces; now it is entirely tab-free.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@329978 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-12 23:56:22 +00:00
Stephan T. Lavavej
bf3a3685cf [libcxx] [test] Use TEST_COMPILER_C1XX.
Also TEST_COMPILER_CLANG in one place. (More could be changed.)

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@329977 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-12 23:56:17 +00:00
Stephan T. Lavavej
a2b7665eb2 [libcxx] [test] Strip trailing whitespace, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324959 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-12 22:54:35 +00:00
Marshall Clow
63be4189d8 Another batch of P0202 constepr algirithms. remove/remove_if/remove_copy/remove_copy_if/reverse_copy, and tests (commented out) for rotate_copy, because that depends on std::copy
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323152 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 21:43:04 +00:00
Marshall Clow
a15161a030 Still more P0202 constexpr-ifying. This batch is: for_each/for_each_n/lexicographical_compare
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323147 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 20:44:33 +00:00
Marshall Clow
c84b496981 Add (commented out) constexpr tests for copy/copy_backwards/copy_if/copy_n. These will be enabled when that part of P0202 is implemented. NFC at this time.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323137 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 18:38:18 +00:00
Marshall Clow
48a4655868 More P0202 constexpr work. This commit adds fill/fill_n/generate/generate_n/unique/unique_copy. I removed a specialization of fill_n that recognized when we were dealing with raw pointers and 1 byte trivially-assignable types and did a memset, because the compiler will do that optimization for us.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323050 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-20 20:14:32 +00:00
Marshall Clow
a75d61347e More P0202 constexpr-ifying in <algorithm>. This commit handles replace/replace_if/replace_copy/replace_copy_if.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322975 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-19 18:07:29 +00:00
Marshall Clow
ecd1909f5f More P0202 constexpr-ifying in <algorithm>. This commit handles 'transform'.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322970 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-19 17:45:39 +00:00
Marshall Clow
82091c2583 Some of the tests from earlier today had 'int' as the return type when it should have been 'bool'. Fix that. It doesn't change the behavior of any of the tests, but it's more accurate.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322505 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-15 19:32:32 +00:00
Marshall Clow
bb8010f6f2 partition_point gets the P0202 treatment
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322493 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-15 17:53:34 +00:00
Marshall Clow
8d0d82585a First part of P0202: Adding constexpr modifiers to functions in <algorithm> and <utility>. This commit is all the is_XXX algorithms.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322489 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-15 16:16:32 +00:00
Stephan T. Lavavej
dd2a900c0b [libcxx] [test] Fix MSVC warnings, null pointer deref.
test/std/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp
Silence MSVC warning C4244. This is expected when passing
floating-point values for size.

test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
Avoid MSVC "warning C4293: '<<': shift count negative or too big,
undefined behavior". MSVC sees (1ULL << N) and warns - being guarded
by const bool canFit is insufficient. A small change to the code
avoids the warning without the need for a pragma.

Remove a spurious printf() declaration from to_ullong.pass.cpp.

Change ULL to UL in to_ulong.pass.cpp. The ULL suffix was
probably copy-pasted.

test/std/utilities/tuple/tuple.general/ignore.pass.cpp
Use LIBCPP_STATIC_ASSERT for consistency with other files.

test/support/container_test_types.h
Fix a null pointer dereference, found by MSVC /analyze
warning C6011 "Dereferencing NULL pointer 'm_expected_args'."

Fixes D41030.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@320535 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13 00:51:27 +00:00
Marshall Clow
aeded2bf6e Fix PR#35948: generate_n does not accept floating point Size arguments.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@319675 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-04 18:59:14 +00:00
Stephan T. Lavavej
559442652c [libcxx] [test] Strip trailing whitespace. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302105 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 01:43:58 +00:00
Eric Fiselier
6b17a7ba2c Cleanup _LIBCPP_HAS_NO_<c++11-feature> in algorithm
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300625 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 23:26:47 +00:00
Marshall Clow
50e32f569c Update the algorithm tests to not use the (deprecated) function binders. No functional change.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298618 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23 16:13:50 +00:00
Marshall Clow
699c414d73 Use 'REQUIRES: c++98 || c++03 || c++11 || c++14' instead of the deprecated 'REQUIRES-ANY: c++98, c++03, c++11, c++14'
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298600 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23 14:20:43 +00:00
Marshall Clow
03b862f6ea Remove random_shuffle in C++17. Please use shuffle instead. If you have to, you cant get it back by defining _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE before including any libc++ headers.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298597 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23 13:43:37 +00:00
Eric Fiselier
a2cd270943 Enable the -Wsign-compare warning to better support MSVC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289363 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-11 05:31:00 +00:00
Stephan T. Lavavej
f1cc7ff4c9 [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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289110 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 21:38:44 +00:00
Stephan T. Lavavej
3bea61851a [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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288747 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 01:13:29 +00:00
Stephan T. Lavavej
21208822a8 [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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288746 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 01:13:14 +00:00
Eric Fiselier
29616b3806 Work around more -Wshadow warnings
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288573 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-03 02:26:28 +00:00
Stephan T. Lavavej
0252201f9e [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.)

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@287383 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-18 21:54:43 +00:00
Marshall Clow
698cce6e0e Add missing include in test; NFC. Thanks to Jonathan Wakely for the report.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284120 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-13 13:21:38 +00:00
Eric Fiselier
917af0a073 Implement C++17 std::sample.
This patch implements the std::sample function added to C++17 from LFTS. It
also removes the std::experimental::sample implementation which now forwards
to std::sample.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279948 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-28 22:14:37 +00:00
Eric Fiselier
17c38db650 Mark LWG 2716 as complete - shuffle and sample disallows lvalue URNGs.
Libc++'s implementation of shuffle and sample already support lvalue and rvalue
RNG's. This patch adds tests for both categories and marks the issue as complete.

This patch also contains drive-by change for std::experimental::sample which
improves the diagnostics produced when the correct iterator categories are
not supplied.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279947 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-28 21:55:00 +00:00
Eric Fiselier
aafdbda646 Fix portability issues in <random> tests. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276585 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-24 23:36:18 +00:00
Eric Fiselier
84acb1ec3f Remove trailing whitespace in test suite. Approved by Marshall Clow.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271435 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-01 21:35:39 +00:00
Eric Fiselier
3a07a2f4f3 Fix warnings in test/std/algorithms
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242626 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-18 21:53:16 +00:00
Eric Fiselier
31cb7fe75e [libcxx] Properly convert the count arguments to the *_n algorithms before use.
Summary:
The requirement on the `Size` type passed to *_n algorithms is that it is convertible to an integral type. This means we can't use a variable of type `Size` directly. Instead we need to convert it to an integral type first.  The problem is finding out what integral type to convert it to.  `__convert_to_integral` figures out what integral type to convert it to and performs the conversion, It also promotes the resulting integral type so that it is at least as big as an integer. `__convert_to_integral` also has a special case for converting enums. This should only work on non-scoped enumerations because it does not apply an explicit conversion from the enum to its underlying type.



Reviewers: chandlerc, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D7449

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@228704 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-10 16:46:42 +00:00
Dimitry Andric
e64ec52760 Test commit: remove whitespace at EOL.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@228280 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-05 07:26:14 +00:00
Marshall Clow
a0ec4b7c85 Fix PR#22433. The algorithm is_partitioned was testing an item in the middle of the sequence twice.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@227824 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-02 18:16:35 +00:00
Marshall Clow
eea9d20edb Removed some tabs that snuck into the test suite. No functionality change
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@227363 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-28 20:26:11 +00:00
Marshall Clow
fd8ed7fa85 Fix PR 22106; make std::swap work for multi-dimensional arrays. Thanks to Peter Griess for the report and suggested fix
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@225285 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-06 19:20:49 +00:00
Eric Fiselier
a90c6dd460 Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-20 01:40:03 +00:00