mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
StandardInstructionVisitor: kill instruction state on ArrayIndexOutOfBounds
This commit is contained in:
@@ -166,6 +166,9 @@ public class StandardInstructionVisitor extends InstructionVisitor {
|
||||
}
|
||||
}
|
||||
processArrayAccess(arrayExpression, alwaysOutOfBounds);
|
||||
if (alwaysOutOfBounds) {
|
||||
return DfaInstructionState.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
DfaValue result = instruction.getValue();
|
||||
LongRangeSet rangeSet = memState.getValueFact(index, DfaFactType.RANGE);
|
||||
|
||||
@@ -3,7 +3,7 @@ class Test {
|
||||
if (params == null) {
|
||||
params = <flown1112>new int[]{<flown11121>-1};
|
||||
}
|
||||
params[3] = <flown1113>44;
|
||||
params[0] = <flown1113>44;
|
||||
for (int <flown11>param : <flown111>params) y(<flown1>param);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,9 @@ class Auto {
|
||||
{
|
||||
Integer i = null;
|
||||
int[] ia = new int[0];
|
||||
int i2 = ia[<warning descr="Array index is out of bounds"><warning descr="Unboxing of 'i' may produce 'NullPointerException'">i</warning></warning>];
|
||||
if (Math.random() > 0.5) {
|
||||
int i2 = ia[<warning descr="Array index is out of bounds"><warning descr="Unboxing of 'i' may produce 'NullPointerException'">i</warning></warning>];
|
||||
}
|
||||
}
|
||||
{
|
||||
Integer i = null;
|
||||
|
||||
@@ -56,7 +56,9 @@ class ArrayInitializerLength {
|
||||
|
||||
void test2DArray() {
|
||||
int[][] md = {{1, 2, 3}, {3, 4}};
|
||||
int elem = md[1][<warning descr="Array index is out of bounds">2</warning>];
|
||||
if(Math.random() > 0.5) {
|
||||
int elem = md[1][<warning descr="Array index is out of bounds">2</warning>];
|
||||
}
|
||||
int[] subArray = md[0];
|
||||
if (<warning descr="Condition 'subArray.length == 3' is always 'true'">subArray.length == 3</warning>) {
|
||||
System.out.println("Always");
|
||||
|
||||
@@ -52,8 +52,12 @@ public final class ArrayLength {
|
||||
}
|
||||
|
||||
public static void testArray(int[] x, int a) {
|
||||
x[<warning descr="Array index is out of bounds">-1</warning>] = -2;
|
||||
x[<warning descr="Array index is out of bounds">x.length</warning>] = -1;
|
||||
if(Math.random() > 0.5) {
|
||||
x[<warning descr="Array index is out of bounds">-1</warning>] = -2;
|
||||
}
|
||||
if(Math.random() > 0.5) {
|
||||
x[<warning descr="Array index is out of bounds">x.length</warning>] = -1;
|
||||
}
|
||||
x[a] = 6;
|
||||
if(<warning descr="Condition 'a < 0' is always 'false'">a < 0</warning>) {
|
||||
System.out.println("never");
|
||||
|
||||
@@ -11,7 +11,7 @@ class Test {
|
||||
}
|
||||
|
||||
void test(Integer x, String[] data) {
|
||||
if(x < 0 && data[<warning descr="Array index is out of bounds">x</warning>].isEmpty()) {}
|
||||
if(<warning descr="Condition 'x < 0 && data[x].isEmpty()' is always 'false'">x < 0 && data[<warning descr="Array index is out of bounds">x</warning>].isEmpty()</warning>) {}
|
||||
}
|
||||
|
||||
void testRangeOutOfThinAir(int x) {
|
||||
|
||||
Reference in New Issue
Block a user