Skip to content

Commit

Permalink
Merge pull request #2114 from MarcMil/fixes
Browse files Browse the repository at this point in the history
Fix for null_types
  • Loading branch information
StevenArzt authored Oct 21, 2024
2 parents 32634a6 + 9560b30 commit 20c6ed8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
25 changes: 16 additions & 9 deletions src/main/java/soot/jimple/toolkits/typing/fast/TypeResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import soot.IntegerType;
import soot.Local;
import soot.LocalGenerator;
import soot.NullType;
import soot.PatchingChain;
import soot.PrimType;
import soot.RefType;
Expand All @@ -64,6 +65,7 @@
import soot.jimple.JimpleBody;
import soot.jimple.NegExpr;
import soot.jimple.NewExpr;
import soot.jimple.NullConstant;
import soot.jimple.SpecialInvokeExpr;
import soot.jimple.Stmt;
import soot.jimple.toolkits.typing.Util;
Expand Down Expand Up @@ -175,7 +177,7 @@ private void addDepend(Local v, int stmtIndex) {

public void inferTypes() {
this.split_new();
//split_new creates new assignments...
// split_new creates new assignments...
this.initAssignments();
ITypingStrategy typingStrategy = getTypingStrategy();
AugEvalFunction ef = createAugEvalFunction(this.jb);
Expand Down Expand Up @@ -250,10 +252,10 @@ public Value visit(Value op, Type useType, Stmt stmt, boolean checkOnly) {
if (useType == t) {
if (op instanceof CastExpr) {
CastExpr ce = (CastExpr) op;
//by default, t only checks for the type of the cast target
// by default, t only checks for the type of the cast target
t = AugEvalFunction.eval_(this.tg, ce.getOp(), stmt, this.jb);
if (ce.getType() == t) {
//no cast necessary!
// no cast necessary!
return ce.getOp();
}
}
Expand Down Expand Up @@ -552,7 +554,7 @@ protected Collection<Typing> applyAssignmentConstraints(Typing tg, IEvalFunction

if (tg.map.isEmpty()) {
simple = new BitSet(numAssignments);
//First get the easy cases out of the way.
// First get the easy cases out of the way.
for (int i = 0; i < numAssignments; i++) {
final DefinitionStmt stmt = this.assignments.get(i);
Value lhs = stmt.getLeftOp();
Expand All @@ -562,11 +564,16 @@ protected Collection<Typing> applyAssignmentConstraints(Typing tg, IEvalFunction
Collection<Type> d = ef.eval(tg, stmt.getRightOp(), stmt);
if (d.size() == 1) {
Type t_ = d.iterator().next();
d = reduceToAllowedTypesForLocal(Collections.singleton(t_), v);
if (d.size() == 1) {
tg.set(v, d.iterator().next());
simple.set(i);
wl.clear(i);
if (stmt.getRightOp() instanceof NullConstant) {
t_ = NullType.v();
}
if (t_.isAllowedInFinalCode() || t_ instanceof NullType) {
d = reduceToAllowedTypesForLocal(Collections.singleton(t_), v);
if (d.size() == 1) {
tg.set(v, d.iterator().next());
simple.set(i);
wl.clear(i);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/soot/jimple/toolkits/typing/fast/Typing.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Type get(Local v) {
}

public Type set(Local v, Type t) {
return (t instanceof BottomType || t instanceof NullType) ? null : this.map.put(v, t);
return (t instanceof BottomType) ? null : this.map.put(v, t);
}

public Collection<Local> getAllLocals() {
Expand Down

0 comments on commit 20c6ed8

Please sign in to comment.