Commit Graph

334 Commits

Author SHA1 Message Date
Louis Dionne
7de36b7778 [libc++] Add a test for resizing of a vector with copy-only elements
See https://reviews.llvm.org/D62228#1658620

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@371067 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-05 13:50:18 +00:00
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
Louis Dionne
5f99b4ef15 [libc++] Add missing UNSUPPORTED for CTAD tests
The tests for unordered_set and unordered_multiset were missing UNSUPPORTED
markup for Apple Clang 9.1, which is still being used on some CI bots.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@366259 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 20:41:33 +00:00
Zoe Carver
3f39fe31c4 Add contains method to associative containers. This patch implements P0458R2, adding contains to map, multimap, unordered_map, unordered_multimap, set, multiset, unordered_set, and unordered_multiset.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@366170 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 03:21:01 +00:00
Louis Dionne
c59091fb03 [libc++] Implement P0433: deduction guides for <unordered_map>
Thanks to Arthur O'Dwyer for the patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@366124 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 20:06:01 +00:00
Louis Dionne
86f93e801c [libc++] Add XFAILs for CTAD tests on older compilers
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@365923 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-12 17:30:57 +00:00
Eric Fiselier
f579c7c19d Fix memory leak in set and map.
When assigning an initializer list into set/map, libc++ would
leak memory if the initializer list contained equivalent keys
because we failed to check if the insertion was successful.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@365840 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-11 23:13:38 +00:00
Louis Dionne
2980850307 [libc++] Implement deduction guides for <unordered_set>
Thanks to Arthur O'Dwyer for the patch.
Differential Revision: https://reviews.llvm.org/D58617

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@365788 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-11 15:16:39 +00:00
Marshall Clow
7a377e25a4 Make forward_list::remove/remove_if/unique all return void before C++20; undoes that bit of D58332. Thanks to Mikhail Maltsev for pointing this out
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@365290 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-08 03:45:28 +00:00
Marshall Clow
da9535d479 Make list::remove/remove_if/unique all return void before C++20; undoes that bit of D58332. Thanks to Mikhail Maltsev for pointing this out
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@365261 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-06 06:10:03 +00:00
Marshall Clow
b23844e251 Implement P0646R1: Erase-Like Algorithms Should Return size_type. Reviewed as https://reviews.llvm.org/D58332, and then updated because I rewrote a couple of those routines to eliminate some UB. Thanks to Zoe for tghe patch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@364840 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-01 19:22:00 +00:00
Richard Smith
caf3bc5596 Fix test failures when using a custom ABI namespace.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@364239 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-24 21:46:05 +00:00
Louis Dionne
e46f68502a [libc++] Take 2: Implement CTAD for map and multimap
This is a re-application of r362986 (which was reverted in r363688) with fixes
for the issue that caused it to be reverted.

Thanks to Arthur O'Dwyer for the patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@363968 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-20 19:32:00 +00:00
Louis Dionne
11aae354b9 [libc++] Revert the addition of map/multimap CTAD
This was found to be broken on Clang trunk. This is a revert of the
following commits (the subsequent commits added XFAILs to the tests
that were missing from the original submission):

    r362986: Implement deduction guides for map/multimap.
    r363014: Add some XFAILs
    r363097: Add more XFAILs
    r363197: Add even more XFAILs

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@363688 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-18 14:40:15 +00:00
Louis Dionne
d7020fb087 [libcxx] XFAIL set/multiset CTAD tests on Apple Clang 10
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@363209 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-12 22:01:05 +00:00
Louis Dionne
3939b1c7e7 [libcxx] XFAIL some CTAD tests on AppleClang 10
AppleClang 10 doesn't contain some changes that are required for this
test to give the right error message.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@363197 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-12 20:12:44 +00:00
Louis Dionne
5a3290673c [libcxx] Mark CTAD tests for set and multiset as unsupported on older Apple Clangs
Those fail on Green Dragon.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@363107 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-11 22:36:20 +00:00
Marshall Clow
35a718a2c5 Mark CTAD fail tests for set/multiset as XFAIL for older compilers that give different error messages
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@363099 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-11 20:35:19 +00:00
Marshall Clow
88b46e4a16 XFAIL a couple of tests on apple-clang-9.1, which is a compiler that I didn't know existed
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@363097 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-11 20:14:07 +00:00
Louis Dionne
19430da69d [libc++] Implement deduction guides for <set>
This is part of C++17's P0433.

Thanks to Arthur O'Dwyer for the patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@363090 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-11 18:21:08 +00:00
Marshall Clow
6b83993a22 XFAIL a couple of CTAD tests on clang-6; it gives different error messages than clang 7/8/9
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@363014 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-11 00:23:50 +00:00
Marshall Clow
49ae262e74 Implement deduction guides for map/multimap. Reviewed as https://reviews.llvm.org/D58587. Thanks to Quuxplusone for the submission.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@362986 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-10 21:28:23 +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
154d4dbd16 [libcxx][tests] Fix order checking in unordered_multiset tests.
Some tests assume that iteration through an unordered multiset elements
will return them in the same order as at the container creation. This
assumption is not true since the container is unordered, so that no
specific order of elements is ever guaranteed for such container. This
patch introduces checks verifying that any iteration will return
elements exactly from a set of valid values and without repetition,
but in no particular order.

Thanks to Andrey Maksimov for  the patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@361494 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-23 13:11:00 +00:00
Louis Dionne
05c927e263 [libcxx][test] Fix order checking in some more unordered_multimap tests
Some tests assume that iteration through an unordered multimap elements
will return them in the same order as at the container creation. This
assumption is not true since the container is unordered, so that no
specific order of elements is ever guaranteed for such container. This
patch is a continuation of D54838 and introduces checks verifying that
any iteration will return elements exactly from a set of valid values
and without repetition, but in no particular order.

