Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Changeset 1166:c6f39553b702

Show
Ignore:
Timestamp:
03/28/09 21:27:04 (3 years ago)
Author:
Frits van Bommel <fvbommel wxs.nl>
branch:
default
Message:

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 :).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gen/toir.cpp

    r1161 r1166  
    612612        if (e1type->ty == Tpointer) { 
    613613            Logger::println("add to pointer"); 
    614             if (r->isConst()) { 
    615                 llvm::ConstantInt* cofs = llvm::cast<llvm::ConstantInt>(r->isConst()->c); 
    616                 if (cofs->isZero()) { 
     614            if (DConstValue* cv = r->isConst()) { 
     615                if (cv->c->isNullValue()) { 
    617616                    Logger::println("is zero"); 
    618617                    return new DImValue(type, l->getRVal()); 
Copyright © 2008, LDC Development Team.