[PATCH] D96536: Make sure some types are indeed trivially_copyable per llvm::is_trivially_copyable
serge via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 24 09:25:18 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGca0bb0e88750: Make sure some types are indeed trivially_copyable per llvm… (authored by serge-sans-paille).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96536/new/
https://reviews.llvm.org/D96536
Files:
llvm/unittests/Support/TypeTraitsTest.cpp
Index: llvm/unittests/Support/TypeTraitsTest.cpp
===================================================================
--- llvm/unittests/Support/TypeTraitsTest.cpp
+++ llvm/unittests/Support/TypeTraitsTest.cpp
@@ -6,6 +6,12 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/FunctionExtras.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/type_traits.h"
#include "gtest/gtest.h"
@@ -92,6 +98,26 @@
TrivialityTester<B &&, false, true>();
}
+// Test that the following ADT behave as expected wrt. trivially copyable trait
+//
+// NB: It is important that this trait behaves the same for (at least) these
+// types for all supported compilers to prevent ABI issue when llvm is compiled
+// with compiler A and an other project using llvm is compiled with compiler B.
+
+TEST(Triviality, ADT) {
+
+ TrivialityTester<llvm::SmallVector<int>, false, false>();
+ TrivialityTester<llvm::SmallString<8>, false, false>();
+
+ TrivialityTester<std::function<int()>, false, false>();
+ TrivialityTester<std::pair<int, bool>, true, true>();
+ TrivialityTester<llvm::unique_function<int()>, false, false>();
+ TrivialityTester<llvm::StringRef, true, true>();
+ TrivialityTester<llvm::ArrayRef<int>, true, true>();
+ TrivialityTester<llvm::PointerIntPair<int *, 2>, true, true>();
+ TrivialityTester<llvm::Optional<int>, true, true>();
+}
+
} // namespace triviality
} // end anonymous namespace
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96536.326118.patch
Type: text/x-patch
Size: 1612 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210224/11bb0b1a/attachment.bin>
More information about the llvm-commits
mailing list