ReturnNode rn, CompositeLocation constraint) {
ExpressionNode returnExp = rn.getReturnExpression();
+
+ CompositeLocation declaredReturnLoc = md2ReturnLoc.get(md);
+
CompositeLocation returnValueLoc;
if (returnExp != null) {
returnValueLoc =
// generateErrorMessage(md.getClassDesc(), rn));
// }
+ if (constraint != null) {
+
+ // Set<CompositeLocation> inputGLB = new HashSet<CompositeLocation>();
+ // inputGLB.add(returnValueLoc);
+ // inputGLB.add(constraint);
+ // returnValueLoc =
+ // CompositeLattice.calculateGLB(inputGLB,
+ // generateErrorMessage(md.getClassDesc(), rn));
+
+ // if (!returnValueLoc.get(returnValueLoc.getSize() - 1).isTop()) {
+ // if (!CompositeLattice.isGreaterThan(constraint, returnValueLoc,
+ // generateErrorMessage(md.getClassDesc(), rn))) {
+ // System.out.println("returnValueLoc.get(returnValueLoc.getSize() - 1).isTop()="
+ // + returnValueLoc.get(returnValueLoc.getSize() - 1).isTop());
+ // throw new Error("The value flow from " + constraint + " to " +
+ // returnValueLoc
+ // + " does not respect location hierarchy on the assignment " +
+ // rn.printNode(0)
+ // + " at " + md.getClassDesc().getSourceFileName() + "::" +
+ // rn.getNumLine());
+ // }
+ // }
+
+ if (!CompositeLattice.isGreaterThan(constraint, declaredReturnLoc,
+ generateErrorMessage(md.getClassDesc(), rn))) {
+ throw new Error("The value flow from " + constraint + " to " + declaredReturnLoc
+ + " does not respect location hierarchy on the assignment " + rn.printNode(0)
+ + " at " + md.getClassDesc().getSourceFileName() + "::" + rn.getNumLine());
+ }
+
+ }
+
// check if return value is equal or higher than RETRUNLOC of method
// declaration annotation
- CompositeLocation declaredReturnLoc = md2ReturnLoc.get(md);
int compareResult =
CompositeLattice.compare(returnValueLoc, declaredReturnLoc, false,
List<CompositeLocation> argList = new ArrayList<CompositeLocation>();
// by default, method has a THIS parameter
- if (!md.isStatic()) {
+ if (!min.getMethod().isStatic()) {
argList.add(baseLocation);
}
argList.add(callerArg);
}
- // System.out.println("\n## computeReturnLocation=" + min.getMethod() +
- // " argList=" + argList);
+ System.out.println("\n## computeReturnLocation=" + min.getMethod() + " argList=" + argList);
CompositeLocation ceilLoc = md2ReturnLocGen.get(min.getMethod()).computeReturnLocation(argList);
- // System.out.println("## ReturnLocation=" + ceilLoc);
+ System.out.println("## ReturnLocation=" + ceilLoc);
return ceilLoc;
MethodLattice<String> calleeLattice = ssjava.getMethodLattice(calleemd);
+ System.out.println("checkCalleeConstraints=" + calleemd + " calleeLattice.getThisLoc()="
+ + calleeLattice.getThisLoc());
+
CompositeLocation calleeThisLoc =
new CompositeLocation(new Location(calleemd, calleeLattice.getThisLoc()));
private CompositeLocation checkLocationFromArrayAccessNode(MethodDescriptor md,
SymbolTable nametable, ArrayAccessNode aan, CompositeLocation constraint, boolean isLHS) {
-
+ System.out.println("aan=" + aan.printNode(0) + " line#=" + aan.getNumLine());
ClassDescriptor cd = md.getClassDesc();
CompositeLocation arrayLoc =
// generateErrorMessage(cd, an));
}
+ System.out.println("src=" + srcLocation + " dest=" + destLocation + " const=" + constraint);
+
if (!CompositeLattice.isGreaterThan(srcLocation, destLocation, generateErrorMessage(cd, an))) {
String context = "";
public static CompositeLocation calculateGLB(Set<CompositeLocation> inputSet, String errMsg) {
- // System.out.println("Calculating GLB=" + inputSet);
+ System.out.println("Calculating GLB=" + inputSet);
CompositeLocation glbCompLoc = new CompositeLocation();
// calculate GLB of the first(priority) element