Commit Graph

201 Commits

Author SHA1 Message Date
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
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
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
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
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
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
272871b658 Move internal usages of alignof/__alignof to use _LIBCPP_ALIGNOF.
Summary:
Starting in Clang 8.0 and GCC 8.0, `alignof` and `__alignof` return different values in same cases. Specifically `alignof` and `_Alignof` return the minimum alignment for a type, where as `__alignof` returns the preferred alignment. libc++ currently uses `__alignof` but means to use `alignof`. See  llvm.org/PR39713

This patch introduces the macro `_LIBCPP_ALIGNOF` so we can control which spelling gets used.

This patch does not introduce any ABI guard to provide the old behavior with newer compilers. However, if we decide that is needed, this patch makes it trivial to implement.

I think we should commit this change immediately, and decide what we want to do about the ABI afterwards. 

Reviewers: ldionne, EricWF

Reviewed By: ldionne, EricWF

Subscribers: jyknight, christof, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@351289 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-16 01:51:12 +00:00
Volodymyr Sapsai
354589c472 [libcxx] Optimize vectors construction of trivial types from an iterator range with const-ness mismatch.
We already have a specialization that will use memcpy for construction
of trivial types from an iterator range like

    std::vector<int>(int *, int *);

But if we have const-ness mismatch like

    std::vector<int>(const int *, const int *);

we would use a slow path that copies each element individually. This change
enables the optimal specialization for const-ness mismatch. Fixes PR37574.

Contributions to the patch are made by Arthur O'Dwyer, Louis Dionne.

rdar://problem/40485845

Reviewers: mclow.lists, EricWF, ldionne, scanon

Reviewed By: ldionne

Subscribers: christof, ldionne, howard.hinnant, cfe-commits

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



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@350583 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-08 00:03:16 +00:00
Eric Fiselier
8c36703b2b Fix static assert diagnostic checks in i386
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@349252 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-15 05:18:56 +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
f927635d87 Implement P1209 - Adopt Consistent Container Erasure from Library Fundamentals 2 for C++20. Reviewed as https://reviews.llvm.org/D55532
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@349178 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-14 18:49:35 +00:00
Marshall Clow
49ad9aa8cb Update a couple of vector<bool> tests that were testing libc++-specific bahavior. Thanks to Andrey Maksimov for the catch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@348660 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-07 22:16:26 +00:00
Louis Dionne
5b19b0bb3f [libcxx] Add checks for unique value of array<T, 0>.begin() and array<T, 0>.end()
The standard section [array.zero] requires the return value of begin()
and end() methods of a zero-sized array to be unique. Eric Fiselier
clarifies: "That unique value cannot be null, and must be properly aligned".
This patch adds checks for the first part of this clarification: unique
value returned by these methods cannot be null.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@348509 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-06 18:24:39 +00:00
Louis Dionne
edfdc498b8 [libcxx] Make return value of array<T, 0>.data() checked only for libc++
The section array.zero says: "The return value of data() is unspecified".
This patch marks all checks of the array<T, 0>.data() return value as
libc++ specific.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@348485 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-06 13:52:20 +00:00
Eric Fiselier
e3e576ae50 Revert "Move internal usages of alignof/__alignof to use _LIBCPP_ALIGNOF. "
This reverts commit 087f065cb0.

The tests were failing on 32 bit builds, and I don't have time
to clean them up right now. I'll recommit tomorrow with fixed tests.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347816 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-28 22:24:19 +00:00
Eric Fiselier
087f065cb0 Move internal usages of alignof/__alignof to use _LIBCPP_ALIGNOF.
Summary:
Starting in Clang 8.0 and GCC 8.0, `alignof` and `__alignof` return different values in same cases. Specifically `alignof` and `_Alignof` return the minimum alignment for a type, where as `__alignof` returns the preferred alignment. libc++ currently uses `__alignof` but means to use `alignof`. See  llvm.org/PR39713

This patch introduces the macro `_LIBCPP_ALIGNOF` so we can control which spelling gets used.

This patch does not introduce any ABI guard to provide the old behavior with newer compilers. However, if we decide that is needed, this patch makes it trivial to implement.

I think we should commit this change immediately, and decide what we want to do about the ABI afterwards. 

Reviewers: ldionne, EricWF

Reviewed By: EricWF

