summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/OptionalTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert rL368939 "Remove LVALUE / RVALUE workarounds"Russell Gallop2019-08-151-0/+4
| | | | | | | | This reverts commit cad8356d699b36c73abb267f65db575ddacbd652. To unbreak Windows bots llvm-svn: 368985
* Remove LVALUE / RVALUE workaroundsJF Bastien2019-08-141-4/+0
| | | | | | | | | | | | Summary: LLVM_HAS_RVALUE_REFERENCE_THIS and LLVM_LVALUE_FUNCTION shouldn't be needed anymore because the minimum compiler versions support them. Subscribers: jkorous, dexonsmith, cfe-commits, llvm-commits, hans, thakis, chandlerc, rnk Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D66240 llvm-svn: 368939
* [NFC] Make Optional<T> trivially copyable when T is trivially copyableSerge Guelton2019-02-181-0/+21
| | | | | | | | | | | This is a follow-up to r354246 and a reimplementation of https://reviews.llvm.org/D57097?id=186600 that should not trigger any UB thanks to the use of an union. This may still be subject to the problem solved by std::launder, but I'm unsure how it interacts whith union. /me plans to revert if this triggers any relevant bot failure. At least this validates in Release mode with clang 6.0.1 and gcc 4.8.5. llvm-svn: 354264
* Revert r354199: Make Optional<T> Trivially Copyable when T is trivially ↵Serge Guelton2019-02-161-7/+0
| | | | | | copyable llvm-svn: 354200
* Make Optional<T> Trivially Copyable when T is trivially copyableSerge Guelton2019-02-161-0/+7
| | | | | | | This is another attempt in the process, works nicely on my setup, let's check how it behaves on other targets. llvm-svn: 354199
* Speculatively revert r354051 "Recommit Optional specialization for trivially ↵Hans Wennborg2019-02-151-20/+0
| | | | | | | | | | | | | | | | | | | | | copyable types" and r354055 "Optional specialization for trivially copyable types, part2" These are suspected to cause Clang to get miscompiled on Ubuntu 14.04 (Trusty) which uses GCC 4.8.4. Reverting for an hour to see if this helps. See llvm-commits thread. > Recommit Optional specialization for trivially copyable types > > Unfortunately the original code gets misscompiled by GCC (at least 8.1), > this is a tentative workaround using std::memcpy instead of inplace new > for trivially copyable types. I'll revert if it breaks. > > Original revision: https://reviews.llvm.org/D57097 llvm-svn: 354126
* Recommit Optional specialization for trivially copyable typesSerge Guelton2019-02-141-0/+20
| | | | | | | | | | Unfortunately the original code gets misscompiled by GCC (at least 8.1), this is a tentative workaround using std::memcpy instead of inplace new for trivially copyable types. I'll revert if it breaks. Original revision: https://reviews.llvm.org/D57097 llvm-svn: 354051
* Revert r353962Serge Guelton2019-02-131-20/+0
| | | | | | | Specialization of Optional for trivially copyable types yields failure on the buildbots I fail to reproduce locally. Better safe than sorry, reverting. llvm-svn: 353982
* Re-commit rL353927, patch includedSerge Guelton2019-02-131-0/+20
| | | | | | | | | | | | | | | Make llvm::Optional<T> trivially copyable when T is trivially copyable This is an ever-recurring issue (see https://bugs.llvm.org/show_bug.cgi?id=39427 and https://bugs.llvm.org/show_bug.cgi?id=35978) but I believe that thanks to https://reviews.llvm.org/D54472 we can now ship a decent implementation of this. Basically the fact that llvm::is_trivially_copyable has a consistent behavior across compilers should prevent any ABI issue, and using in-place new instead of memcpy should keep compiler bugs away. This patch is slightly different from the original revision https://reviews.llvm.org/rL353927 but achieves the same goal. It just avoids going through std::conditional which may the code more explicit. llvm-svn: 353962
* Revert r353927Serge Guelton2019-02-131-20/+0
| | | | llvm-svn: 353940
* Missing headerSerge Guelton2019-02-131-0/+2
| | | | llvm-svn: 353933
* Make llvm::Optional<T> trivially copyable when T is trivially copyableSerge Guelton2019-02-131-0/+20
| | | | | | | | | | | | This is an ever-recurring issue (see https://bugs.llvm.org/show_bug.cgi?id=39427 and https://bugs.llvm.org/show_bug.cgi?id=35978) but I believe that thanks to https://reviews.llvm.org/D54472 we can now ship a decent implementation of this. Basically the fact that llvm::is_trivially_copyable has a consistent behavior across compilers should prevent any ABI issue, and using in-place new instead of memcpy should keep compiler bugs away. Differential Revision: https://reviews.llvm.org/D57097 llvm-svn: 353927
* Fix compilation error with gcc 4.8Pavel Labath2019-01-211-4/+4
| | | | | | | This version of gcc seems to be having issues with raw literals inside macro arguments. I change the string to use regular string literals instead. llvm-svn: 351756
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. 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: 351636
* [ADT] Add streaming operators for llvm::OptionalPavel Labath2019-01-181-1/+51
| | | | | | | | | | | | | | | | | | | | | | | Summary: The operators simply print the underlying value or "None". The trickier part of this patch is making sure the streaming operators work even in unit tests (which was my primary motivation, though I can also see them being useful elsewhere). Since the stream operator was a template, implicit conversions did not kick in, and our gtest glue code was explicitly introducing an implicit conversion to make sure other implicit conversions do not kick in :P. I resolve that by specializing llvm_gtest::StreamSwitch for llvm:Optional<T>. Reviewers: sammccall, dblaikie Reviewed By: sammccall Subscribers: mgorny, dexonsmith, kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D56795 llvm-svn: 351548
* Re-apply r346985: [ADT] Drop llvm::Optional clang-specific optimization for ↵Tom Stellard2018-11-161-8/+0
| | | | | | | | | trivially copyable types Remove a test case that was added with the optimization we are now removing. llvm-svn: 347004
* [ADT] Make moving Optional not reset the Optional it moves from.Benjamin Kramer2018-01-251-6/+6
| | | | | | | | | This brings it in line with std::optional. My recent changes to make Optional of trivial types trivially copyable introduced diverging behavior depending on the type, which is bad. Now all types have the same moving behavior. llvm-svn: 323445
* [ADT] Just give up on GCC, I can't fix this.Benjamin Kramer2018-01-181-2/+1
| | | | | | | | | | While the memmove workaround fixed it for GCC 6.3. GCC 4.8 and GCC 7.1 are still broken. I have no clue what's going on, just blacklist GCC for now. Needless to say this code is ubsan, asan and msan-clean. llvm-svn: 322862
* [ADT] Split optional to only include copy mechanics and dtor for non-trivial ↵Benjamin Kramer2018-01-181-0/+9
| | | | | | | | | | | | | types. This makes uses of Optional more transparent to the compiler (and clang-tidy) and generates slightly smaller code. This is a re-land of r317019, which had issues with GCC 4.8 back then. Those issues don't reproduce anymore, but I'll watch the buildbots closely in case anything goes wrong. llvm-svn: 322838
* Revert rL317019, "[ADT] Split optional to only include copy mechanics and ↵NAKAMURA Takumi2017-11-011-9/+0
| | | | | | | | dtor for non-trivial types." Seems g++-4.8 (eg. Ubuntu 14.04) doesn't like this. llvm-svn: 317077
* [ADT] Split optional to only include copy mechanics and dtor for non-trivial ↵Benjamin Kramer2017-10-311-0/+9
| | | | | | | | | types. This makes uses of Optional more transparent to the compiler (and clang-tidy) and generates slightly smaller code. llvm-svn: 317019
* Re-sort #include lines for unittests. This uses a slightly modifiedChandler Carruth2017-06-061-1/+1
| | | | | | | | | | | | | | | clang-format (https://reviews.llvm.org/D33932) to keep primary headers at the top and handle new utility headers like 'gmock' consistently with other utility headers. No other change was made. I did no manual edits, all of this is clang-format. This should allow other changes to have more clear and focused diffs, and is especially motivated by moving some headers into more focused libraries. llvm-svn: 304786
* [ADT] Add relation operators for OptionalTim Shen2016-08-111-11/+139
| | | | | | | | | | | | Summary: Make Optional's behavior the same as the coming std::optional. Reviewers: dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23178 llvm-svn: 278397
* Allow Optionals to be compared to NoneDavid Blaikie2015-08-191-0/+13
| | | | | | | | | | | This is something like nullopt in std::experimental::optional. Optional could already be constructed from None, so this seems like an obvious extension from there. I have a use in a future patch for Clang, though it may not go that way/end up used - so this seemed worth committing now regardless. llvm-svn: 245518
* Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for ↵Aaron Ballman2015-02-151-5/+5
| | | | | | requiring the macro. NFC; LLVM edition. llvm-svn: 229340
* Update test name to match changes made in r218783David Blaikie2014-10-011-1/+1
| | | | | | Addressing post commit review feedback from Justin Bogner. llvm-svn: 218821
* Add an immovable type to test Optional<T>::emplace more rigorously after ↵David Blaikie2014-10-011-5/+26
| | | | | | r218732. llvm-svn: 218783
* ADTTests/OptionalTest.cpp: Use LLVM_DELETED_FUNCTION.NAKAMURA Takumi2014-10-011-4/+4
| | | | llvm-svn: 218750
* Add an emplace(...) method to llvm::Optional<T>.Jordan Rose2014-10-011-0/+49
| | | | | | | | | | | | | This can be used for in-place initialization of non-moveable types. For compilers that don't support variadic templates, only up to four arguments are supported. We can always add more, of course, but this should be good enough until we move to a later MSVC that has full support for variadic templates. Inspired by std::experimental::optional from the "Library Fundamentals" C++ TS. Reviewed by David Blaikie. llvm-svn: 218732
* Add getValueOr to llvm::Optional<T>.Jordan Rose2014-09-291-0/+29
| | | | | | | | | | This takes a single argument convertible to T, and - if the Optional has a value, returns the existing value, - otherwise, constructs a T from the argument and returns that. Inspired by std::experimental::optional from the "Library Fundamentals" C++ TS. llvm-svn: 218618
* [C++11] Remove uses of LLVM_HAS_RVALUE_REFERENCES from the unittests.Chandler Carruth2014-03-011-2/+0
| | | | llvm-svn: 202583
* Only include move-related Optional<T> tests when rvalue references are ↵David Blaikie2013-02-211-30/+32
| | | | | | available. llvm-svn: 175730
* Add move ctor/assignment to Optional<T>David Blaikie2013-02-211-0/+109
| | | | | | Code review feedback for r175580 by Jordan Rose. llvm-svn: 175729
* Rename llvm::Optional<T>::Reset to 'reset' as per LLVM naming conventions.David Blaikie2013-02-201-1/+1
| | | | | | Code review feedback on r175580 from Jordan Rose. llvm-svn: 175595
* Allow llvm::Optional to work with types without default constructors.David Blaikie2013-02-201-0/+173
This generalizes Optional to require less from the T type by using aligned storage for backing & placement new/deleting the T into it when necessary. Also includes unit tests. llvm-svn: 175580
OpenPOWER on IntegriCloud