summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/SmallPtrSet.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-03-07 22:33:21 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-03-07 22:33:21 +0000
commit6e8d4b8eb4c45fde5a11607438905efa529e268d (patch)
treedafe537f58fb3df0aebd01841300b357c603771f /llvm/lib/Support/SmallPtrSet.cpp
parenta8b3dbf20f1812e691449e7ae2a26d335bea8fc0 (diff)
downloadbcm5719-llvm-6e8d4b8eb4c45fde5a11607438905efa529e268d.tar.gz
bcm5719-llvm-6e8d4b8eb4c45fde5a11607438905efa529e268d.zip
SmallPtrSet: Copy all the elements when swapping, not just numelements.
This fixes a build failure in webkit. Copying all elements shouldn't be necessary, I'll look out for a better fix soon. llvm-svn: 152252
Diffstat (limited to 'llvm/lib/Support/SmallPtrSet.cpp')
-rw-r--r--llvm/lib/Support/SmallPtrSet.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Support/SmallPtrSet.cpp b/llvm/lib/Support/SmallPtrSet.cpp
index dd516d37f05..92ffa49833d 100644
--- a/llvm/lib/Support/SmallPtrSet.cpp
+++ b/llvm/lib/Support/SmallPtrSet.cpp
@@ -241,7 +241,7 @@ void SmallPtrSetImpl::swap(SmallPtrSetImpl &RHS) {
// If only RHS is small, copy the small elements into LHS and move the pointer
// from LHS to RHS.
if (!this->isSmall() && RHS.isSmall()) {
- std::copy(RHS.SmallArray, RHS.SmallArray+RHS.NumElements, this->SmallArray);
+ std::copy(RHS.SmallArray, RHS.SmallArray+CurArraySize, this->SmallArray);
std::swap(this->NumElements, RHS.NumElements);
std::swap(this->CurArraySize, RHS.CurArraySize);
RHS.CurArray = this->CurArray;
@@ -254,8 +254,7 @@ void SmallPtrSetImpl::swap(SmallPtrSetImpl &RHS) {
// If only LHS is small, copy the small elements into RHS and move the pointer
// from RHS to LHS.
if (this->isSmall() && !RHS.isSmall()) {
- std::copy(this->SmallArray, this->SmallArray+this->NumElements,
- RHS.SmallArray);
+ std::copy(this->SmallArray, this->SmallArray+CurArraySize, RHS.SmallArray);
std::swap(RHS.NumElements, this->NumElements);
std::swap(RHS.CurArraySize, this->CurArraySize);
this->CurArray = RHS.CurArray;
@@ -268,8 +267,8 @@ void SmallPtrSetImpl::swap(SmallPtrSetImpl &RHS) {
// Both a small, just swap the small elements.
assert(this->isSmall() && RHS.isSmall());
assert(this->CurArraySize == RHS.CurArraySize);
- unsigned MaxElems = std::max(this->NumElements, RHS.NumElements);
- std::swap_ranges(this->SmallArray, this->SmallArray+MaxElems, RHS.SmallArray);
+ std::swap_ranges(this->SmallArray, this->SmallArray+CurArraySize,
+ RHS.SmallArray);
std::swap(this->NumElements, RHS.NumElements);
}
OpenPOWER on IntegriCloud