Class PrunedCFG<I, T extends IBasicBlock<I>>
java.lang.Object
com.ibm.wala.util.graph.AbstractGraph<T>
com.ibm.wala.util.graph.AbstractNumberedGraph<T>
com.ibm.wala.ipa.cfg.PrunedCFG<I,T>
- All Implemented Interfaces:
ControlFlowGraph<I,T>, MinimalCFG<T>, EdgeManager<T>, Graph<T>, NodeManager<T>, NumberedEdgeManager<T>, NumberedGraph<T>, NumberedNodeManager<T>, Iterable<T>
public class PrunedCFG<I, T extends IBasicBlock<I>>
extends AbstractNumberedGraph<T>
implements ControlFlowGraph<I,T>
A pruned view of a
ControlFlowGraph. Use this class along with an EdgeFilter to
produce a custom view of a CFG.
For example, you can use this class to produce a CFG view that ignores certain types of exceptional edges.
-
Method Summary
Modifier and TypeMethodDescriptionentry()Return the entry basic block in the CFGexit()getBlockForInstruction(int index) protected NumberedEdgeManager<T> The order of blocks returned should be arbitrary but deterministic.The order of blocks returned must indicate the exception-handling scope.I[]protected NumberedNodeManager<T> The order of blocks returned should be arbitrary but deterministic.The order of blocks returned should be arbitrary but deterministic.getPhiIndices(T bb) intgetProgramCounter(int index) TODO: move this into IR?static <I, T extends IBasicBlock<I>>
PrunedCFG<I, T> make(ControlFlowGraph<I, T> cfg, EdgeFilter<T> filter) Methods inherited from class AbstractNumberedGraph
getMaxNumber, getNode, getNumber, getPredNodeNumbers, getSuccNodeNumbers, iterateNodesMethods inherited from class AbstractGraph
addEdge, addNode, containsNode, edgeString, getNumberOfNodes, getPredNodeCount, getPredNodes, getSuccNodeCount, getSuccNodes, hasEdge, iterator, nodeString, removeAllIncidentEdges, removeEdge, removeIncomingEdges, removeNode, removeNodeAndEdges, removeOutgoingEdges, stream, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface EdgeManager
addEdge, getPredNodeCount, getPredNodes, getSuccNodeCount, getSuccNodes, hasEdge, removeAllIncidentEdges, removeEdge, removeIncomingEdges, removeOutgoingEdgesMethods inherited from interface Graph
removeNodeAndEdgesMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface NodeManager
addNode, containsNode, getNumberOfNodes, iterator, removeNode, streamMethods inherited from interface NumberedEdgeManager
getPredNodeNumbers, getSuccNodeNumbersMethods inherited from interface NumberedNodeManager
getMaxNumber, getNode, getNumber, iterateNodes
-
Method Details
-
make
public static <I, T extends IBasicBlock<I>> PrunedCFG<I,T> make(ControlFlowGraph<I, T> cfg, EdgeFilter<T> filter) - Parameters:
cfg- the original CFG that you want a view offilter- an object that selectively filters edges in the original CFG- Returns:
- a view of cfg that includes only edges accepted by the filter.
- Throws:
IllegalArgumentException- if cfg is null
-
getNodeManager
- Specified by:
getNodeManagerin classAbstractNumberedGraph<T extends IBasicBlock<I>>- Returns:
- the object which manages nodes in the graph
-
getEdgeManager
- Specified by:
getEdgeManagerin classAbstractNumberedGraph<T extends IBasicBlock<I>>- Returns:
- the object which manages edges in the graph
-
getExceptionalSuccessors
Description copied from interface:MinimalCFGThe order of blocks returned must indicate the exception-handling scope. So the first block is the first candidate catch block, and so on. With this invariant one can compute the exceptional control flow for a given exception type.- Specified by:
getExceptionalSuccessorsin interfaceMinimalCFG<I>- Returns:
- the basic blocks which may be reached from b via exceptional control flow
-
getNormalSuccessors
Description copied from interface:MinimalCFGThe order of blocks returned should be arbitrary but deterministic.- Specified by:
getNormalSuccessorsin interfaceMinimalCFG<I>- Returns:
- the basic blocks which may be reached from b via normal control flow
-
getExceptionalPredecessors
Description copied from interface:MinimalCFGThe order of blocks returned should be arbitrary but deterministic.- Specified by:
getExceptionalPredecessorsin interfaceMinimalCFG<I>- Returns:
- the basic blocks from which b may be reached via exceptional control flow
-
getNormalPredecessors
Description copied from interface:MinimalCFGThe order of blocks returned should be arbitrary but deterministic.- Specified by:
getNormalPredecessorsin interfaceMinimalCFG<I>- Returns:
- the basic blocks from which b may be reached via normal control flow
-
entry
Description copied from interface:MinimalCFGReturn the entry basic block in the CFG- Specified by:
entryin interfaceMinimalCFG<I>
-
exit
- Specified by:
exitin interfaceMinimalCFG<I>- Returns:
- the synthetic exit block for the cfg
-
getBlockForInstruction
- Specified by:
getBlockForInstructionin interfaceControlFlowGraph<I, T extends IBasicBlock<I>>- Parameters:
index- an instruction index- Returns:
- the basic block which contains this instruction.
-
getInstructions
- Specified by:
getInstructionsin interfaceControlFlowGraph<I, T extends IBasicBlock<I>>- Returns:
- the instructions of this CFG, as an array.
-
getProgramCounter
public int getProgramCounter(int index) Description copied from interface:ControlFlowGraphTODO: move this into IR?- Specified by:
getProgramCounterin interfaceControlFlowGraph<I, T extends IBasicBlock<I>>- Parameters:
index- an instruction index- Returns:
- the program counter (bytecode index) corresponding to that instruction
-
getMethod
- Specified by:
getMethodin interfaceControlFlowGraph<I, T extends IBasicBlock<I>>- Returns:
- the Method this CFG represents
-
getCatchBlocks
- Specified by:
getCatchBlocksin interfaceControlFlowGraph<I, T extends IBasicBlock<I>>- Returns:
- the indices of the catch blocks, as a bit vector
-
getPhiIndices
-