mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Add bound checks in SmallVector
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56432 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
namespace std {
|
namespace std {
|
||||||
@@ -116,10 +117,14 @@ public:
|
|||||||
const_reverse_iterator rend() const { return const_reverse_iterator(begin());}
|
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) {
|
reference operator[](unsigned idx) {
|
||||||
|
assert (Begin + idx <= End);
|
||||||
return Begin[idx];
|
return Begin[idx];
|
||||||
}
|
}
|
||||||
const_reference operator[](unsigned idx) const {
|
const_reference operator[](unsigned idx) const {
|
||||||
|
assert (Begin + idx <= End);
|
||||||
return Begin[idx];
|
return Begin[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user