diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index 9ca089877c7..2dbe7085ddc 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(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.