Thanks to Andrey Maksimov for the patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@361414 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-22 18:10:32 +00:00
Marshall Clow
3cae9fcd3d Fix a bunch of unordered container tests that were failing when _LIBCPP_DEBUG was set.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@359642 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-01 01:52:51 +00:00
Marshall Clow
732332686b Add tests specifically for LWG2164. We already did this; but now we have tests. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@359458 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-29 15:38:07 +00:00
Marshall Clow
1b3740a663 Add tests for stability to list::sort and forward_list::sort. Thanks to Jonathan Wakely for the notice
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@358541 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-17 00:11:00 +00:00
Marshall Clow
ef93f3843f Fix list/forward_list implementations of remove_if and unique to deal with predicates that are part of the sequence passed in. We already do this for remove.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@358534 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-16 22:11:26 +00:00
Billy Robert O'Neal III
8b2f8ce5e6 [libcxx] [test] Use ptrdiff_t rather than int in splice_after_range.pass.cpp to avoid narrowing from pointer subtraction to int warnings.
Reviewed as https://reviews.llvm.org/D60104

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357546 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 00:07:18 +00:00
Louis Dionne
4ff4db7f84 [libc++] Remove unnecessary <iostream> #includes in tests
Some tests #include <iostream> but they don't use anything from the
header. Those are probably artifacts of when the tests were developped.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357181 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-28 16:38:15 +00:00
Louis Dionne
a9b1043901 [libc++] Rename span's as_writeable_bytes to as_writable_bytes
Summary: The Standard says as_writable_bytes.

Reviewers: mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357139 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-28 01:27:52 +00:00
Casey Carter
2fe3307e56 Fix occurrences of _LIBCPP_ASSERT in span tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357092 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-27 17:03:44 +00:00
Marshall Clow
4d774fe669 Fix a vector test to not use a local type as a template parameter. This causes a warning on C++03. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356726 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-22 00:49:41 +00:00
Marshall Clow
ddb1b0576a Mark 'front()' and 'back()' as noexcept for array/deque/string/string_view. These are just rebranded 'operator[]', and should be noexcept like it is.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356435 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-19 03:30:07 +00:00
Marshall Clow
527149c670 Update a deque test with more assertions. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356266 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-15 15:00:41 +00:00
Marshall Clow
9039043195 Mark vector::operator[] and front/back as noexcept. We already do this for string and string_view. This should give better codegen inside of noexcept functions. Add tests for op[]/front/back/at, because apparently we had none.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356224 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-15 00:29:35 +00:00
Marshall Clow
fa199b9339 Add noexcept to operator[] for array and deque. This is an extension. We already do this for string and string_view. This should give better codegen inside of noexcept functions.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356209 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-14 21:56:57 +00:00
Marshall Clow
526bce48cc Eradicate all the ptrdiff_ts in span left over from applying P1227. A couple of other minor cleanups. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@355481 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-06 03:59:44 +00:00
Marshall Clow
ae4afd034b Implment the last part of P1024: tuple-like interface to span. Reviewed as https://reviews.llvm.org/D58706.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@354988 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-27 15:41:37 +00:00
Marshall Clow
680a56e1aa Fix an ambiguity in the tests that gcc-tot complained about.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@354944 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-27 01:29:52 +00:00
Marshall Clow
b3c66aa0ab First part of P1227R2 - change span over to use 'size_t' instead of 'ptrdiff_t'. Reviewed as https://reviews.llvm.org/D58639.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@354936 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-27 00:32:16 +00:00
Marshall Clow
a333218455 LWG3101 - span's Container constructors need another constraint. Reviewed as https://reviews.llvm.org/D57058.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@354805 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-25 18:32:57 +00:00
Marshall Clow
c67930bd74 Commit LWG3144 - span does not have a const_pointer typedef. Reviewed as D57039.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@354802 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-25 17:58:03 +00:00
Marshall Clow
e5cb744bf1 First part of P1024: Usability Enhancements for std::span. Remove operator() for indexing, and add 'front' and 'back' calls.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@354801 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-25 17:54:08 +00:00
Louis Dionne
712d476de3 [libcxx] Do not assume the number of elements in a moved-from associative container
Reviewed as https://reviews.llvm.org/D57903.
Thanks to Andrey Maksimov for the patch.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@353955 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-13 16:43:44 +00:00
Chandler Carruth
b20da37b6b Update some newly added files that mistakenly used the old file header
to the new one.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@353668 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-11 08:39:14 +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
92f58d1b36 Mark some of the behavior in the move w/allocator constructors of deque/unordered containers as 'libc++-specific'. Thanks to Andrey Maksimov for pointing this out.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@352512 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-29 16:12:45 +00:00
Louis Dionne
42cbe7a2aa [libcxx] Portability fix: unordered_set and unordered_multiset iterators are not required to be the same
The unordered_set and unordered_multiset iterators are specified in the standard as follows:

using iterator             = implementation-defined; // see [container.requirements]
using const_iterator       = implementation-defined; // see [container.requirements]
using local_iterator       = implementation-defined; // see [container.requirements]
using const_local_iterator = implementation-defined; // see [container.requirements]

The pairs iterator/const_iterator and local_iterator/const_local_iterator
are not required to be the same. The reasonable requirement would be that
iterator can convert to const_iterator and local_iterator can convert to
const_local_iterator. This patch weakens the check and makes the test
more portable.

Reviewed as https://reviews.llvm.org/D56493.
Thanks to Andrey Maksimov for the patch.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@352083 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-24 19:09:22 +00:00