summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/sequences
Commit message (Collapse)AuthorAgeFilesLines
* [libcxx] [test] Include missing headers. (NFC)Stephan T. Lavavej2019-12-131-0/+4
| | | | | | | | libcxx/test/std/containers/sequences/array/at.pass.cpp Need to include <stdexcept> for std::out_of_range. libcxx/test/std/localization/locale.categories/category.time/* Need to include <ios> for std::ios.
* [libcxx] [test] Fix valarray UB and MSVC warnings.Stephan T. Lavavej2019-12-121-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [libcxx] [test] Calling min and max on an empty valarray is UB. libcxx/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp libcxx/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp The calls `v1.min();` and `v1.max();` were emitting nodiscard warnings with MSVC's STL. Upon closer inspection, these calls were triggering undefined behavior. N4842 [valarray.members] says: "T min() const; 8 Preconditions: size() > 0 is true. T max() const; 10 Preconditions: size() > 0 is true." As these tests already provide coverage for non-empty valarrays (immediately above), I've simply deleted the code for empty valarrays. [libcxx] [test] Add macros to msvc_stdlib_force_include.h (NFC). libcxx/test/support/msvc_stdlib_force_include.h These macros are being used by: libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp Defining them to nothing allows that test to pass. [libcxx] [test] Silence MSVC warning C5063 for is_constant_evaluated (NFC). libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.pass.cpp This test is intentionally writing code that MSVC intentionally warns about, so the warning should be silenced. Additionally, comment an endif for clarity. [libcxx] [test] Silence MSVC warning C4127 (NFC). libcxx/test/support/charconv_test_helpers.h MSVC avoids emitting this warning when it sees a single constexpr value being tested, but this condition is a mix of compile-time and run-time. Using push-disable-pop is the least intrusive way to silence this. [libcxx] [test] Silence MSVC truncation warning (NFC). libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp This test is intentionally truncating float to int, which MSVC intentionally warns about, so push-disable-pop is necessary. [libcxx] [test] Avoid truncation warnings in erase_if tests (NFC). libcxx/test/std/containers/associative/map/map.erasure/erase_if.pass.cpp libcxx/test/std/containers/associative/multimap/multimap.erasure/erase_if.pass.cpp libcxx/test/std/containers/unord/unord.map/erase_if.pass.cpp libcxx/test/std/containers/unord/unord.multimap/erase_if.pass.cpp These tests use maps with `short` keys and values, emitting MSVC truncation warnings from `int`. Adding `static_cast` to `key_type` and `mapped_type` avoids these warnings. As these tests require C++20 mode (or newer), for brevity I've changed the multimap tests to use emplace to initialize the test data. This has no effect on the erase_if testing.
* [NFC] Strip trailing whitespace from libc++Louis Dionne2019-10-238-16/+16
|
* [libcxx][test][NFC] Fix comment typos.Stephan T. Lavavej2019-10-221-1/+1
| | | | (Testing git commit access.)
* Fix failing negative compilation test for some versions of ClangEric Fiselier2019-09-131-0/+1
| | | | llvm-svn: 371874
* Recommit r370502: Make `vector` unconditionally move elements whenEric Fiselier2019-09-132-45/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | exceptions are disabled. The patch was reverted due to some confusion about non-movable types. ie types that explicitly delete their move constructors. However, such types do not meet the requirement for `MoveConstructible`, which is required by `std::vector`: Summary: `std::vector<T>` is free choose between using copy or move operations when it needs to resize. The standard only candidates that the correct exception safety guarantees are provided. When exceptions are disabled these guarantees are trivially satisfied. Meaning vector is free to optimize it's implementation by moving instead of copying. This patch makes `std::vector` unconditionally move elements when exceptions are disabled. This optimization is conforming according to the current standard wording. There are concerns that moving in `-fno-noexceptions`mode will be a surprise to users. For example, a user may be surprised to find their code is slower with exceptions enabled than it is disabled. I'm sympathetic to this surprised, but I don't think it should block this optimization. Reviewers: mclow.lists, ldionne, rsmith Reviewed By: ldionne Subscribers: zoecarver, christof, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D62228 llvm-svn: 371867
* [libc++] Add a test for resizing of a vector with copy-only elementsLouis Dionne2019-09-051-0/+45
| | | | | | See https://reviews.llvm.org/D62228#1658620 llvm-svn: 371067
* libcxx: Rename .hpp files in libcxx/test/support to .hNico Weber2019-08-216-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 369481
* Make forward_list::remove/remove_if/unique all return void before C++20; ↵Marshall Clow2019-07-084-62/+124
| | | | | | undoes that bit of D58332. Thanks to Mikhail Maltsev for pointing this out llvm-svn: 365290
* Make list::remove/remove_if/unique all return void before C++20; undoes that ↵Marshall Clow2019-07-064-19/+84
| | | | | | bit of D58332. Thanks to Mikhail Maltsev for pointing this out llvm-svn: 365261
* Implement P0646R1: Erase-Like Algorithms Should Return size_type. Reviewed ↵Marshall Clow2019-07-016-41/+41
| | | | | | 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. llvm-svn: 364840
* Add include for 'test_macros.h' to all the tests that were missing them. ↵Marshall Clow2019-05-31177-0/+192
| | | | | | Thanks to Zoe for the (big, but simple) patch. NFC intended. llvm-svn: 362252
* Add tests specifically for LWG2164. We already did this; but now we have ↵Marshall Clow2019-04-292-0/+23
| | | | | | tests. NFC llvm-svn: 359458
* Add tests for stability to list::sort and forward_list::sort. Thanks to ↵Marshall Clow2019-04-174-0/+184
| | | | | | Jonathan Wakely for the notice llvm-svn: 358541
* Fix list/forward_list implementations of remove_if and unique to deal with ↵Marshall Clow2019-04-164-0/+94
| | | | | | predicates that are part of the sequence passed in. We already do this for remove. llvm-svn: 358534
* [libcxx] [test] Use ptrdiff_t rather than int in splice_after_range.pass.cpp ↵Billy Robert O'Neal III2019-04-031-23/+24
| | | | | | | | to avoid narrowing from pointer subtraction to int warnings. Reviewed as https://reviews.llvm.org/D60104 llvm-svn: 357546
* [libc++] Remove unnecessary <iostream> #includes in testsLouis Dionne2019-03-282-2/+0
| | | | | | | Some tests #include <iostream> but they don't use anything from the header. Those are probably artifacts of when the tests were developped. llvm-svn: 357181
* Fix a vector test to not use a local type as a template parameter. This ↵Marshall Clow2019-03-221-7/+9
| | | | | | causes a warning on C++03. NFC llvm-svn: 356726
* Mark 'front()' and 'back()' as noexcept for array/deque/string/string_view. ↵Marshall Clow2019-03-192-16/+40
| | | | | | These are just rebranded 'operator[]', and should be noexcept like it is. llvm-svn: 356435
* Update a deque test with more assertions. NFCMarshall Clow2019-03-151-6/+6
| | | | llvm-svn: 356266
* Mark vector::operator[] and front/back as noexcept. We already do this for ↵Marshall Clow2019-03-151-0/+121
| | | | | | 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. llvm-svn: 356224
* Add noexcept to operator[] for array and deque. This is an extension. We ↵Marshall Clow2019-03-142-4/+29
| | | | | | already do this for string and string_view. This should give better codegen inside of noexcept functions. llvm-svn: 356209
* Support tests in freestandingJF Bastien2019-02-04345-345/+1037
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 353086
* Mark some of the behavior in the move w/allocator constructors of ↵Marshall Clow2019-01-291-12/+13
| | | | | | deque/unordered containers as 'libc++-specific'. Thanks to Andrey Maksimov for pointing this out. llvm-svn: 352512
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-19340-1360/+1020
| | | | | | | | | | | | | | | | | | 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. llvm-svn: 351648
* Move internal usages of `alignof`/`__alignof` to use `_LIBCPP_ALIGNOF`. Eric Fiselier2019-01-161-2/+0
| | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 351289
* [libcxx] Optimize vectors construction of trivial types from an iterator ↵Volodymyr Sapsai2019-01-081-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 350583
* Fix static assert diagnostic checks in i386Eric Fiselier2018-12-152-2/+2
| | | | llvm-svn: 349252
* Tolerate Clangs new static_assert messagesEric Fiselier2018-12-142-2/+2
| | | | llvm-svn: 349189
* Implement P1209 - Adopt Consistent Container Erasure from Library ↵Marshall Clow2018-12-148-0/+624
| | | | | | Fundamentals 2 for C++20. Reviewed as https://reviews.llvm.org/D55532 llvm-svn: 349178
* Update a couple of vector<bool> tests that were testing libc++-specific ↵Marshall Clow2018-12-073-10/+17
| | | | | | bahavior. Thanks to Andrey Maksimov for the catch. llvm-svn: 348660
* [libcxx] Add checks for unique value of array<T, 0>.begin() and array<T, ↵Louis Dionne2018-12-061-1/+8
| | | | | | | | | | | | | | | 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. llvm-svn: 348509
* [libcxx] Make return value of array<T, 0>.data() checked only for libc++Louis Dionne2018-12-062-6/+6
| | | | | | | | | | | 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. llvm-svn: 348485
* Revert "Move internal usages of `alignof`/`__alignof` to use ↵Eric Fiselier2018-11-281-0/+2
| | | | | | | | | | | `_LIBCPP_ALIGNOF`. " This reverts commit 087f065cb0c7463f521a62599884493aaee2ea12. 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. llvm-svn: 347816
* Move internal usages of `alignof`/`__alignof` to use `_LIBCPP_ALIGNOF`. Eric Fiselier2018-11-281-2/+0
| | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 347787
* [libcxx] Fix incorrect iterator type in vector container testLouis Dionne2018-11-211-24/+32
| | | | | | | | | | | | 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. llvm-svn: 347423
* [libcxx] Add missing <cstddef> includes in testsLouis Dionne2018-11-192-0/+3
| | | | | | | | | | | 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. llvm-svn: 347232
* Get tests compiling with -Wunused-local-typedefEric Fiselier2018-11-154-9/+0
| | | | llvm-svn: 346914
* [libcxx] [test] Fix MSVC warning C4800.Stephan T. Lavavej2018-11-141-6/+6
| | | | | | | | | | | | 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.) llvm-svn: 346910
* [libcxx] [test] Strip trailing whitespace. NFC.Stephan T. Lavavej2018-11-142-2/+2
| | | | llvm-svn: 346826
* Update the array tests to not use a local type; removes warnings in C++03. NFCMarshall Clow2018-10-123-9/+13
| | | | llvm-svn: 344417
* Update all the max_size tests to eliminate signed/unsigned comparison ↵Marshall Clow2018-10-124-16/+16
| | | | | | warnings. NFC llvm-svn: 344416
* Remove unused include of "verbose_assert.h"Marshall Clow2018-09-191-1/+0
| | | | llvm-svn: 342524
* mark LWG#2953 as complete. No code changes required, but added a couple of ↵Marshall Clow2018-09-122-0/+64
| | | | | | extra tests. llvm-svn: 342070
* Implement LWG #3017. list splice functions should use addressofMarshall Clow2018-09-122-0/+21
| | | | llvm-svn: 342057
* Fix Bug 38644: multimap::clear() missing exception specifier. Add noexcept ↵Marshall Clow2018-08-224-3/+81
| | | | | | tests for all the containers that have clear(). llvm-svn: 340385
* Update the changes to the array tests (that I committed yesterday) to use ↵Marshall Clow2018-08-031-55/+8
| | | | | | the test_comparison routines that I committed last week. NFC. llvm-svn: 338797
* Implement P1023: constexpr comparison operators for std::arrayMarshall Clow2018-08-021-0/+46
| | | | llvm-svn: 338668
* Fix a couple of 'unused variable' warnings in a vector test. NFC.Marshall Clow2018-07-131-0/+4
| | | | llvm-svn: 337016
* [libcxx] [test] Strip trailing whitespace. NFC.Stephan T. Lavavej2018-06-148-12/+12
| | | | llvm-svn: 334676
OpenPOWER on IntegriCloud