SmallVector: Crank up verbosity of asserts per Chandler's request.

Also add assertions to validate the iterator in the insert method overloads.

llvm-svn: 160882
This commit is contained in:
Benjamin Kramer 2012-07-27 19:05:58 +00:00
parent c25f88b703
commit 718b007fe9
1 changed files with 19 additions and 3 deletions

View File

@ -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.