[llvm-commits] [llvm] r56432 - /llvm/trunk/include/llvm/ADT/SmallVector.h
Rafael Espindola
rafael.espindola at gmail.com
Mon Sep 22 03:06:27 PDT 2008
Author: rafael
Date: Mon Sep 22 05:06:26 2008
New Revision: 56432
URL: http://llvm.org/viewvc/llvm-project?rev=56432&view=rev
Log:
Add bound checks in SmallVector
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=56432&r1=56431&r2=56432&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SmallVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SmallVector.h Mon Sep 22 05:06:26 2008
@@ -19,6 +19,7 @@
#include <algorithm>
#include <cstring>
#include <memory>
+#include <cassert>
#ifdef _MSC_VER
namespace std {
@@ -116,10 +117,14 @@
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);
return Begin[idx];
}
const_reference operator[](unsigned idx) const {
+ assert (Begin + idx <= End);
return Begin[idx];
}
More information about the llvm-commits
mailing list