Package com.ibm.wala.ipa.cfg
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>
,com.ibm.wala.util.graph.EdgeManager<T>
,com.ibm.wala.util.graph.Graph<T>
,com.ibm.wala.util.graph.NodeManager<T>
,com.ibm.wala.util.graph.NumberedEdgeManager<T>
,com.ibm.wala.util.graph.NumberedGraph<T>
,com.ibm.wala.util.graph.NumberedNodeManager<T>
,java.lang.Iterable<T>
public class PrunedCFG<I,T extends IBasicBlock<I>> extends com.ibm.wala.util.graph.AbstractNumberedGraph<T> implements ControlFlowGraph<I,T>
A pruned view of aControlFlowGraph
. Use this class along with anEdgeFilter
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
entry()
Return the entry basic block in the CFGT
exit()
T
getBlockForInstruction(int index)
com.ibm.wala.util.intset.BitVector
getCatchBlocks()
protected com.ibm.wala.util.graph.NumberedEdgeManager<T>
getEdgeManager()
java.util.Collection<T>
getExceptionalPredecessors(T N)
The order of blocks returned should be arbitrary but deterministic.java.util.List<T>
getExceptionalSuccessors(T N)
The order of blocks returned must indicate the exception-handling scope.I[]
getInstructions()
IMethod
getMethod()
protected com.ibm.wala.util.graph.NumberedNodeManager<T>
getNodeManager()
java.util.Collection<T>
getNormalPredecessors(T N)
The order of blocks returned should be arbitrary but deterministic.java.util.Collection<T>
getNormalSuccessors(T N)
The order of blocks returned should be arbitrary but deterministic.com.ibm.wala.util.intset.IntSet
getPhiIndices(T bb)
int
getProgramCounter(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 com.ibm.wala.util.graph.AbstractNumberedGraph
getMaxNumber, getNode, getNumber, getPredNodeNumbers, getSuccNodeNumbers, iterateNodes
-
Methods inherited from class com.ibm.wala.util.graph.AbstractGraph
addEdge, addNode, containsNode, edgeString, getNumberOfNodes, getPredNodeCount, getPredNodes, getSuccNodeCount, getSuccNodes, hasEdge, iterator, nodeString, removeAllIncidentEdges, removeEdge, removeIncomingEdges, removeNode, removeNodeAndEdges, removeOutgoingEdges, stream, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.ibm.wala.util.graph.EdgeManager
addEdge, getPredNodeCount, getPredNodes, getSuccNodeCount, getSuccNodes, hasEdge, removeAllIncidentEdges, removeEdge, removeIncomingEdges, removeOutgoingEdges
-
Methods inherited from interface com.ibm.wala.util.graph.NodeManager
addNode, containsNode, getNumberOfNodes, iterator, removeNode, stream
-
-
-
-
Method Detail
-
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:
java.lang.IllegalArgumentException
- if cfg is null
-
getNodeManager
protected com.ibm.wala.util.graph.NumberedNodeManager<T> getNodeManager()
- Specified by:
getNodeManager
in classcom.ibm.wala.util.graph.AbstractNumberedGraph<T extends IBasicBlock<I>>
-
getEdgeManager
protected com.ibm.wala.util.graph.NumberedEdgeManager<T> getEdgeManager()
- Specified by:
getEdgeManager
in classcom.ibm.wala.util.graph.AbstractNumberedGraph<T extends IBasicBlock<I>>
-
getExceptionalSuccessors
public java.util.List<T> getExceptionalSuccessors(T N)
Description copied from interface:MinimalCFG
The 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:
getExceptionalSuccessors
in interfaceMinimalCFG<I>
- Returns:
- the basic blocks which may be reached from b via exceptional control flow
-
getNormalSuccessors
public java.util.Collection<T> getNormalSuccessors(T N)
Description copied from interface:MinimalCFG
The order of blocks returned should be arbitrary but deterministic.- Specified by:
getNormalSuccessors
in interfaceMinimalCFG<I>
- Returns:
- the basic blocks which may be reached from b via normal control flow
-
getExceptionalPredecessors
public java.util.Collection<T> getExceptionalPredecessors(T N)
Description copied from interface:MinimalCFG
The order of blocks returned should be arbitrary but deterministic.- Specified by:
getExceptionalPredecessors
in interfaceMinimalCFG<I>
- Returns:
- the basic blocks from which b may be reached via exceptional control flow
-
getNormalPredecessors
public java.util.Collection<T> getNormalPredecessors(T N)
Description copied from interface:MinimalCFG
The order of blocks returned should be arbitrary but deterministic.- Specified by:
getNormalPredecessors
in interfaceMinimalCFG<I>
- Returns:
- the basic blocks from which b may be reached via normal control flow
-
entry
public T entry()
Description copied from interface:MinimalCFG
Return the entry basic block in the CFG- Specified by:
entry
in interfaceMinimalCFG<I>
-
exit
public T exit()
- Specified by:
exit
in interfaceMinimalCFG<I>
- Returns:
- the synthetic exit block for the cfg
-
getBlockForInstruction
public T getBlockForInstruction(int index)
- Specified by:
getBlockForInstruction
in interfaceControlFlowGraph<I,T extends IBasicBlock<I>>
- Parameters:
index
- an instruction index- Returns:
- the basic block which contains this instruction.
-
getInstructions
public I[] getInstructions()
- Specified by:
getInstructions
in 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:ControlFlowGraph
TODO: move this into IR?- Specified by:
getProgramCounter
in interfaceControlFlowGraph<I,T extends IBasicBlock<I>>
- Parameters:
index
- an instruction index- Returns:
- the program counter (bytecode index) corresponding to that instruction
-
getMethod
public IMethod getMethod()
- Specified by:
getMethod
in interfaceControlFlowGraph<I,T extends IBasicBlock<I>>
- Returns:
- the Method this CFG represents
-
getCatchBlocks
public com.ibm.wala.util.intset.BitVector getCatchBlocks()
- Specified by:
getCatchBlocks
in interfaceControlFlowGraph<I,T extends IBasicBlock<I>>
- Returns:
- the indices of the catch blocks, as a bit vector
-
getPhiIndices
public com.ibm.wala.util.intset.IntSet getPhiIndices(T bb)
-
-