Commit Graph

97 Commits

Author SHA1 Message Date
Nico Weber
28db4445e2 libcxx: Rename .hpp files in libcxx/test/support to .h
LLVM uses .h as its extension for header files.

Files renamed using:

    for f in libcxx/test/support/*.hpp; do git mv $f ${f%.hpp}.h; done

References to the files updated using:

    for f in $(git diff master | grep 'rename from' | cut -f 3 -d ' '); do
        a=$(basename $f);
        echo $a;
        rg -l $a libcxx | xargs sed -i '' "s/$a/${a%.hpp}.h/";
    done

HPP include guards updated manually using:

    for f in $(git diff master | grep 'rename from' | cut -f 3 -d ' '); do
      echo ${f%.hpp}.h ;
    done | xargs mvim

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@369481 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-21 00:14:12 +00:00
Marshall Clow
b9f7426583 Fix a couple of unguarded operator, calls in algorithm. Fixes PR#43063. Updated all the heap tests to check this.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@369448 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-20 21:31:51 +00:00
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
Marshall Clow
ff04a5678c Add missing include to test. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@349639 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-19 16:39:04 +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
Marshall Clow
fa1a3d5c91 One more local type warning removed from the tests. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344421 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-12 21:59:32 +00:00
Eric Fiselier
c39fe08b20 Add diagnostics for min/max algorithms when a InputIterator is used.
These algorithms require a ForwardIterator or better. Ensure
we diagnose the contract violation at compile time instead of
of silently doing the wrong thing.

Further algorithms will be audited in upcoming patches.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@340426 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 17:47:13 +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
Eric Fiselier
b173b26b9e Work around GCC constexpr initialization bug
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324165 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-03 01:48:21 +00:00
Peter Collingbourne
27c341db41 Fix the BinaryPredicate form of std::is_permutation to not rely on operator==
According to [1], forms 2 and 4 of std::is_permutation should use the passed in
binary predicate to compare elements. operator== should only be used for forms
1 and 3 which do not take a binary predicate.

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

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

Patch by Thomas Anderson!

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323563 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-26 21:23:27 +00:00
Marshall Clow
5b12e3bdb4 Last batch of P0202 constexpr additions: includes/set_intersection/exchange
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323159 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 23:10:40 +00:00
Marshall Clow
63be4189d8 Another batch of P0202 constepr algirithms. remove/remove_if/remove_copy/remove_copy_if/reverse_copy, and tests (commented out) for rotate_copy, because that depends on std::copy
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323152 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 21:43:04 +00:00
Marshall Clow
a15161a030 Still more P0202 constexpr-ifying. This batch is: for_each/for_each_n/lexicographical_compare
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323147 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 20:44:33 +00:00
Marshall Clow
c84b496981 Add (commented out) constexpr tests for copy/copy_backwards/copy_if/copy_n. These will be enabled when that part of P0202 is implemented. NFC at this time.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323137 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 18:38:18 +00:00
Marshall Clow
27ae75c894 Really comment out the constexpr tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323072 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 01:51:49 +00:00
Marshall Clow
f7e345ab81 implement (but leave commented out) the constexpr tests from P0202 for std::merge. merge requires std::copy, which isn't constexpr yet.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323070 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 00:11:44 +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
Eric Fiselier
457d2c157b Fix most GCC test failures.
This patch fixes almost all currently failing tests when
using GCC ToT.

The specific changes are:

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

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

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322810 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-18 03:41:06 +00:00
Marshall Clow
d6082200f6 More constexpr algorithms from P0202. search/search_n
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322566 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 15:48:27 +00:00
Marshall Clow
39b886259e More constexpr algorithms from P0202: lower_bound, upper_bound, equal_range, binary_search
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322529 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 02:34:41 +00:00
Marshall Clow
f1caa62ccd Actually CALL the constexpr tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322528 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 02:11:13 +00:00
Marshall Clow
4cd596538b More constexpr (re P0202) - equal and mismatch
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322527 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 02:04:10 +00:00
Marshall Clow
5af38a078e Fix constexpr failure on C++11-based buildbots.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322507 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-15 19:59:09 +00:00
Marshall Clow
0dc8ca7729 More constexpr from P0202. count and count_if. Also fix a comment that Morwenn noted.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322506 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-15 19:40:34 +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
6a1c2ffea4 More P0202 constexpr-ifying. All the find_XXX algorithms in this commit.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322504 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-15 19:26:05 +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
de4b2869d7 More constexpr algorithms from P0202. any_of/all_of/none_of.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322492 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-15 17:20:36 +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
Marshall Clow
210d12c946 Fix misspelled macro name - thanks to andrew@ispras.ru for the catch
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322196 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-10 16:25:04 +00:00
Marshall Clow
334063336b Add the C++17 extensions to std::search. Include the default searcher, but not the Boyer-Moore or Boyer-Moore-Horspool searcher (yet). BUT put the BM and BMH tests in place, marked to XFAIL. The other searchers will follow soon
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322019 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-08 19:18:00 +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
Billy Robert O'Neal III
7e250fcdc1 Change (void) casts to TEST_IGNORE_NODISCARD, as requested by Eric. Reviewed as https://reviews.llvm.org/D40065
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318804 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-21 21:37:26 +00:00
Billy Robert O'Neal III
b981667776 Tolerate even more [[nodiscard]] in the STL. Reviewed as https://reviews.llvm.org/D39080
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318277 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-15 07:45:07 +00:00
Marshall Clow
3b8f03d964 Mark test as unsupported on C++98/03, since it uses move_iterator
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@316917 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30 16:07:59 +00:00
Marshall Clow
c3fa9655a4 Fix PR#35119 : set_union misbehaves with move_iterators. Thanks to Denis Yaroshevskiy for both the bug report and the fix.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@316914 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30 15:50:00 +00:00
Marshall Clow
90dfa2804a Fix test for C++03
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@311967 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-29 01:10:51 +00:00
Marshall Clow
25a78dcd77 Fix PR31166: std::inplace_merge seems to be unstable. Thanks to Jan Wilken Dörrie for the suggested fix.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@311952 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-28 23:16:13 +00:00
Stephan T. Lavavej
5d91f314f1 [libcxx] [test] Change comments to say C++ instead of c++. NFC.
This makes them consistent (many comments already used uppercase).

The special REQUIRES, UNSUPPORTED, and XFAIL comments are excluded from this change.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309468 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29 00:55:35 +00:00
Stephan T. Lavavej
a686caad20 [libcxx] [test] Untabify, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309464 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29 00:55:10 +00:00