Mercurial > projects > ldc
changeset 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 | 226c07c71967 |
children | ed4b050ada45 |
files | gen/toir.cpp |
diffstat | 1 files changed, 2 insertions(+), 3 deletions(-) [+] |
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()); }