[llvm-commits] [llvm] r72221 - /llvm/trunk/include/llvm/ADT/SmallVector.h

Jay Foad jay.foad at gmail.com
Thu May 21 12:49:01 PDT 2009


Author: foad
Date: Thu May 21 14:48:58 2009
New Revision: 72221

URL: http://llvm.org/viewvc/llvm-project?rev=72221&view=rev
Log:
Tighten up the asserts in SmallVector::operator[]().
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.

Modified:
    llvm/trunk/include/llvm/ADT/SmallVector.h

Modified: llvm/trunk/include/llvm/ADT/SmallVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=72221&r1=72220&r2=72221&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/SmallVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SmallVector.h Thu May 21 14:48:58 2009
@@ -121,14 +121,12 @@
   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];
   }
 





More information about the llvm-commits mailing list