/** * This is slow. Fix it. */ public static <T> boolean isAcyclic(NumberedGraph<T> G, T root) { IBinaryNaturalRelation r = computeBackEdges(G, root); Iterator<IntPair> it = r.iterator(); return !it.hasNext(); }
/** * This is slow. Fix it. */ public static <T> boolean isAcyclic(NumberedGraph<T> G, T root) { IBinaryNaturalRelation r = computeBackEdges(G, root); Iterator<IntPair> it = r.iterator(); return !it.hasNext(); }
/** * This is slow. Fix it. */ public static <T> boolean isAcyclic(NumberedGraph<T> G, T root) { IBinaryNaturalRelation r = computeBackEdges(G, root); Iterator<IntPair> it = r.iterator(); return !it.hasNext(); }
/** * advance to the next operator */ private void advanceOuter() { innerDelegate = null; while (outerKeyDelegate.hasNext()) { currentOperator = outerKeyDelegate.next(); IBinaryNaturalRelation R = implicitUnaryMap.get(currentOperator); Iterator<IntPair> it = R.iterator(); if (it.hasNext()) { innerDelegate = it; return; } } }
/** * advance to the next operator */ private void advanceOuter() { innerDelegate = null; while (outerKeyDelegate.hasNext()) { currentOperator = outerKeyDelegate.next(); IBinaryNaturalRelation R = implicitUnaryMap.get(currentOperator); Iterator<IntPair> it = R.iterator(); if (it.hasNext()) { innerDelegate = it; return; } } }
public NullPointerFrameWork(ControlFlowGraph<SSAInstruction, T> cfg, IR ir) { final IBinaryNaturalRelation backEdges = Acyclic.computeBackEdges(cfg, cfg.entry()); boolean hasBackEdge = backEdges.iterator().hasNext(); if (hasBackEdge) { MutableCFG<SSAInstruction, T> cfg2 = MutableCFG.copyFrom(cfg); for (IntPair edge : backEdges) { T from = cfg2.getNode(edge.getX()); T to = cfg2.getNode(edge.getY()); cfg2.removeEdge(from, to); cfg2.addEdge(from, cfg.exit()); } this.flow = cfg2; } else { this.flow = cfg; } this.transferFunct = new NullPointerTransferFunctionProvider<>(cfg, ir); }
public NullPointerFrameWork(ControlFlowGraph<SSAInstruction, T> cfg, IR ir) { final IBinaryNaturalRelation backEdges = Acyclic.computeBackEdges(cfg, cfg.entry()); boolean hasBackEdge = backEdges.iterator().hasNext(); if (hasBackEdge) { MutableCFG<SSAInstruction, T> cfg2 = MutableCFG.copyFrom(cfg); for (IntPair edge : backEdges) { T from = cfg2.getNode(edge.getX()); T to = cfg2.getNode(edge.getY()); cfg2.removeEdge(from, to); cfg2.addEdge(from, cfg.exit()); } this.flow = cfg2; } else { this.flow = cfg; } this.transferFunct = new NullPointerTransferFunctionProvider<>(cfg, ir); }
@Test public void testNList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS); ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, "Lrecurse/NList"); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraph cg = CallGraphTestUtil.buildZeroCFA(options, new AnalysisCacheImpl(), cha, scope, false); IBinaryNaturalRelation backEdges = Acyclic.computeBackEdges(cg, cg.getFakeRootNode()); Assert.assertTrue("NList should have cycles", backEdges.iterator().hasNext()); Map<CGNode, Set<CGNode>> cgBackEdges = HashMapFactory.make(); for (IntPair p : backEdges) { CGNode src = cg.getNode(p.getX()); if (!cgBackEdges.containsKey(src)) { cgBackEdges.put(src, HashSetFactory.<CGNode>make()); } cgBackEdges.get(src).add(cg.getNode(p.getY())); } PrunedCallGraph pcg = new PrunedCallGraph(cg, Iterator2Collection.toSet(cg.iterator()), cgBackEdges); Assert.assertTrue("cycles should be gone", !Acyclic.computeBackEdges(pcg, pcg.getFakeRootNode()).iterator().hasNext()); }