Skip to content

Commit

Permalink
fix for the fix: Only propagate constants which are not null, otherwi…
Browse files Browse the repository at this point in the history
…se you get a null_type in the type hierarchy
  • Loading branch information
StevenArzt committed Jun 15, 2013
1 parent 66dee3a commit f6f3522
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/soot/jimple/toolkits/typing/fast/UseChecker.java
Expand Up @@ -254,7 +254,8 @@ else if ( rhs instanceof NegExpr )
((NegExpr)rhs).getOp(), tlhs, stmt));
}
else if ( rhs instanceof Constant )
stmt.setLeftOp(this.uv.visit(lhs, ((Constant) rhs).getType(), stmt));
if (!(rhs instanceof NullConstant))
stmt.setLeftOp(this.uv.visit(lhs, ((Constant) rhs).getType(), stmt));
}

public void caseIdentityStmt(IdentityStmt stmt) { }
Expand Down

2 comments on commit f6f3522

@quentin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a strange behavior with this piece of code (and probably the previous version).

The following Java code

Object[] arr = new Object[1];
arr[0] = "0"

Has the following Jimple code

java.lang.Object[] r1;
java.lang.Object r2;
java.lang.String r3;
r1 = newarray (java.lang.Object)[1];
r2 = r1[0];
r3 = (java.lang.String) r2;
r3 = "1";

I fixed my example by modifying line 258 into

stmt.setRightOp(this.uv.visit(rhs, tlhs, stmt));

However I'm not sure it is the right fix.

@StevenArzt
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix seems to be ok for me. I will push it to the "develop" branch. In fact, the wrong side got cast here. It makes much more sense to cast the constant than to cast the target of the assignment. Thank you for reporting that one!

Please sign in to comment.