# HG changeset patch # User Frits van Bommel # Date 1238290024 -7200 # Node ID c6f39553b7024f74ee7f39aa4455cf567ddcf124 # Parent 226c07c71967ce97067396c6df3b8fc442e1d416 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 :). diff -r 226c07c71967 -r c6f39553b702 gen/toir.cpp --- 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(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()); }