Fixed assertion fault, in case of multidimensional arrays.
This commit is contained in:
parent
dfaa44d111
commit
3acd97ebfb
|
@ -164,4 +164,12 @@ public class NotDetectable {
|
|||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multidimensional Arrays are not supported yet.
|
||||
*/
|
||||
public int multiDimensional(){
|
||||
int arr[][] = new int[5][10];
|
||||
return arr[2][3];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ArrayboundsAnalysisTest {
|
|||
private static final int DETECTABLE_NUMBER_OF_ARRAY_ACCESS = 34;
|
||||
|
||||
private static final String NOT_DETECTABLE_TESTDATA = "Larraybounds/NotDetectable";
|
||||
private static final int NOT_DETECTABLE_NUMBER_OF_ARRAY_ACCESS = 8;
|
||||
private static final int NOT_DETECTABLE_NUMBER_OF_ARRAY_ACCESS = 10;
|
||||
|
||||
private static final String NOT_IN_BOUND_TESTDATA = "Larraybounds/NotInBound";
|
||||
private static final int NOT_IN_BOUND_TESTDATA_NUMBER_OF_ARRAY_ACCESS = 8;
|
||||
|
|
|
@ -87,19 +87,21 @@ public class ArrayBoundsGraphBuilder {
|
|||
instruction.visit(new Visitor() {
|
||||
@Override
|
||||
public void visitNew(SSANewInstruction instruction) {
|
||||
assert instruction.getNumberOfUses() == 1;
|
||||
final int constructionLength = instruction.getUse(0);
|
||||
Integer arraysNode = ArrayBoundsGraphBuilder.this.lowerBoundGraph
|
||||
.getArrayLength().get(tmp);
|
||||
ArrayBoundsGraphBuilder.this.lowerBoundGraph.addEdge(
|
||||
arraysNode, constructionLength);
|
||||
arraysNode = ArrayBoundsGraphBuilder.this.upperBoundGraph
|
||||
.getArrayLength().get(tmp);
|
||||
ArrayBoundsGraphBuilder.this.upperBoundGraph.addEdge(
|
||||
arraysNode, constructionLength);
|
||||
|
||||
ArrayBoundsGraphBuilder.this
|
||||
.addPossibleConstant(constructionLength);
|
||||
//We only support arrays with dimension 1
|
||||
if (instruction.getNumberOfUses() == 1) {
|
||||
final int constructionLength = instruction.getUse(0);
|
||||
Integer arraysNode = ArrayBoundsGraphBuilder.this.lowerBoundGraph
|
||||
.getArrayLength().get(tmp);
|
||||
ArrayBoundsGraphBuilder.this.lowerBoundGraph.addEdge(
|
||||
arraysNode, constructionLength);
|
||||
arraysNode = ArrayBoundsGraphBuilder.this.upperBoundGraph
|
||||
.getArrayLength().get(tmp);
|
||||
ArrayBoundsGraphBuilder.this.upperBoundGraph.addEdge(
|
||||
arraysNode, constructionLength);
|
||||
|
||||
ArrayBoundsGraphBuilder.this
|
||||
.addPossibleConstant(constructionLength);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue