Insert array bound checks for slices.

This commit is contained in:
Christian Kamm
2008-07-30 19:02:13 +02:00
parent 7882f4858e
commit 5b5d7404b4
3 changed files with 15 additions and 7 deletions

View File

@@ -1009,12 +1009,12 @@ DValue* IndexExp::toElem(IRState* p)
}
else if (e1type->ty == Tsarray) {
if(global.params.useArrayBounds)
DtoArrayBoundsCheck(loc, l, r);
DtoArrayBoundsCheck(loc, l, r, false);
arrptr = DtoGEP(l->getRVal(), zero, r->getRVal());
}
else if (e1type->ty == Tarray) {
if(global.params.useArrayBounds)
DtoArrayBoundsCheck(loc, l, r);
DtoArrayBoundsCheck(loc, l, r, false);
arrptr = DtoArrayPtr(l);
arrptr = DtoGEP1(arrptr,r->getRVal());
}
@@ -1071,6 +1071,9 @@ DValue* SliceExp::toElem(IRState* p)
LLValue* vlo = lo->getRVal();
LLValue* vup = up->getRVal();
if(global.params.useArrayBounds && (etype->ty == Tsarray || etype->ty == Tarray))
DtoArrayBoundsCheck(loc, e, up, true);
// offset by lower
eptr = DtoGEP1(eptr, vlo);