DFA: do not flush array length on element write

This commit is contained in:
Tagir Valeev
2017-11-28 12:57:45 +07:00
parent e6ada0322c
commit 58bd65acee
2 changed files with 20 additions and 1 deletions
@@ -139,7 +139,9 @@ public abstract class InstructionVisitor {
if (variable != null) {
if (instruction.isDependentsOnly()) {
for (DfaVariableValue qualified : runner.getFactory().getVarFactory().getAllQualifiedBy(variable)) {
memState.flushVariable(qualified);
if (qualified.isFlushableByCalls()) {
memState.flushVariable(qualified);
}
}
}
else {
@@ -1,6 +1,23 @@
import java.util.Arrays;
public final class ArrayLength {
void testEquality(int[] x) {
int len = x.length;
for(int i=0; i<100; i++) {
if (i == len) {
x[<warning descr="Array index is out of bounds">i</warning>] = 10;
}
}
}
int[] testFor(int length) {
int[] x = new int[length];
for(int i=0; i<=length; i++) {
x[i] = 1;
}
return x;
}
public static void testArray2(Object[] x, Object[] y, int a) {
if(<warning descr="Condition 'x[a] == null && a == x.length' is always 'false'">x[a] == null && <warning descr="Condition 'a == x.length' is always 'false' when reached">a == x.length</warning></warning>) {
System.out.println("Impossible");