summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/ADT/APInt.h14
-rw-r--r--llvm/unittests/ADT/APIntTest.cpp32
2 files changed, 5 insertions, 41 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 22ca29e3e63..92aa08dfaa1 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -693,24 +693,16 @@ public:
/// @brief Move assignment operator.
APInt &operator=(APInt &&that) {
- if (!isSingleWord()) {
- // The MSVC STL shipped in 2013 requires that self move assignment be a
- // no-op. Otherwise algorithms like stable_sort will produce answers
- // where half of the output is left in a moved-from state.
- if (this == &that)
- return *this;
+ assert(this != &that && "Self-move not supported");
+ if (!isSingleWord())
delete[] pVal;
- }
// Use memcpy so that type based alias analysis sees both VAL and pVal
// as modified.
memcpy(&VAL, &that.VAL, sizeof(uint64_t));
- // If 'this == &that', avoid zeroing our own bitwidth by storing to 'that'
- // first.
- unsigned ThatBitWidth = that.BitWidth;
+ BitWidth = that.BitWidth;
that.BitWidth = 0;
- BitWidth = ThatBitWidth;
return *this;
}
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index 65481f5b2f2..d24d5800a40 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -1606,36 +1606,6 @@ TEST(APIntTest, isShiftedMask) {
}
}
-#if defined(__clang__)
-// Disable the pragma warning from versions of Clang without -Wself-move
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunknown-pragmas"
-// Disable the warning that triggers on exactly what is being tested.
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wself-move"
-#endif
-TEST(APIntTest, SelfMoveAssignment) {
- APInt X(32, 0xdeadbeef);
- X = std::move(X);
- EXPECT_EQ(32u, X.getBitWidth());
- EXPECT_EQ(0xdeadbeefULL, X.getLimitedValue());
-
- uint64_t Bits[] = {0xdeadbeefdeadbeefULL, 0xdeadbeefdeadbeefULL};
- APInt Y(128, Bits);
- Y = std::move(Y);
- EXPECT_EQ(128u, Y.getBitWidth());
- EXPECT_EQ(~0ULL, Y.getLimitedValue());
- const uint64_t *Raw = Y.getRawData();
- EXPECT_EQ(2u, Y.getNumWords());
- EXPECT_EQ(0xdeadbeefdeadbeefULL, Raw[0]);
- EXPECT_EQ(0xdeadbeefdeadbeefULL, Raw[1]);
-}
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#pragma clang diagnostic pop
-#endif
-}
-
TEST(APIntTest, reverseBits) {
EXPECT_EQ(1, APInt(1, 1).reverseBits());
EXPECT_EQ(0, APInt(1, 0).reverseBits());
@@ -2025,3 +1995,5 @@ TEST(APIntTest, GCD) {
APInt C = GreatestCommonDivisor(A, B);
EXPECT_EQ(C, HugePrime);
}
+
+} // end anonymous namespace
OpenPOWER on IntegriCloud