private void checkNormalSuccessors(SSACFG cfg, PrunedCFG<SSAInstruction, ISSABasicBlock> prunedCfg, ISSABasicBlock block) { LinkedHashSet<ISSABasicBlock> normalSuccessorCfg = new LinkedHashSet<>(cfg.getNormalSuccessors(block)); LinkedHashSet<ISSABasicBlock> normalSuccessorPruned = new LinkedHashSet<>(prunedCfg.getNormalSuccessors(block)); collector.checkThat("", normalSuccessorPruned, equalTo(normalSuccessorCfg)); }
@Override public boolean hasNormalEdge(ISSABasicBlock src, ISSABasicBlock dst) { boolean originalEdge = node.getIR().getControlFlowGraph().getNormalSuccessors(src).contains(dst); boolean result = originalEdge; SSAInstruction instruction = IntraproceduralExceptionAnalysis.getThrowingInstruction(src); if (instruction != null) { if (analysis.getFilter().getFilter(node).alwaysThrowsException(instruction)) { result = false; } } return result; }
@Override public boolean hasNormalEdge(ISSABasicBlock src, ISSABasicBlock dst) { boolean originalEdge = node.getIR().getControlFlowGraph().getNormalSuccessors(src).contains(dst); boolean result = originalEdge; SSAInstruction instruction = IntraproceduralExceptionAnalysis.getThrowingInstruction(src); if (instruction != null) { if (analysis.getFilter().getFilter(node).alwaysThrowsException(instruction)) { result = false; } } return result; }
@Override public Collection<IExplodedBasicBlock> getNormalSuccessors(IExplodedBasicBlock bb) { ExplodedBasicBlock eb = (ExplodedBasicBlock) bb; assert eb != null; if (eb.equals(exit)) { return Collections.emptySet(); } if (eb.isEntryBlock()) { return Collections.singleton(normalNodes.get(0)); } if (eb.instructionIndex == eb.original.getLastInstructionIndex()) { List<IExplodedBasicBlock> result = new ArrayList<>(); for (ISSABasicBlock s : ir.getControlFlowGraph().getNormalSuccessors(eb.original)) { if (s.equals(ir.getControlFlowGraph().exit())) { result.add(exit()); } else { assert normalNodes.get(s.getFirstInstructionIndex()) != null; result.add(normalNodes.get(s.getFirstInstructionIndex())); } } return result; } else { assert normalNodes.get(eb.instructionIndex + 1) != null; return Collections.singleton(normalNodes.get(eb.instructionIndex + 1)); } }
@Override public Collection<IExplodedBasicBlock> getNormalSuccessors(IExplodedBasicBlock bb) { ExplodedBasicBlock eb = (ExplodedBasicBlock) bb; assert eb != null; if (eb.equals(exit)) { return Collections.emptySet(); } if (eb.isEntryBlock()) { return Collections.singleton(normalNodes.get(0)); } if (eb.instructionIndex == eb.original.getLastInstructionIndex()) { List<IExplodedBasicBlock> result = new ArrayList<>(); for (ISSABasicBlock s : ir.getControlFlowGraph().getNormalSuccessors(eb.original)) { if (s.equals(ir.getControlFlowGraph().exit())) { result.add(exit()); } else { assert normalNodes.get(s.getFirstInstructionIndex()) != null; result.add(normalNodes.get(s.getFirstInstructionIndex())); } } return result; } else { assert normalNodes.get(eb.instructionIndex + 1) != null; return Collections.singleton(normalNodes.get(eb.instructionIndex + 1)); } }