Make the assignment operator for SmallPtrSet return a reference, and fix a long-standing bug in the copy
ctor while I'm at it.
Thanks to Chris Lattner for help with this patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38470 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/ADT/SmallPtrSet.h b/include/llvm/ADT/SmallPtrSet.h
index 2563982..9f975af 100644
--- a/include/llvm/ADT/SmallPtrSet.h
+++ b/include/llvm/ADT/SmallPtrSet.h
@@ -240,7 +240,7 @@
// Allow assignment from any smallptrset with the same element type even if it
// doesn't have the same smallsize.
- const SmallPtrSet<PtrType, SmallSize>
+ const SmallPtrSet<PtrType, SmallSize>&
operator=(const SmallPtrSet<PtrType, SmallSize> &RHS) {
CopyFrom(RHS);
return *this;
diff --git a/lib/Support/SmallPtrSet.cpp b/lib/Support/SmallPtrSet.cpp
index 5ad2430..e8e530f 100644
--- a/lib/Support/SmallPtrSet.cpp
+++ b/lib/Support/SmallPtrSet.cpp
@@ -164,7 +164,7 @@
CurArray[CurArraySize] = 0;
// Copy over all valid entries.
- for (void **BucketPtr = that.CurArray, **E = that.CurArray+CurArraySize;
+ for (void **BucketPtr = that.CurArray, **E = that.CurArray+that.CurArraySize;
BucketPtr != E; ++BucketPtr) {
// Copy over the element if it is valid.
void *Elt = *BucketPtr;