Tighten up the asserts in SmallVector::operator[]().
authorJay Foad <jay.foad@gmail.com>
Thu, 21 May 2009 19:48:58 +0000 (19:48 +0000)
committerJay Foad <jay.foad@gmail.com>
Thu, 21 May 2009 19:48:58 +0000 (19:48 +0000)
If this causes any new assertion failures that I didn't catch in
testing, the fix is usually to change "&v[0]" to "v.data()" for some
SmallVector v.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72221 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/SmallVector.h

index de5648fe8527074bcd5b2e0da5cdfcc227da0787..f59a438d3eb4f98b276a6e30b70f81bb6c3a9815 100644 (file)
@@ -121,14 +121,12 @@ public:
   const_reverse_iterator rend() const { return const_reverse_iterator(begin());}
 
 
-  /* These asserts could be "Begin + idx < End", but there are lots of places
-     in llvm where we use &v[v.size()] instead of v.end(). */
   reference operator[](unsigned idx) {
-    assert (Begin + idx <= End);
+    assert (Begin + idx < End);
     return Begin[idx];
   }
   const_reference operator[](unsigned idx) const {
-    assert (Begin + idx <= End);
+    assert (Begin + idx < End);
     return Begin[idx];
   }