[llvm] r272965 - Fix BitVector move ctor/assignment.

Evgenii Stepanov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 15:46:19 PDT 2016


No, it's a leftover from the way I've split this change from a larger commit.

On Thu, Jun 16, 2016 at 2:53 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
> On Thu, Jun 16, 2016 at 2:45 PM, Evgeniy Stepanov via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: eugenis
>> Date: Thu Jun 16 16:45:13 2016
>> New Revision: 272965
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=272965&view=rev
>> Log:
>> Fix BitVector move ctor/assignment.
>>
>> Current implementation leaves the object in an invalid state.
>>
>> This reverts commit bf0c389ac683cd6c0e5959b16537e59e5f4589e3.
>
>
> I assume this isn't a revert of anything, is it?
>
> (but if it is, we have llvm/utils/git-svn/git-svnrevert that helps revert a
> patch using a git hash, but produces a commit message that lists the SVN
> revision instead of the git hash, so it's useful for archival purposes)
>
>>
>>
>> Modified:
>>     llvm/trunk/include/llvm/ADT/BitVector.h
>>     llvm/trunk/unittests/ADT/BitVectorTest.cpp
>>
>> Modified: llvm/trunk/include/llvm/ADT/BitVector.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/BitVector.h?rev=272965&r1=272964&r2=272965&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/ADT/BitVector.h (original)
>> +++ llvm/trunk/include/llvm/ADT/BitVector.h Thu Jun 16 16:45:13 2016
>> @@ -105,6 +105,7 @@ public:
>>    BitVector(BitVector &&RHS)
>>      : Bits(RHS.Bits), Size(RHS.Size), Capacity(RHS.Capacity) {
>>      RHS.Bits = nullptr;
>> +    RHS.Size = RHS.Capacity = 0;
>>    }
>>
>>    ~BitVector() {
>> @@ -454,6 +455,7 @@ public:
>>      Capacity = RHS.Capacity;
>>
>>      RHS.Bits = nullptr;
>> +    RHS.Size = RHS.Capacity = 0;
>>
>>      return *this;
>>    }
>>
>> Modified: llvm/trunk/unittests/ADT/BitVectorTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/BitVectorTest.cpp?rev=272965&r1=272964&r2=272965&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/unittests/ADT/BitVectorTest.cpp (original)
>> +++ llvm/trunk/unittests/ADT/BitVectorTest.cpp Thu Jun 16 16:45:13 2016
>> @@ -399,5 +399,31 @@ TYPED_TEST(BitVectorTest, CompoundTestRe
>>    C.reset(C);
>>    EXPECT_TRUE(C.none());
>>  }
>> +
>> +TYPED_TEST(BitVectorTest, MoveConstructor) {
>> +  TypeParam A(10, true);
>> +  TypeParam B(std::move(A));
>> +  // Check that the move ctor leaves the moved-from object in a valid
>> state.
>> +  // The following line used to crash.
>> +  A = B;
>> +
>> +  TypeParam C(10, true);
>> +  EXPECT_EQ(C, A);
>> +  EXPECT_EQ(C, B);
>> +}
>> +
>> +TYPED_TEST(BitVectorTest, MoveAssignment) {
>> +  TypeParam A(10, true);
>> +  TypeParam B;
>> +  B = std::move(A);
>> +  // Check that move assignment leaves the moved-from object in a valid
>> state.
>> +  // The following line used to crash.
>> +  A = B;
>> +
>> +  TypeParam C(10, true);
>> +  EXPECT_EQ(C, A);
>> +  EXPECT_EQ(C, B);
>> +}
>> +
>>  }
>>  #endif
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>


More information about the llvm-commits mailing list