From 7e99e31b9182f0da5b8dabd55fda96afb4c232c8 Mon Sep 17 00:00:00 2001 From: Frits van Bommel Date: Sun, 29 Mar 2009 03:27:04 +0200 Subject: [PATCH] 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 :). --- gen/toir.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gen/toir.cpp b/gen/toir.cpp index 5cd18f4f..80554be7 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -611,9 +611,8 @@ DValue* AddExp::toElem(IRState* p) 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()); }