Mercurial > projects > ldc
diff gen/toir.cpp @ 1166:c6f39553b702
Clean up some suspicious code.
There's no guarantee a constant of integer type is a ConstantInt, so it's not
safe to just cast<> these to ConstantInt. (It could be a constant expression,
for example)
The code is shorter this way too :).
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sun, 29 Mar 2009 03:27:04 +0200 |
parents | f528e55fb32f |
children | 7c7072437a89 83d3b25c2213 |
line wrap: on
line diff
--- a/gen/toir.cpp Sun Mar 29 01:29:30 2009 +0100 +++ b/gen/toir.cpp Sun Mar 29 03:27:04 2009 +0200 @@ -611,9 +611,8 @@ if (e1type != e2type) { if (e1type->ty == Tpointer) { Logger::println("add to pointer"); - if (r->isConst()) { - llvm::ConstantInt* cofs = llvm::cast<llvm::ConstantInt>(r->isConst()->c); - if (cofs->isZero()) { + if (DConstValue* cv = r->isConst()) { + if (cv->c->isNullValue()) { Logger::println("is zero"); return new DImValue(type, l->getRVal()); }