Skip to content

Commit

Permalink
fix value replacement in aggregation via a hacky "ValueBox.canContain…
Browse files Browse the repository at this point in the history
…Value"
  • Loading branch information
swissiety committed Nov 6, 2023
1 parent 6a94685 commit 7b5dc03
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Set;
import javax.annotation.Nonnull;
import sootup.core.graph.MutableStmtGraph;
import sootup.core.jimple.basic.Immediate;
import sootup.core.jimple.basic.LValue;
import sootup.core.jimple.basic.Local;
import sootup.core.jimple.basic.Value;
Expand Down Expand Up @@ -190,12 +189,19 @@ public void interceptBody(@Nonnull Body.BodyBuilder builder, @Nonnull View<?> vi
}

Value aggregatee = ((AbstractDefinitionStmt) relevantDef).getRightOp();
Stmt newStmt = null;
if (aggregatee instanceof Immediate) {
final ReplaceUseStmtVisitor replaceVisitor = new ReplaceUseStmtVisitor(val, aggregatee);
Stmt newStmt;

final ReplaceUseStmtVisitor replaceVisitor = new ReplaceUseStmtVisitor(val, aggregatee);
// FIXME: this try-catch is an awful hack for "ValueBox.canContainValue" -> try to determine
// a replaceability earlier!
try {
replaceVisitor.caseAssignStmt(assignStmt);
newStmt = replaceVisitor.getResult();
} catch (ClassCastException iae) {
newStmt = null;
}

if (newStmt != null) {
graph.replaceNode(stmt, newStmt);
if (graph.getStartingStmt() == relevantDef) {
Stmt newStartingStmt = builder.getStmtGraph().successors(relevantDef).get(0);
Expand Down

0 comments on commit 7b5dc03

Please sign in to comment.