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 :).
This commit is contained in:
Frits van Bommel
2009-03-29 03:27:04 +02:00
parent 2586278349
commit 7e99e31b91

View File

@@ -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<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());
}