Mercurial > projects > ldc
comparison gen/arrays.cpp @ 1271:0686701178d3
Moved special casing of 'assert(this, "null this");' generated statements from !ThisExp into !AssertExp.
Fixed filenames for array bounds errors and probably others, fixes #271 .
author | Tomas Lindquist Olsen <tomas.l.olsen gmail com> |
---|---|
date | Mon, 27 Apr 2009 13:30:48 +0200 |
parents | e45984519be7 |
children | ad41053c336e |
comparison
equal
deleted
inserted
replaced
1270:dd135ff697fa | 1271:0686701178d3 |
---|---|
976 | 976 |
977 ////////////////////////////////////////////////////////////////////////////////////////// | 977 ////////////////////////////////////////////////////////////////////////////////////////// |
978 void DtoArrayBoundsCheck(Loc& loc, DValue* arr, DValue* index, bool isslice) | 978 void DtoArrayBoundsCheck(Loc& loc, DValue* arr, DValue* index, bool isslice) |
979 { | 979 { |
980 Type* arrty = arr->getType()->toBasetype(); | 980 Type* arrty = arr->getType()->toBasetype(); |
981 assert((arrty->ty == Tsarray || arrty->ty == Tarray) && "Can only array bounds check for static or dynamic arrays"); | 981 assert((arrty->ty == Tsarray || arrty->ty == Tarray) && |
982 "Can only array bounds check for static or dynamic arrays"); | |
982 | 983 |
983 // static arrays could get static checks for static indices | 984 // static arrays could get static checks for static indices |
984 // but shouldn't since it might be generic code that's never executed | 985 // but shouldn't since it might be generic code that's never executed |
985 | 986 |
986 // runtime check | 987 // runtime check |
998 gIR->scope() = IRScope(failbb, okbb); | 999 gIR->scope() = IRScope(failbb, okbb); |
999 | 1000 |
1000 std::vector<LLValue*> args; | 1001 std::vector<LLValue*> args; |
1001 | 1002 |
1002 // file param | 1003 // file param |
1003 args.push_back(DtoLoad(gIR->dmodule->ir.irModule->fileName)); | 1004 // get the filename from the function symbol instead of the current module |
1005 // it's wrong for instantiations of imported templates. Fixes LDC bug #271 | |
1006 Module* funcmodule = gIR->func()->decl->getModule(); | |
1007 args.push_back(DtoLoad(getIrModule(NULL)->fileName)); | |
1004 | 1008 |
1005 // line param | 1009 // line param |
1006 LLConstant* c = DtoConstUint(loc.linnum); | 1010 LLConstant* c = DtoConstUint(loc.linnum); |
1007 args.push_back(c); | 1011 args.push_back(c); |
1008 | 1012 |