mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-13 11:23:14 +01:00
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:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user