Subscribers: christof, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347787 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-28 18:16:02 +00:00
Louis Dionne
5beaebf500 [libcxx] Fix incorrect iterator type in vector container test
The iterator types for different specializations of containers with the
same element type but different allocators are not required to be
convertible. This patch makes the test to take the iterator type from
the same container specialization as the created container.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347423 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-21 20:53:07 +00:00
Louis Dionne
a320121c4c [libcxx] Add missing <cstddef> includes in tests
Some tests use type std::max_align_t, but don't include <cstddef> header
directly. As a result, these tests won't compile against some conformant
libraries.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347232 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-19 17:39:50 +00:00
Eric Fiselier
c2c6c1de6b Get tests compiling with -Wunused-local-typedef
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346914 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-15 00:11:02 +00:00
Stephan T. Lavavej
5e97ad3674 [libcxx] [test] Fix MSVC warning C4800.
This was implicitly converting [1, 3] to bool, which triggers
an MSVC warning. The test should just pass `true`, which is
simpler, has the same behavior, and avoids the warning. (This
is a library test, not a compiler test, and the conversion happens
before calling `push_back`, so passing [1, 3] isn't interesting
in any way. This resembles a previous change to stop passing
`1 == 1` in the `vector<bool>` tests.)

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346910 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-14 23:23:46 +00:00
Stephan T. Lavavej
439de45011 [libcxx] [test] Strip trailing whitespace. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346826 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-14 03:06:06 +00:00
Marshall Clow
8f07eceb27 Update the array tests to not use a local type; removes warnings in C++03. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344417 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-12 21:24:44 +00:00
Marshall Clow
477f04b9a2 Update all the max_size tests to eliminate signed/unsigned comparison warnings. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344416 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-12 21:22:15 +00:00
Marshall Clow
699cb5b3b8 Remove unused include of "verbose_assert.h"
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@342524 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 02:27:44 +00:00
Marshall Clow
c106dd615d mark LWG#2953 as complete. No code changes required, but added a couple of extra tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@342070 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-12 18:51:12 +00:00
Marshall Clow
ec25143bbb Implement LWG #3017. list splice functions should use addressof
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@342057 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-12 14:46:17 +00:00
Marshall Clow
4c90425692 Fix Bug 38644: multimap::clear() missing exception specifier. Add noexcept tests for all the containers that have clear().
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@340385 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 04:28:43 +00:00
Marshall Clow
3a225ef042 Update the changes to the array tests (that I committed yesterday) to use the test_comparison routines that I committed last week. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@338797 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-03 00:47:12 +00:00
Marshall Clow
88f5d7a38b Implement P1023: constexpr comparison operators for std::array
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@338668 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-02 02:11:06 +00:00
Marshall Clow
9765ed0367 Fix a couple of 'unused variable' warnings in a vector test. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@337016 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-13 16:26:16 +00:00
Stephan T. Lavavej
9165f9d181 [libcxx] [test] Strip trailing whitespace. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@334676 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 00:12:20 +00:00
Eric Fiselier
d54a86893f Fix test failures after r334053.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@334056 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-06 00:13:49 +00:00
Eric Fiselier
301518c94e Fix PR37694 - std::vector doesn't correctly move construct allocators.
C++2a[container.requirements.general]p8 states that when move constructing
a container, the allocator is move constructed. Vector previously copy
constructed these allocators. This patch fixes that bug.

Additionally it cleans up some unnecessary allocator conversions
when copy constructing containers. Libc++ uses
__internal_allocator_traits::select_on_copy_construction to select
the correct allocator during copy construction, but it unnecessarily
converted the resulting allocator to the user specified allocator
type and back. After this patch list and forward_list no longer
do that.

Technically we're supposed to be using allocator_traits<allocator_type>::select_on_copy_construction,
but that should seemingly be addressed as a separate patch, if at all.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@334053 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-05 22:32:52 +00:00
JF Bastien
e4063adf19 Mark deduction guide tests as failing on apple-clang-9
As discussed here: http://lists.llvm.org/pipermail/cfe-dev/2018-May/058116.html
The tests fail on clang-5, as well as apple-clang-9. Mark them as such.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@333479 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-29 23:28:04 +00:00
Marshall Clow
d1e11a1a6f Fix up the final bits of breakage due to clang v5 generating bad implicit template deduction guides - specifically for copy-ctors
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@333381 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-28 19:20:21 +00:00
JF Bastien
3dfc68d12a Fix array deduction guide test breakage
No matching constructor

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@333315 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-25 21:17:43 +00:00
Marshall Clow
32bc2e298c Implement deduction guides for vector
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@332901 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-21 21:30:12 +00:00
Marshall Clow
d4c79d0bbb Deduction guides for list
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@332818 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-20 14:05:31 +00:00
Marshall Clow
fa3202c565 Implement deduction guides for forward_list
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@332811 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-19 16:02:05 +00:00