1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

Add bound checks in SmallVector

llvm-svn: 56432
This commit is contained in:
Rafael Espindola 2008-09-22 10:06:26 +00:00
parent d1fdff199f
commit efe64e5f1e

View File

@ -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];
}