summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/OptionalTest.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2018-01-18 11:26:24 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2018-01-18 11:26:24 +0000
commitc806d39182c1aa6c647d044d19d58aad9f5c95df (patch)
tree10d1bc2ac6c65fe8cef5f8e00eeab781e04b6cfe /llvm/unittests/ADT/OptionalTest.cpp
parent878469cd829757a27fbdca8bc7ce1ca3a8cbd29e (diff)
downloadbcm5719-llvm-c806d39182c1aa6c647d044d19d58aad9f5c95df.tar.gz
bcm5719-llvm-c806d39182c1aa6c647d044d19d58aad9f5c95df.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. 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
Diffstat (limited to 'llvm/unittests/ADT/OptionalTest.cpp')
-rw-r--r--llvm/unittests/ADT/OptionalTest.cpp9
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
OpenPOWER on IntegriCloud