summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/SmallPtrSet.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2013-11-20 18:29:56 +0000
committerChandler Carruth <chandlerc@gmail.com>2013-11-20 18:29:56 +0000
commitc74010df48919a8360e3e095b1cdcbb71dda14be (patch)
tree36571e15ffb1ea14ee134ab337156c14cb6ec1a4 /llvm/lib/Support/SmallPtrSet.cpp
parent6d888bc0daa7195e475aecfffa412b2555508787 (diff)
downloadbcm5719-llvm-c74010df48919a8360e3e095b1cdcbb71dda14be.tar.gz
bcm5719-llvm-c74010df48919a8360e3e095b1cdcbb71dda14be.zip
Make the moved-from SmallPtrSet be a valid, empty, small-state object.
Enhance the tests to actually require moves in C++11 mode, in addition to testing the moved-from state. Further enhance the tests to cover copy-assignment into a moved-from object and moving a large-state object. (Note that we can't really test small-state vs. large-state as that isn't an observable property of the API really.) This should finish addressing review on r195239. llvm-svn: 195261
Diffstat (limited to 'llvm/lib/Support/SmallPtrSet.cpp')
-rw-r--r--llvm/lib/Support/SmallPtrSet.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/llvm/lib/Support/SmallPtrSet.cpp b/llvm/lib/Support/SmallPtrSet.cpp
index 9b86a793513..e37e23b7bb1 100644
--- a/llvm/lib/Support/SmallPtrSet.cpp
+++ b/llvm/lib/Support/SmallPtrSet.cpp
@@ -206,6 +206,12 @@ SmallPtrSetImpl::SmallPtrSetImpl(const void **SmallStorage, unsigned SmallSize,
// Otherwise, we steal the large memory allocation and no copy is needed.
CurArray = that.CurArray;
that.CurArray = that.SmallArray;
+
+ // Make the "that" object small and empty.
+ that.CurArraySize = SmallSize;
+ assert(that.CurArray == that.SmallArray);
+ that.NumElements = 0;
+ that.NumTombstones = 0;
}
#endif
@@ -246,7 +252,7 @@ void SmallPtrSetImpl::CopyFrom(const SmallPtrSetImpl &RHS) {
}
#if LLVM_HAS_RVALUE_REFERENCES
-void SmallPtrSetImpl::MoveFrom(SmallPtrSetImpl &&RHS) {
+void SmallPtrSetImpl::MoveFrom(unsigned SmallSize, SmallPtrSetImpl &&RHS) {
if (!isSmall())
free(CurArray);
@@ -263,6 +269,12 @@ void SmallPtrSetImpl::MoveFrom(SmallPtrSetImpl &&RHS) {
CurArraySize = RHS.CurArraySize;
NumElements = RHS.NumElements;
NumTombstones = RHS.NumTombstones;
+
+ // Make the RHS small and empty.
+ RHS.CurArraySize = SmallSize;
+ assert(RHS.CurArray == RHS.SmallArray);
+ RHS.NumElements = 0;
+ RHS.NumTombstones = 0;
}
#endif
OpenPOWER on IntegriCloud