@Override public void visitNew(SSANewInstruction instruction) { pointsToSet = OrdinalSet.empty(); }
@Override public void visitNew(SSANewInstruction instruction) { pointsToSet = OrdinalSet.empty(); }
@Override public OrdinalSet<InstanceKey> getPointsToSet(PointerKey key) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key == null"); } IClass type = inferType(key); if (type == null) { return OrdinalSet.empty(); } else { OrdinalSet<InstanceKey> result = pointsTo.get(type); if (result == null) { result = computeOrdinalInstanceSet(type); pointsTo.put(type, result); } return result; } }
@Override public OrdinalSet<InstanceKey> getPointsToSet(PointerKey key) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key == null"); } IClass type = inferType(key); if (type == null) { return OrdinalSet.empty(); } else { OrdinalSet<InstanceKey> result = pointsTo.get(type); if (result == null) { result = computeOrdinalInstanceSet(type); pointsTo.put(type, result); } return result; } }
/** * Computes the set of vertices that may reach {@code dest} along paths not containing an * {@link UnknownVertex}. */ public OrdinalSet<FuncVertex> getReachingSet(Vertex dest, IProgressMonitor monitor) throws CancelException { if(!graph.containsNode(dest)) return OrdinalSet.empty(); compute_optimistic_closure(monitor); return optimistic_closure.getReachableSet(dest); }
/** * Computes the set of vertices that may reach {@code dest} along paths not containing an * {@link UnknownVertex}. */ public OrdinalSet<FuncVertex> getReachingSet(Vertex dest, IProgressMonitor monitor) throws CancelException { if(!graph.containsNode(dest)) return OrdinalSet.empty(); compute_optimistic_closure(monitor); return optimistic_closure.getReachableSet(dest); }
/** * @return the set of interesting nodes reachable from n */ public OrdinalSet<S> getReachableSet(Object n) throws IllegalStateException { if (solver == null) { throw new IllegalStateException("must call solve() before calling getReachableSet()"); } BitVectorVariable v = solver.getOut(n); assert v != null : "null variable for node " + n; if (v.getValue() == null) { return OrdinalSet.empty(); } else { return new OrdinalSet<>(v.getValue(), domain); } }
/** * @return the set of interesting nodes reachable from n */ public OrdinalSet<S> getReachableSet(Object n) throws IllegalStateException { if (solver == null) { throw new IllegalStateException("must call solve() before calling getReachableSet()"); } BitVectorVariable v = solver.getOut(n); assert v != null : "null variable for node " + n; if (v.getValue() == null) { return OrdinalSet.empty(); } else { return new OrdinalSet<>(v.getValue(), domain); } }
/** * @return the set of interesting nodes reachable from n */ public OrdinalSet<S> getReachableSet(Object n) throws IllegalStateException { if (solver == null) { throw new IllegalStateException("must call solve() before calling getReachableSet()"); } BitVectorVariable v = solver.getOut(n); assert v != null : "null variable for node " + n; if (v.getValue() == null) { return OrdinalSet.empty(); } else { return new OrdinalSet<>(v.getValue(), domain); } }
/** * Creates the union of two ordinal sets. * * @param A ordinal set a * @param B ordinal set b * @return union of a and b * @throws IllegalArgumentException iff A or B is null */ public static <T> OrdinalSet<T> unify(OrdinalSet<T> A, OrdinalSet<T> B) { if (A == null) { throw new IllegalArgumentException("A is null"); } if (B == null) { throw new IllegalArgumentException("B is null"); } if (A.size() != 0 && B.size() != 0) { assert A.mapping.equals(B.mapping); } if (A.S == null) { return (B.S == null) ? OrdinalSet.<T> empty() : new OrdinalSet<>(B.S, B.mapping); } else if (B.S == null) { return new OrdinalSet<>(A.S, A.mapping); } IntSet union = A.S.union(B.S); return new OrdinalSet<>(union, A.mapping); }
/** * Creates the union of two ordinal sets. * * @param A ordinal set a * @param B ordinal set b * @return union of a and b * @throws IllegalArgumentException iff A or B is null */ public static <T> OrdinalSet<T> unify(OrdinalSet<T> A, OrdinalSet<T> B) { if (A == null) { throw new IllegalArgumentException("A is null"); } if (B == null) { throw new IllegalArgumentException("B is null"); } if (A.size() != 0 && B.size() != 0) { assert A.mapping.equals(B.mapping); } if (A.S == null) { return (B.S == null) ? OrdinalSet.<T> empty() : new OrdinalSet<>(B.S, B.mapping); } else if (B.S == null) { return new OrdinalSet<>(A.S, A.mapping); } IntSet union = A.S.union(B.S); return new OrdinalSet<>(union, A.mapping); }
/** * Creates the union of two ordinal sets. * * @param A ordinal set a * @param B ordinal set b * @return union of a and b * @throws IllegalArgumentException iff A or B is null */ public static <T> OrdinalSet<T> unify(OrdinalSet<T> A, OrdinalSet<T> B) { if (A == null) { throw new IllegalArgumentException("A is null"); } if (B == null) { throw new IllegalArgumentException("B is null"); } if (A.size() != 0 && B.size() != 0) { assert A.mapping.equals(B.mapping); } if (A.S == null) { return (B.S == null) ? OrdinalSet.<T> empty() : new OrdinalSet<>(B.S, B.mapping); } else if (B.S == null) { return new OrdinalSet<>(A.S, A.mapping); } IntSet union = A.S.union(B.S); return new OrdinalSet<>(union, A.mapping); }
@Override @SuppressWarnings("unchecked") public OrdinalSet<InstanceKey> getPointsToSet(PointerKey key) { if (pointsToMap.isImplicit(key)) { return computeImplicitPointsToSet(key); } // special logic to handle contents of char[] from string constants. if (key instanceof InstanceFieldKey) { InstanceFieldKey ifk = (InstanceFieldKey) key; if (ifk.getInstanceKey() instanceof ConstantKey) { ConstantKey<?> i = (ConstantKey<?>) ifk.getInstanceKey(); if (i.getValue() instanceof String && i.getConcreteType().getClassLoader().getLanguage().equals(Language.JAVA)) { StringConstantCharArray contents = StringConstantCharArray.make((ConstantKey<String>) i); instanceKeys.add(contents); Collection<InstanceKey> singleton = HashSetFactory.make(); singleton.add(contents); return OrdinalSet.toOrdinalSet(singleton, instanceKeys); } } } PointsToSetVariable v = pointsToMap.getPointsToSet(key); if (v == null) { return OrdinalSet.empty(); } else { IntSet S = v.getValue(); return new OrdinalSet<>(S, instanceKeys); } }
@Override @SuppressWarnings("unchecked") public OrdinalSet<InstanceKey> getPointsToSet(PointerKey key) { if (pointsToMap.isImplicit(key)) { return computeImplicitPointsToSet(key); } // special logic to handle contents of char[] from string constants. if (key instanceof InstanceFieldKey) { InstanceFieldKey ifk = (InstanceFieldKey) key; if (ifk.getInstanceKey() instanceof ConstantKey) { ConstantKey<?> i = (ConstantKey<?>) ifk.getInstanceKey(); if (i.getValue() instanceof String && i.getConcreteType().getClassLoader().getLanguage().equals(Language.JAVA)) { StringConstantCharArray contents = StringConstantCharArray.make((ConstantKey<String>) i); instanceKeys.add(contents); Collection<InstanceKey> singleton = HashSetFactory.make(); singleton.add(contents); return OrdinalSet.toOrdinalSet(singleton, instanceKeys); } } } PointsToSetVariable v = pointsToMap.getPointsToSet(key); if (v == null) { return OrdinalSet.empty(); } else { IntSet S = v.getValue(); return new OrdinalSet<>(S, instanceKeys); } }
public OrdinalSet<InstanceKey> computeImplicitPointsToSetAtGet(CGNode node, FieldReference field, int refVn, boolean isStatic) { IField f = getCallGraph().getClassHierarchy().resolveField(field); if (f == null) { return OrdinalSet.empty(); } if (isStatic) { PointerKey fKey = pointerKeys.getPointerKeyForStaticField(f); return getPointsToSet(fKey); } else { PointerKey ref = pointerKeys.getPointerKeyForLocal(node, refVn); MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); OrdinalSet<InstanceKey> refs = getPointsToSet(ref); for (InstanceKey ik : refs) { PointerKey fkey = pointerKeys.getPointerKeyForInstanceField(ik, f); if (fkey != null) { OrdinalSet pointees = getPointsToSet(fkey); IntSet set = pointees.getBackingSet(); if (set != null) { S.addAll(set); } } } return new OrdinalSet<>(S, instanceKeys); } }
public OrdinalSet<InstanceKey> computeImplicitPointsToSetAtGet(CGNode node, FieldReference field, int refVn, boolean isStatic) { IField f = getCallGraph().getClassHierarchy().resolveField(field); if (f == null) { return OrdinalSet.empty(); } if (isStatic) { PointerKey fKey = pointerKeys.getPointerKeyForStaticField(f); return getPointsToSet(fKey); } else { PointerKey ref = pointerKeys.getPointerKeyForLocal(node, refVn); MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); OrdinalSet<InstanceKey> refs = getPointsToSet(ref); for (InstanceKey ik : refs) { PointerKey fkey = pointerKeys.getPointerKeyForInstanceField(ik, f); if (fkey != null) { OrdinalSet pointees = getPointsToSet(fkey); IntSet set = pointees.getBackingSet(); if (set != null) { S.addAll(set); } } } return new OrdinalSet<>(S, instanceKeys); } }