aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/SmallVector.h
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2008-09-22 10:06:26 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2008-09-22 10:06:26 +0000
commit73c3a94df976593fe6759446a4e30f95b493a76e (patch)
tree4945d7f4b41fbc18e9388fbd463556b50bf788e6 /include/llvm/ADT/SmallVector.h
parentb3334b6cced3670a24f28a215e44b13858417eca (diff)
downloadexternal_llvm-73c3a94df976593fe6759446a4e30f95b493a76e.zip
external_llvm-73c3a94df976593fe6759446a4e30f95b493a76e.tar.gz
external_llvm-73c3a94df976593fe6759446a4e30f95b493a76e.tar.bz2
Add bound checks in SmallVector
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56432 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/SmallVector.h')
-rw-r--r--include/llvm/ADT/SmallVector.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h
index fdecb6c..a1373e2 100644
--- a/include/llvm/ADT/SmallVector.h
+++ b/include/llvm/ADT/SmallVector.h
@@ -19,6 +19,7 @@
#include <algorithm>
#include <cstring>
#include <memory>
+#include <cassert>
#ifdef _MSC_VER
namespace std {
@@ -116,10 +117,14 @@ 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);
return Begin[idx];
}
const_reference operator[](unsigned idx) const {
+ assert (Begin + idx <= End);
return Begin[idx];
}