nodeQueue.remove(node); if (!node.isEntryBlock() && !node.isExitBlock()) { // entry and exit are dummy basic blocks LOG(DEBUG, "DEBUG", ">> bb: " + node.getNumber());
@Override public boolean isExitBlock() { return delegate.isExitBlock(); }
@Override public boolean isExitBlock() { return delegate.isExitBlock(); }
/** * @return true iff there's a unique catch block which catches all exceptions thrown by a certain call site. */ protected static boolean hasUniqueCatchBlock(SSAAbstractInvokeInstruction call, IRView ir) { ISSABasicBlock[] bb = ir.getBasicBlocksForCall(call.getCallSite()); if (bb.length == 1) { Iterator<ISSABasicBlock> it = ir.getControlFlowGraph().getExceptionalSuccessors(bb[0]).iterator(); // check that there's exactly one element in the iterator if (it.hasNext()) { ISSABasicBlock sb = it.next(); return (!it.hasNext() && (sb.isExitBlock() || ((sb instanceof ExceptionHandlerBasicBlock) && ((ExceptionHandlerBasicBlock)sb).getCatchInstruction() != null))); } } return false; }
/** * @return true iff there's a unique catch block which catches all exceptions thrown by a certain call site. */ protected static boolean hasUniqueCatchBlock(SSAAbstractInvokeInstruction call, IRView ir) { ISSABasicBlock[] bb = ir.getBasicBlocksForCall(call.getCallSite()); if (bb.length == 1) { Iterator<ISSABasicBlock> it = ir.getControlFlowGraph().getExceptionalSuccessors(bb[0]).iterator(); // check that there's exactly one element in the iterator if (it.hasNext()) { ISSABasicBlock sb = it.next(); return (!it.hasNext() && (sb.isExitBlock() || ((sb instanceof ExceptionHandlerBasicBlock) && ((ExceptionHandlerBasicBlock)sb).getCatchInstruction() != null))); } } return false; }
private static <T extends ISSABasicBlock> List<T> searchNodesWithPathToCatchAll(ControlFlowGraph<SSAInstruction, T> cfg) { final List<T> nodes = new LinkedList<>(); for (final T exp : cfg) { final List<T> excSucc = cfg.getExceptionalSuccessors(exp); if (excSucc != null && excSucc.size() > 1) { boolean foundExit = false; boolean foundCatchAll = false; for (final T succ : excSucc) { if (succ.isExitBlock()) { foundExit = true; } else if (succ.isCatchBlock()) { final Iterator<TypeReference> caught = succ.getCaughtExceptionTypes(); while (caught.hasNext()) { final TypeReference t = caught.next(); if (t.equals(TypeReference.JavaLangException) || t.equals(TypeReference.JavaLangThrowable)) { foundCatchAll = true; } } } } if (foundExit && foundCatchAll) { nodes.add(exp); } } } return nodes; }
private static <T extends ISSABasicBlock> List<T> searchNodesWithPathToCatchAll(ControlFlowGraph<SSAInstruction, T> cfg) { final List<T> nodes = new LinkedList<>(); for (final T exp : cfg) { final List<T> excSucc = cfg.getExceptionalSuccessors(exp); if (excSucc != null && excSucc.size() > 1) { boolean foundExit = false; boolean foundCatchAll = false; for (final T succ : excSucc) { if (succ.isExitBlock()) { foundExit = true; } else if (succ.isCatchBlock()) { final Iterator<TypeReference> caught = succ.getCaughtExceptionTypes(); while (caught.hasNext()) { final TypeReference t = caught.next(); if (t.equals(TypeReference.JavaLangException) || t.equals(TypeReference.JavaLangThrowable)) { foundCatchAll = true; } } } } if (foundExit && foundCatchAll) { nodes.add(exp); } } } return nodes; }
@Override public boolean hasExceptionalEdge(ISSABasicBlock src, ISSABasicBlock dst) { boolean originalEdge = node.getIR().getControlFlowGraph().getExceptionalSuccessors(src).contains(dst); boolean result = originalEdge; if (dst.isCatchBlock()) { if (!analysis.catchesException(node, src, dst)) { result = false; } } else { assert dst.isExitBlock(); result = analysis.hasUncaughtExceptions(node, src); } return result; }
@Override public boolean hasExceptionalEdge(ISSABasicBlock src, ISSABasicBlock dst) { boolean originalEdge = node.getIR().getControlFlowGraph().getExceptionalSuccessors(src).contains(dst); boolean result = originalEdge; if (dst.isCatchBlock()) { if (!analysis.catchesException(node, src, dst)) { result = false; } } else { assert dst.isExitBlock(); result = analysis.hasUncaughtExceptions(node, src); } return result; }
/** * add enough nodes and edges to the graph to allow for computing successors of N */ private void initForSucc(BasicBlockInContext<T> N) { CGNode node = getCGNode(N); addIntraproceduralNodesAndEdgesForCGNodeIfNeeded(node); int num = g.getNumber(N); if (!addedSuccs.contains(num)) { addedSuccs.add(num); if (N.getDelegate().isExitBlock()) { addCallerEdges(node); } if (hasCall(N)) { addCalleeEdgesForCall(node, N); } } }
/** * add enough nodes and edges to the graph to allow for computing successors of N */ private void initForSucc(BasicBlockInContext<T> N) { CGNode node = getCGNode(N); addIntraproceduralNodesAndEdgesForCGNodeIfNeeded(node); int num = g.getNumber(N); if (!addedSuccs.contains(num)) { addedSuccs.add(num); if (N.getDelegate().isExitBlock()) { addCallerEdges(node); } if (hasCall(N)) { addCalleeEdgesForCall(node, N); } } }
if (sb.isExitBlock()) {
if (sb.isExitBlock()) {
if (!addedSuccs.contains(getNumber(src))) { if (!src.getNode().equals(dst.getNode())) { if (src.getDelegate().isExitBlock()) {
if (!addedSuccs.contains(getNumber(src))) { if (!src.getNode().equals(dst.getNode())) { if (src.getDelegate().isExitBlock()) {
if (!b2.isExitBlock()) { g.addEdge(b, b2);
if (!b2.isExitBlock()) { g.addEdge(b, b2);
controlFlowGraph); for (ISSABasicBlock bb : cdg) { if (bb.isExitBlock()) {