mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-28 14:10:55 +00:00
Ensure moved-from container is cleared on move
In all cases except for this optimistic attempt to reuse memory, the moved-from TinyPtrVector was left `empty()` at the end of this assignment. Though using a container after it's been moved from can be a bit sketchy, it's probably best to just be consistent here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320408 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1bc958a4c1
commit
1559083a44
@ -97,6 +97,7 @@ public:
|
||||
if (RHS.Val.template is<EltTy>()) {
|
||||
V->clear();
|
||||
V->push_back(RHS.front());
|
||||
RHS.Val = (EltTy)nullptr;
|
||||
return *this;
|
||||
}
|
||||
delete V;
|
||||
|
@ -152,6 +152,12 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveCtorTest) {
|
||||
TypeParam Move(std::move(Copy2));
|
||||
this->expectValues(Move, this->testArray(42));
|
||||
this->expectValues(Copy2, this->testArray(0));
|
||||
|
||||
TypeParam MultipleElements(this->testArray(2));
|
||||
TypeParam SingleElement(this->testArray(1));
|
||||
MultipleElements = std::move(SingleElement);
|
||||
this->expectValues(MultipleElements, this->testArray(1));
|
||||
this->expectValues(SingleElement, this->testArray(0));
|
||||
}
|
||||
|
||||
TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) {
|
||||
|
Loading…
Reference in New Issue
Block a user