summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-07-27 19:05:58 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-07-27 19:05:58 +0000
commite82fafe9e22c7f0bb35ec4cb7d5428bf9e930807 (patch)
tree73a54c36fb01fc6b6f958d324fb76a46d86c98a9
parent85aa39071303a517941117c07854874b1050f442 (diff)
downloadllvm-e82fafe9e22c7f0bb35ec4cb7d5428bf9e930807.tar.gz
llvm-e82fafe9e22c7f0bb35ec4cb7d5428bf9e930807.tar.bz2
llvm-e82fafe9e22c7f0bb35ec4cb7d5428bf9e930807.tar.xz
SmallVector: Crank up verbosity of asserts per Chandler's request.
Also add assertions to validate the iterator in the insert method overloads. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160882 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ADT/SmallVector.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h
index 9ca089877c..2dbe7085dd 100644
--- a/include/llvm/ADT/SmallVector.h
+++ b/include/llvm/ADT/SmallVector.h
@@ -463,7 +463,9 @@ public:
}
iterator erase(iterator I) {
- assert(I >= this->begin() && I < this->end() && "Iterator out of bounds");
+ assert(I >= this->begin() && "Iterator to erase is out of bounds.");
+ assert(I < this->end() && "Erasing at past-the-end iterator.");
+
iterator N = I;
// Shift all elts down one.
this->move(I+1, this->end(), I);
@@ -473,8 +475,10 @@ public:
}
iterator erase(iterator S, iterator E) {
- assert(S >= this->begin() && S <= E && E <= this->end() &&
- "Iterator range out of bounds");
+ assert(S >= this->begin() && "Range to erase is out of bounds.");
+ assert(S <= E && "Trying to erase invalid range.");
+ assert(E <= this->end() && "Trying to erase past the end.");
+
iterator N = S;
// Shift all elts down.
iterator I = this->move(E, this->end(), S);
@@ -491,6 +495,9 @@ public:
return this->end()-1;
}
+ assert(I >= this->begin() && "Insertion iterator is out of bounds.");
+ assert(I <= this->end() && "Inserting past the end of the vector.");
+
if (this->EndX < this->CapacityX) {
Retry:
::new ((void*) this->end()) T(::std::move(this->back()));
@@ -520,6 +527,9 @@ public:
return this->end()-1;
}
+ assert(I >= this->begin() && "Insertion iterator is out of bounds.");
+ assert(I <= this->end() && "Inserting past the end of the vector.");
+
if (this->EndX < this->CapacityX) {
Retry:
::new ((void*) this->end()) T(this->back());
@@ -551,6 +561,9 @@ public:
return this->begin()+InsertElt;
}
+ assert(I >= this->begin() && "Insertion iterator is out of bounds.");
+ assert(I <= this->end() && "Inserting past the end of the vector.");
+
// Ensure there is enough space.
reserve(static_cast<unsigned>(this->size() + NumToInsert));
@@ -599,6 +612,9 @@ public:
return this->begin()+InsertElt;
}
+ assert(I >= this->begin() && "Insertion iterator is out of bounds.");
+ assert(I <= this->end() && "Inserting past the end of the vector.");
+
size_t NumToInsert = std::distance(From, To);
// Ensure there is enough space.