summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/utility/pairs
Commit message (Collapse)AuthorAgeFilesLines
* [libc++] Take 2: Implement LWG 2510Louis Dionne2019-09-265-2/+102
| | | | | | | | | | | | | | | | | | | | | | | Summary: LWG2510 makes tag types like allocator_arg_t explicitly default constructible instead of implicitly default constructible. It also makes the constructors for std::pair and std::tuple conditionally explicit based on the explicit-ness of the default constructibility for the pair/tuple's elements. This was previously committed as r372777 and reverted in r372832 due to the commit breaking LLVM's build in C++14 mode. This issue has now been addressed. Reviewers: mclow.lists Subscribers: christof, jkorous, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D65161 llvm-svn: 372983
* [libc++] Purge mentions of GCC 4 from the test suiteLouis Dionne2019-09-252-8/+0
| | | | | | | | | We don't support GCC 4 and older according to the documentation, so we should pretend it doesn't exist. This is a re-application of r372787. llvm-svn: 372916
* Revert r372777: [libc++] Implement LWG 2510 and its follow-upsIlya Biryukov2019-09-256-97/+10
| | | | | | | | | | | | This also reverts: - r372778: [libc++] Implement LWG 3158 - r372782: [libc++] Try fixing tests that fail on GCC 5 and older - r372787: Purge mentions of GCC 4 from the test suite Reason: the change breaks compilation of LLVM with libc++, for details see http://lists.llvm.org/pipermail/libcxx-dev/2019-September/000599.html llvm-svn: 372832
* [libc++] Purge mentions of GCC 4 from the test suiteLouis Dionne2019-09-244-10/+2
| | | | | | | We don't support GCC 4 and older according to the documentation, so we should pretend it doesn't exist. llvm-svn: 372787
* [libc++] Try fixing tests that fail on GCC 5 and olderLouis Dionne2019-09-242-0/+8
| | | | llvm-svn: 372782
* [libc++] Implement LWG 2510Louis Dionne2019-09-245-2/+89
| | | | | | | | | | | | | | | | | | | Summary: LWG2510 makes tag types like allocator_arg_t explicitly default constructible instead of implicitly default constructible. It also makes the constructors for std::pair and std::tuple conditionally explicit based on the explicit-ness of the default constructibility for the pair/tuple's elements. Reviewers: mclow.lists, EricWF Subscribers: christof, jkorous, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D65161 llvm-svn: 372777
* libcxx: Rename .hpp files in libcxx/test/support to .hNico Weber2019-08-219-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add include for 'test_macros.h' to all the tests that were missing them. ↵Marshall Clow2019-05-3120-0/+40
| | | | | | Thanks to Zoe for the (big, but simple) patch. NFC intended. llvm-svn: 362252
* Support tests in freestandingJF Bastien2019-02-0441-41/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1938-152/+114
| | | | | | | | | | | | | | | | | | 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
* [pair] Mark constructors as conditionally noexceptLouis Dionne2018-12-111-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: std::tuple marks its constructors as noexcept when the corresponding memberwise constructors are noexcept too -- this commit improves std::pair so that it behaves the same. This is a re-application of r348824, which broke the build in C++03 mode because a test was marked as supported in C++03 when it shouldn't be. Note: I did not add support in the explicit and non-explicit `pair(_Tuple&& __p)` constructors because those are non-standard extensions, and supporting them properly is tedious (we have to copy the rvalue-referenceness of the deduced _Tuple&& onto the result of tuple_element). <rdar://problem/29537079> Reviewers: mclow.lists, EricWF Subscribers: christof, llvm-commits Differential Revision: https://reviews.llvm.org/D48669 llvm-svn: 348847
* Revert "[pair] Mark constructors as conditionally noexcept"Louis Dionne2018-12-111-3/+2
| | | | | | | This broke the tests on Linux. Reverting until I find out why the tests are broken (tomorrow). llvm-svn: 348825
* [pair] Mark constructors as conditionally noexceptLouis Dionne2018-12-111-2/+3
| | | | | | | | | | | | | | | | | | | | | | | Summary: std::tuple marks its constructors as noexcept when the corresponding memberwise constructors are noexcept too -- this commit improves std::pair so that it behaves the same. Note: I did not add support in the explicit and non-explicit `pair(_Tuple&& __p)` constructors because those are non-standard extensions, and supporting them properly is tedious (we have to copy the rvalue-referenceness of the deduced _Tuple&& onto the result of tuple_element). <rdar://problem/29537079> Reviewers: mclow.lists, EricWF Subscribers: christof, llvm-commits Differential Revision: https://reviews.llvm.org/D48669 llvm-svn: 348824
* [libcxx] [test] Avoid MSVC truncation warnings.Stephan T. Lavavej2018-04-123-4/+4
| | | | | | | | | | | | | | | | | | | MSVC emits "warning C4244: 'initializing': conversion from 'int' to 'short', possible loss of data" when it sees pair<Whatever, short> constructed from (whatever, 4), because int is being truncated to short within pair's constructor. (The compiler doesn't take into account the fact that 4 is a literal at the callsite; it generates this warning when the constructor is instantiated, because it might be called with a runtime-valued int that would actually truncate.) Instead of static_cast<short>, we can simply change short to int in these tests, without affecting the pair operations that they're trying to test: move assignment, convert copy construction, and convert move construction. Fixes D45016. llvm-svn: 329973
* fix typo in align_const_pair_U_V.pass.cppEric Fiselier2018-03-291-1/+1
| | | | llvm-svn: 328760
* Move libc++ pair/tuple assign test to libcxx/ test directory.Eric Fiselier2018-03-293-140/+38
| | | | | | | | | | | Libc++ implements the pair& operator=(pair<U, V>) assignment operator using a single template that handles assignment from all tuple-like types. This patch moves the test for that to the libcxx test directory since it's non-standard. It also adds additional tests to the std/.../pair directory to test the standard behavior this template implements. llvm-svn: 328758
* Remove unneeded typename from testRoger Ferrer Ibanez2017-10-101-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D38628 llvm-svn: 315278
* Fix accidental assignment inside test assertsEric Fiselier2017-10-042-2/+2
| | | | llvm-svn: 314947
* Add C++17 explicit deduction guides to std::pair.Eric Fiselier2017-10-041-0/+80
| | | | | | | This patch adds the newly standardized deduction guides for std::pair, allowing it to work class template deduction. llvm-svn: 314864
* Added failing tests for index out of range for tuple_element<pair<T1,T2>> ↵Marshall Clow2017-06-281-0/+22
| | | | | | and variant_alternative<> llvm-svn: 306580
* [libcxx] [test] Strip trailing whitespace. NFC.Stephan T. Lavavej2017-06-201-1/+1
| | | | llvm-svn: 305848
* Mark LWG#2796 as complete. No functionality change; we had tests that ↵Marshall Clow2017-05-111-0/+4
| | | | | | covered it already. Just added comments to the tests llvm-svn: 302798
* Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the utilities libraryEric Fiselier2017-04-192-4/+4
| | | | llvm-svn: 300635
* [libcxx] [test] Fix Clang -Wunused-local-typedef, part 3/3.Stephan T. Lavavej2017-02-051-1/+1
| | | | | | | | | | | | | | | | test/std/strings/string.classes/typedefs.pass.cpp Actually test what basic_string's typedefs stand for. test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp NotDerived and ND were completely unused. test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp P2 was mistakenly not being used. Yes, that's right: -Wunused-local-typedef CAUGHT A MISTAKE! AMAZING! Fixes D29137. llvm-svn: 294156
* Remove all usages of REQUIRES-ANY in the test suite.Eric Fiselier2017-01-241-1/+1
| | | | | | | | | Pending LIT changes are about to remove the REQUIRES-ANY keyword in place of supporting boolean && and || within "REQUIRES". This patch prepares libc++ for that change so that when applied the bots don't lose their mind. llvm-svn: 292901
* [libcxx] [test] Fix comment typos, strip trailing whitespace.Stephan T. Lavavej2017-01-182-2/+2
| | | | | | No functional change, no code review. llvm-svn: 292434
* Fix XFAILS for is_trivially_destructible traitEric Fiselier2016-12-151-3/+0
| | | | llvm-svn: 289802
* Fix typoEric Fiselier2016-12-151-1/+1
| | | | llvm-svn: 289781
* Add tests for LWG 2796Eric Fiselier2016-12-151-0/+35
| | | | llvm-svn: 289780
* [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible ↵Stephan T. Lavavej2016-12-081-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | loss of data", part 7/7. test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp Add static_cast<char> because basic_istream::get() returns int_type (N4606 27.7.2.3 [istream.unformatted]/4). test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp Add static_cast<char> because toupper() returns int (C11 7.4.2.2/1). test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp This test is intentionally writing doubles to ostream_iterator<int>. It's silencing -Wliteral-conversion for Clang, so I'm adding C4244 silencing for MSVC. test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp Given `extern float zero;`, the expression `1./zero` has type double, which emits a truncation warning when being passed to test<float>() taking float. The fix is to say `1.f/zero` which has type float. test/std/numerics/complex.number/cmplx.over/arg.pass.cpp test/std/numerics/complex.number/cmplx.over/norm.pass.cpp These tests were constructing std::complex<double>(x, 0), emitting truncation warnings when x is long long. Saying static_cast<double>(x) avoids this. test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp This was using `int s` to construct and seed a linear_congruential_engine<T, stuff>, where T is unsigned short/unsigned int/unsigned long/unsigned long long. That emits a truncation warning in the unsigned short case. Because the range [0, 20) is tiny and we aren't doing anything else with the index, we can just iterate with `T s`. test/std/re/re.traits/value.pass.cpp regex_traits<wchar_t>::value()'s first parameter is wchar_t (N4606 28.7 [re.traits]/13). This loop is using int to iterate through ['g', 0xFFFF), emitting a truncation warning from int to wchar_t (which is 16-bit for some of us). Because the bound is exclusive, we can just iterate with wchar_t. test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp This test is a little strange. It's trying to verify that basic_string's (InIt, InIt) range constructor isn't confused by "N copies of C" when N and C have the same integral type. To do this, it was testing (100, 65), but that eventually emits truncation warnings from int to char. There's a simple way to avoid this - passing (static_cast<char>(100), static_cast<char>(65)) also exercises the disambiguation. (And 100 is representable even when char has a signed range.) test/std/strings/string.view/string.view.hash/string_view.pass.cpp Add static_cast<char_type> because `'0' + i` has type int. test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp What's more horrible than nested bind()? pow() overloads! This operator()(T a, T b) was assuming that std::pow(a, b) can be returned as T. (In this case, T is int.) However, N4606 26.9.1 [cmath.syn]/2 says that pow(int, int) returns double, so this was truncating double to int. Adding static_cast<T> silences this. test/std/utilities/function.objects/unord.hash/integral.pass.cpp This was iterating `for (int i = 0; i <= 5; ++i)` and constructing `T t(i);` but that's truncating when T is short. (And super truncating when T is bool.) Adding static_cast<T> silences this. test/std/utilities/utility/exchange/exchange.pass.cpp First, this was exchanging 67.2 into an int, but that's inherently truncating. Changing this to static_cast<short>(67) avoids the truncation while preserving the "what if T and U are different" test coverage. Second, this was exchanging {} with the explicit type float into an int, and that's also inherently truncating. Specifying short is just as good. test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp Add static_cast<short>. Note that this affects template argument deduction for make_pair(), better fulfilling the test's intent. For example, this was saying `typedef std::pair<int, short> P1; P1 p1 = std::make_pair(3, 4);` but that was asking make_pair() to return pair<int, int>, which was then being converted to pair<int, short>. (pair's converting constructors are tested elsewhere.) Now, std::make_pair(3, static_cast<short>(4)) actually returns pair<int, short>. (There's still a conversion from pair<nullptr_t, short> to pair<unique_ptr<int>, short>.) Fixes D27544. llvm-svn: 289111
* [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible ↵Stephan T. Lavavej2016-12-0812-28/+28
| | | | | | | | | | loss of data", part 3/7. Add static_cast<short> when constructing pair<Whatever, short> from (Something, int). Fixes D27540. llvm-svn: 289107
* [libcxx] [test] Replace _LIBCPP_STD_VER with TEST_STD_VER.Stephan T. Lavavej2016-11-041-1/+3
| | | | | | | | | | | This replaces every occurrence of _LIBCPP_STD_VER in the tests with TEST_STD_VER. Additionally, for every affected file, #include "test_macros.h" is being added explicitly if it wasn't already there. https://reviews.llvm.org/D26294 llvm-svn: 286007
* Disable trivial pair copy/move tests when unsupportedDimitry Andric2016-10-121-0/+6
| | | | | | | | | | | | | | | | | | Summary: On FreeBSD, for ABI compatibility reasons, the pair trivial copy constructor is disabled, using the aptly-named `_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR` define. Disable the related tests when this define is on, so they don't fail unexpectedly. Reviewers: emaste, rsmith, theraven, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25449 llvm-svn: 284047
* Remove all instances of _LIBCPP_HAS_NO_RVALUE_REFERENCES from test/std/utilitiesEric Fiselier2016-10-013-8/+9
| | | | llvm-svn: 283032
* Fix pair::operator=(TupleLike&&).Eric Fiselier2016-08-291-0/+140
| | | | | | | | | | | This assignment operator was previously broken since the SFINAE always resulted in substitution failure. This caused assignments to turn into copy construction + assignment. This patch was originally committed as r279953 but was reverted due to warnings in the test-suite. This new patch corrects those warnings. llvm-svn: 279955
* Revert r279953 - Fix pair::operator=(TupleLike&&)Eric Fiselier2016-08-291-135/+0
| | | | | | | The test emits warnings causing the test-suite to fail. Since I want this patch merged into 3.9 I'll recommit it with a clean test. llvm-svn: 279954
* Fix pair::operator=(TupleLike&&).Eric Fiselier2016-08-291-0/+135
| | | | | | | | This assignment operator was previously broken since the SFINAE always resulted in substitution failure. This caused assignments to turn into copy construction + assignment. llvm-svn: 279953
* Unbreak C++03 build.Eric Fiselier2016-08-111-1/+1
| | | | llvm-svn: 278323
* Refactor test archetypes implementation.Eric Fiselier2016-08-116-68/+74
| | | | llvm-svn: 278319
* Remove use of C++1z static assert in C++11 testEric Fiselier2016-07-251-8/+8
| | | | llvm-svn: 276608
* Implement the std::pair parts of "Improving pair and tuple". Completes N4387.Eric Fiselier2016-07-259-35/+668
| | | | llvm-svn: 276605
* Recommit r276548 - Make pair/tuples assignment operators SFINAE properly.Eric Fiselier2016-07-253-2/+216
| | | | | | | I think I've solved issues with is_assignable and references to incomplete types. The updated patch adds tests for this case. llvm-svn: 276603
* Revert r276548 - Make pair/tuples assignment operators SFINAE properly.Eric Fiselier2016-07-253-192/+2
| | | | | | | | | | | | This is a breaking change. The SFINAE required is instantiated the second the class is instantiated, and this can cause hard SFINAE errors when applied to references to incomplete types. Ex. struct IncompleteType; extern IncompleteType it; std::tuple<IncompleteType&> t(it); // SFINAE will blow up. llvm-svn: 276598
* Don't SFINAE pair's copy assignment operator in C++03 mode.Eric Fiselier2016-07-251-0/+36
| | | | | | | | In C++03 mode evaluating the SFINAE can cause a hard error due to access control violations. This is a problem because the SFINAE is evaluated as soon as the class is instantiated, and not later. llvm-svn: 276594
* Make pair/tuples assignment operators SFINAE properly.Eric Fiselier2016-07-242-2/+156
| | | | llvm-svn: 276548
* Replace __cplusplus comparisons and dialect __has_feature checks with ↵Eric Fiselier2016-06-142-3/+7
| | | | | | | | | TEST_STD_VER. This is a huge cleanup that helps make the libc++ test suite more portable. Patch from STL@microsoft.com. Thanks STL! llvm-svn: 272716
* Remove _LIBCPP_TRIVIAL_PAIR_COPY_CTOR option.Eric Fiselier2016-06-143-6/+94
| | | | llvm-svn: 272613
* [libcxx] Improve tests to use the UNSUPPORTED lit directiveAsiri Rathnayake2016-05-283-12/+3
| | | | | | | | | | | | | | | | | | | Quite a few libcxx tests seem to follow the format: #if _LIBCPP_STD_VER > X // Do test. #else // Empty test. #endif We should instead use the UNSUPPORTED lit directive to exclude the test on earlier C++ standards. This gives us a more accurate number of test passes for those standards and avoids unnecessary conflicts with other lit directives on the same tests. Reviewers: bcraig, ericwf, mclow.lists Differential revision: http://reviews.llvm.org/D20730 llvm-svn: 271108
* Removing some trailing whitespaceEric Fiselier2016-05-042-2/+2
| | | | llvm-svn: 268543
* Mark some test XFAIL for GCC 4.9 due to missing is_trivial* traitsEric Fiselier2016-01-202-1/+12
| | | | llvm-svn: 258287
OpenPOWER on IntegriCloud