diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2017-10-31 18:35:54 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2017-10-31 18:35:54 +0000 |
commit | 5168f257d5b93e39eb983481ef8e190f49384968 (patch) | |
tree | 0027485c06408f21aa2412f76996d740a2876483 /llvm/unittests/ADT/OptionalTest.cpp | |
parent | 2d2798b3a7de613740124efe3925d4e464a986a6 (diff) | |
download | bcm5719-llvm-5168f257d5b93e39eb983481ef8e190f49384968.tar.gz bcm5719-llvm-5168f257d5b93e39eb983481ef8e190f49384968.zip |
[ADT] Split optional to only include copy mechanics and dtor for non-trivial types.
This makes uses of Optional more transparent to the compiler (and
clang-tidy) and generates slightly smaller code.
llvm-svn: 317019
Diffstat (limited to 'llvm/unittests/ADT/OptionalTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/OptionalTest.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/OptionalTest.cpp b/llvm/unittests/ADT/OptionalTest.cpp index 46d4fe0780c..a9a37bf820d 100644 --- a/llvm/unittests/ADT/OptionalTest.cpp +++ b/llvm/unittests/ADT/OptionalTest.cpp @@ -518,5 +518,14 @@ TEST_F(OptionalTest, OperatorGreaterEqual) { CheckRelation<GreaterEqual>(InequalityLhs, InequalityRhs, !IsLess); } +#if (__has_feature(is_trivially_copyable) && defined(_LIBCPP_VERSION)) || \ + (defined(__GNUC__) && __GNUC__ >= 5) +static_assert(std::is_trivially_copyable<Optional<int>>::value, + "Should be trivially copyable"); +static_assert( + !std::is_trivially_copyable<Optional<NonDefaultConstructible>>::value, + "Shouldn't be trivially copyable"); +#endif + } // end anonymous namespace |