|
36 | 36 | import soot.Value;
|
37 | 37 | import soot.jimple.ArrayRef;
|
38 | 38 | import soot.jimple.AssignStmt;
|
| 39 | +import soot.jimple.BranchableStmt; |
39 | 40 | import soot.jimple.Constant;
|
40 | 41 | import soot.jimple.DoubleConstant;
|
41 | 42 | import soot.jimple.FloatConstant;
|
42 | 43 | import soot.jimple.IntConstant;
|
43 | 44 | import soot.jimple.LongConstant;
|
44 | 45 | import soot.jimple.NewArrayExpr;
|
| 46 | +import soot.jimple.Stmt; |
45 | 47 |
|
46 | 48 | /**
|
47 | 49 | * Detector class that identifies array initializations and packs them into a single instruction:
|
@@ -76,6 +78,12 @@ public void constructArrayInitializations(Body body) {
|
76 | 78 | Set<Unit> curIgnoreUnits = null;
|
77 | 79 | int arraySize = 0;
|
78 | 80 | Value concernedArray = null;
|
| 81 | + Set<Stmt> directGotoTargets = new HashSet<>(); |
| 82 | + for (Unit u : body.getUnits()) { |
| 83 | + if (u instanceof BranchableStmt) { |
| 84 | + directGotoTargets.add((Stmt) ((BranchableStmt) u).getTarget()); |
| 85 | + } |
| 86 | + } |
79 | 87 | for (Unit u : body.getUnits()) {
|
80 | 88 | if (!(u instanceof AssignStmt)) {
|
81 | 89 | arrayValues = null;
|
@@ -105,7 +113,7 @@ public void constructArrayInitializations(Body body) {
|
105 | 113 | if (rop instanceof IntConstant || rop instanceof LongConstant || rop instanceof FloatConstant
|
106 | 114 | || rop instanceof DoubleConstant) {
|
107 | 115 | ArrayRef aref = (ArrayRef) assignStmt.getLeftOp();
|
108 |
| - if (aref.getBase() != concernedArray) { |
| 116 | + if (aref.getBase() != concernedArray || directGotoTargets.contains(assignStmt)) { |
109 | 117 | arrayValues = null;
|
110 | 118 | continue;
|
111 | 119 | }
|
|
0 commit comments