llvm.org GIT mirror llvm / 57ba611
Fix BitVector move ctor/assignment. Current implementation leaves the object in an invalid state. This reverts commit bf0c389ac683cd6c0e5959b16537e59e5f4589e3. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272965 91177308-0d34-0410-b5e6-96231b3b80d8 Evgeniy Stepanov 3 years ago
2 changed file(s) with 28 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
104104 BitVector(BitVector &&RHS)
105105 : Bits(RHS.Bits), Size(RHS.Size), Capacity(RHS.Capacity) {
106106 RHS.Bits = nullptr;
107 RHS.Size = RHS.Capacity = 0;
107108 }
108109
109110 ~BitVector() {
453454 Capacity = RHS.Capacity;
454455
455456 RHS.Bits = nullptr;
457 RHS.Size = RHS.Capacity = 0;
456458
457459 return *this;
458460 }
398398 C.reset(C);
399399 EXPECT_TRUE(C.none());
400400 }
401
402 TYPED_TEST(BitVectorTest, MoveConstructor) {
403 TypeParam A(10, true);
404 TypeParam B(std::move(A));
405 // Check that the move ctor leaves the moved-from object in a valid state.
406 // The following line used to crash.
407 A = B;
408
409 TypeParam C(10, true);
410 EXPECT_EQ(C, A);
411 EXPECT_EQ(C, B);
412 }
413
414 TYPED_TEST(BitVectorTest, MoveAssignment) {
415 TypeParam A(10, true);
416 TypeParam B;
417 B = std::move(A);
418 // Check that move assignment leaves the moved-from object in a valid state.
419 // The following line used to crash.
420 A = B;
421
422 TypeParam C(10, true);
423 EXPECT_EQ(C, A);
424 EXPECT_EQ(C, B);
425 }
426
401427 }
402428 #endif