mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
Lift self-copy protection up to the header file and add self-move
protection to the same layer. This is in line with Howard's advice on how best to handle self-move assignment as he explained on SO[1]. It also ensures that implementing swap with move assignment continues to work in the case of self-swap. [1]: http://stackoverflow.com/questions/9322174/move-assignment-operator-and-if-this-rhs git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195705 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -218,8 +218,7 @@ SmallPtrSetImpl::SmallPtrSetImpl(const void **SmallStorage, unsigned SmallSize,
|
||||
/// CopyFrom - implement operator= from a smallptrset that has the same pointer
|
||||
/// type, but may have a different small size.
|
||||
void SmallPtrSetImpl::CopyFrom(const SmallPtrSetImpl &RHS) {
|
||||
if (&RHS == this)
|
||||
return;
|
||||
assert(&RHS != this && "Self-copy should be handled by the caller.");
|
||||
|
||||
if (isSmall() && RHS.isSmall())
|
||||
assert(CurArraySize == RHS.CurArraySize &&
|
||||
@@ -256,6 +255,8 @@ void SmallPtrSetImpl::CopyFrom(const SmallPtrSetImpl &RHS) {
|
||||
|
||||
#if LLVM_HAS_RVALUE_REFERENCES
|
||||
void SmallPtrSetImpl::MoveFrom(unsigned SmallSize, SmallPtrSetImpl &&RHS) {
|
||||
assert(&RHS != this && "Self-move should be handled by the caller.");
|
||||
|
||||
if (!isSmall())
|
||||
free(CurArray);
|
||||
|
||||
|
Reference in New Issue
Block a user