public static boolean maybeSameLocation(Value v1, Value v2) { if (!(v1 instanceof InstanceFieldRef && v2 instanceof InstanceFieldRef) && !(v1 instanceof ArrayRef && v2 instanceof ArrayRef)) { return v1.equivTo(v2); } if (v1 instanceof InstanceFieldRef && v2 instanceof InstanceFieldRef) { InstanceFieldRef ifr1 = (InstanceFieldRef) v1; InstanceFieldRef ifr2 = (InstanceFieldRef) v2; if (!ifr1.getField().getName().equals(ifr2.getField().getName())) return false; Local base1 = (Local) ifr1.getBase(); Local base2 = (Local) ifr2.getBase(); PointsToAnalysis pta = Scene.v().getPointsToAnalysis(); PointsToSet pts1 = pta.reachingObjects(base1); PointsToSet pts2 = pta.reachingObjects(base2); return pts1.hasNonEmptyIntersection(pts2); } else { // v1 instanceof ArrayRef && v2 instanceof ArrayRef ArrayRef ar1 = (ArrayRef) v1; ArrayRef ar2 = (ArrayRef) v2; Local base1 = (Local) ar1.getBase(); Local base2 = (Local) ar2.getBase(); PointsToAnalysis pta = Scene.v().getPointsToAnalysis(); PointsToSet pts1 = pta.reachingObjects(base1); PointsToSet pts2 = pta.reachingObjects(base2); return pts1.hasNonEmptyIntersection(pts2); } }
private int numMatchArgs(int numFormals, UnchangedParamsAnalysis mrpa, Stmt s) { FlowSet before = (FlowSet) mrpa.getFlowBefore(s); List args = ((InvokeExpr) s.getInvokeExpr()).getArgs(); int matchArg = 0; for (int i = 0; i < numFormals; i++) { Value arg = (Value) args.get(i); for (Iterator rppIt = before.iterator(); rppIt.hasNext(); ) { IDValuePair rpp = (IDValuePair) rppIt.next(); if (rpp.groupID == i && arg.equivTo(rpp.value)) { matchArg++; break; } } } return matchArg; }