[llvm] ebdc886 - [APInt] Allow self-assignment with libstdc++
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 20 04:14:51 PDT 2020
Author: Vitaly Buka
Date: 2020-08-20T04:14:40-07:00
New Revision: ebdc886b5f3f9843c3b89d2e7c86c0ba7aa7fded
URL: https://github.com/llvm/llvm-project/commit/ebdc886b5f3f9843c3b89d2e7c86c0ba7aa7fded
DIFF: https://github.com/llvm/llvm-project/commit/ebdc886b5f3f9843c3b89d2e7c86c0ba7aa7fded.diff
LOG: [APInt] Allow self-assignment with libstdc++
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-ubuntu/builds/8256/steps/test-check-all/logs/FAIL%3A%20LLVM%3A%3Athinlto-function-summary-paramaccess.ll
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D86053
Added:
Modified:
llvm/include/llvm/ADT/APInt.h
llvm/unittests/ADT/APIntTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 715f7cd4fdf3..e3032a19f111 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -765,8 +765,8 @@ class LLVM_NODISCARD APInt {
/// Move assignment operator.
APInt &operator=(APInt &&that) {
-#ifdef _MSC_VER
- // The MSVC std::shuffle implementation still does self-assignment.
+#ifdef EXPENSIVE_CHECKS
+ // Some std::shuffle implementations still do self-assignment.
if (this == &that)
return *this;
#endif
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index 37ab21bcfaf2..4b8e8c720652 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -1783,8 +1783,9 @@ TEST(APIntTest, isShiftedMask) {
}
}
-// Test that self-move works, but only when we're using MSVC.
-#if defined(_MSC_VER)
+// Test that self-move works with EXPENSIVE_CHECKS. It calls std::shuffle which
+// does self-move on some platforms.
+#ifdef EXPENSIVE_CHECKS
#if defined(__clang__)
// Disable the pragma warning from versions of Clang without -Wself-move
#pragma clang diagnostic push
@@ -1813,7 +1814,7 @@ TEST(APIntTest, SelfMoveAssignment) {
#pragma clang diagnostic pop
#pragma clang diagnostic pop
#endif
-#endif // _MSC_VER
+#endif // EXPENSIVE_CHECKS
TEST(APIntTest, byteSwap) {
EXPECT_EQ(0x00000000, APInt(16, 0x0000).byteSwap());
More information about the llvm-commits
mailing list