Class AbstractInterproceduralCFG<T extends ISSABasicBlock>
java.lang.Object
com.ibm.wala.ipa.cfg.AbstractInterproceduralCFG<T>
- All Implemented Interfaces:
EdgeManager<BasicBlockInContext<T>>, Graph<BasicBlockInContext<T>>, NodeManager<BasicBlockInContext<T>>, NumberedEdgeManager<BasicBlockInContext<T>>, NumberedGraph<BasicBlockInContext<T>>, NumberedNodeManager<BasicBlockInContext<T>>, Iterable<BasicBlockInContext<T>>
- Direct Known Subclasses:
ExplodedInterproceduralCFG, InterproceduralCFG
public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock>
extends Object
implements NumberedGraph<BasicBlockInContext<T>>
Interprocedural control-flow graph, constructed lazily.
-
Constructor Summary
ConstructorsConstructorDescriptionBuild an Interprocedural CFG from a call graph.AbstractInterproceduralCFG(CallGraph CG, Predicate<CGNode> relevant) Build an Interprocedural CFG from a call graph. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEdge(BasicBlockInContext<T> src, BasicBlockInContext<T> dst) protected voidaddEdgesToNonEntryBlock(CGNode n, ControlFlowGraph<?, T> cfg, SSAInstruction[] instrs, T bb) Add edges to the IPCFG for the incoming edges incident on a basic block bb.voidadd a node to this graphvoidShould be invoked when the underlying call graph has changed.booleanprotected CallSiteReferenceget theCallSiteReferencecorresponding to the last instruction in B (assumed to be a call)getCallSites(BasicBlockInContext<T> returnBlock, CGNode callee) get the basic blocks which are call sites that may call callee and return to returnBlock if callee is null, answer return sites for which no callee was found.abstract ControlFlowGraph<SSAInstruction, T> protected SSAInstructiongetLastInstructionForBlock(T pb, SSAInstruction[] instrs) intgetNode(int number) intintintReturn the number ofimmediate predecessornodes of nReturn anIteratorover the immediate predecessor nodes of ngetReturnSites(BasicBlockInContext<T> callBlock) intReturn the number ofimmediate successornodes of this Node in the GraphReturn an Iterator over the immediate successor nodes of nbooleanprotected booleanhasCall(BasicBlockInContext<T> B, ControlFlowGraph<SSAInstruction, T> cfg) booleanhasEdge(BasicBlockInContext<T> src, BasicBlockInContext<T> dst) booleanisReturn(BasicBlockInContext<T> bb) iterator()voidvoidremoveEdge(BasicBlockInContext<T> src, BasicBlockInContext<T> dst) voidvoidremove a node from this graphvoidremove a node and all its incident edgesvoidstream()toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
AbstractInterproceduralCFG
Build an Interprocedural CFG from a call graph. This version defaults to using whatever CFGs the call graph provides by default, and includes all nodes in the call graph.- Parameters:
cg- the call graph
-
AbstractInterproceduralCFG
-
-
Method Details
-
callGraphUpdated
public void callGraphUpdated()Should be invoked when the underlying call graph has changed. This will cause certain successor and predecessor edges to be recomputed. USE WITH EXTREME CARE. -
getCFG
-
addEdgesToNonEntryBlock
protected void addEdgesToNonEntryBlock(CGNode n, ControlFlowGraph<?, T> cfg, SSAInstruction[] instrs, T bb) Add edges to the IPCFG for the incoming edges incident on a basic block bb.- Parameters:
n- a call graph nodecfg- the CFG for ninstrs- the instructions for node nbb- a basic block in the CFG
-
getLastInstructionForBlock
-
getCFG
public ControlFlowGraph<SSAInstruction, T> getCFG(BasicBlockInContext<T> B) throws IllegalArgumentException - Returns:
- the original CFG from whence B came
- Throws:
IllegalArgumentException- if B == null
-
getCGNode
- Returns:
- the original CGNode from whence B came
- Throws:
IllegalArgumentException- if B == null
-
removeNodeAndEdges
Description copied from interface:Graphremove a node and all its incident edges- Specified by:
removeNodeAndEdgesin interfaceGraph<T extends ISSABasicBlock>- Throws:
UnsupportedOperationException- if the graph implementation does not allow removal- See Also:
-
iterator
- Specified by:
iteratorin interfaceIterable<T extends ISSABasicBlock>- Specified by:
iteratorin interfaceNodeManager<T extends ISSABasicBlock>- Returns:
- an
Iteratorof the nodes in this graph - See Also:
-
stream
- Specified by:
streamin interfaceNodeManager<T extends ISSABasicBlock>- Returns:
- a
Streamof the nodes in this graph - See Also:
-
getNumberOfNodes
public int getNumberOfNodes()- Specified by:
getNumberOfNodesin interfaceNodeManager<T extends ISSABasicBlock>- Returns:
- the number of nodes in this graph
- See Also:
-
addNode
Description copied from interface:NodeManageradd a node to this graph- Specified by:
addNodein interfaceNodeManager<T extends ISSABasicBlock>- Throws:
UnsupportedOperationException- See Also:
-
removeNode
Description copied from interface:NodeManagerremove a node from this graph- Specified by:
removeNodein interfaceNodeManager<T extends ISSABasicBlock>- Throws:
UnsupportedOperationException- See Also:
-
getPredNodes
Description copied from interface:EdgeManagerReturn anIteratorover the immediate predecessor nodes of nThis method never returns
null.- Specified by:
getPredNodesin interfaceEdgeManager<T extends ISSABasicBlock>- Returns:
- an
Iteratorover the immediate predecessor nodes of this Node. - See Also:
-
getPredNodeCount
Description copied from interface:EdgeManagerReturn the number ofimmediate predecessornodes of n- Specified by:
getPredNodeCountin interfaceEdgeManager<T extends ISSABasicBlock>- Returns:
- the number of immediate predecessors of n.
- See Also:
-
getSuccNodes
Description copied from interface:EdgeManagerReturn an Iterator over the immediate successor nodes of nThis method never returns
null.- Specified by:
getSuccNodesin interfaceEdgeManager<T extends ISSABasicBlock>- Returns:
- an Iterator over the immediate successor nodes of n
- See Also:
-
getSuccNodeCount
Description copied from interface:EdgeManagerReturn the number ofimmediate successornodes of this Node in the Graph- Specified by:
getSuccNodeCountin interfaceEdgeManager<T extends ISSABasicBlock>- Returns:
- the number of immediate successor Nodes of this Node in the Graph.
- See Also:
-
addEdge
public void addEdge(BasicBlockInContext<T> src, BasicBlockInContext<T> dst) throws UnsupportedOperationException - Specified by:
addEdgein interfaceEdgeManager<T extends ISSABasicBlock>- Throws:
UnsupportedOperationException- See Also:
-
removeEdge
public void removeEdge(BasicBlockInContext<T> src, BasicBlockInContext<T> dst) throws UnsupportedOperationException - Specified by:
removeEdgein interfaceEdgeManager<T extends ISSABasicBlock>- Throws:
UnsupportedOperationException
-
removeAllIncidentEdges
public void removeAllIncidentEdges(BasicBlockInContext<T> node) throws UnsupportedOperationException - Specified by:
removeAllIncidentEdgesin interfaceEdgeManager<T extends ISSABasicBlock>- Throws:
UnsupportedOperationException- See Also:
-
toString
-
containsNode
- Specified by:
containsNodein interfaceNodeManager<T extends ISSABasicBlock>- Returns:
- true iff the graph contains the specified node
- See Also:
-
hasCall
- Returns:
- true iff basic block B ends in a call instruction
-
hasCall
- Returns:
- true iff basic block B ends in a call instruction
-
getCallTargets
- Returns:
- the set of CGNodes that B may call, according to the governing call graph.
- Throws:
IllegalArgumentException- if B is null
-
getCallSiteForCallBlock
protected CallSiteReference getCallSiteForCallBlock(IBasicBlock<SSAInstruction> B, ControlFlowGraph<SSAInstruction, T> cfg) get theCallSiteReferencecorresponding to the last instruction in B (assumed to be a call) -
removeIncomingEdges
- Specified by:
removeIncomingEdgesin interfaceEdgeManager<T extends ISSABasicBlock>- Throws:
UnsupportedOperationException
-
removeOutgoingEdges
- Specified by:
removeOutgoingEdgesin interfaceEdgeManager<T extends ISSABasicBlock>- Throws:
UnsupportedOperationException
-
hasEdge
- Specified by:
hasEdgein interfaceEdgeManager<T extends ISSABasicBlock>
-
getNumber
- Specified by:
getNumberin interfaceNumberedNodeManager<T extends ISSABasicBlock>
-
getNode
- Specified by:
getNodein interfaceNumberedNodeManager<T extends ISSABasicBlock>- Throws:
UnimplementedError
-
getMaxNumber
public int getMaxNumber()- Specified by:
getMaxNumberin interfaceNumberedNodeManager<T extends ISSABasicBlock>
-
iterateNodes
- Specified by:
iterateNodesin interfaceNumberedNodeManager<T extends ISSABasicBlock>- Returns:
- iterator of nodes with the numbers in set s
- Throws:
UnimplementedError
-
getSuccNodeNumbers
- Specified by:
getSuccNodeNumbersin interfaceNumberedEdgeManager<T extends ISSABasicBlock>- Returns:
- the numbers identifying the immediate successors of node
-
getPredNodeNumbers
- Specified by:
getPredNodeNumbersin interfaceNumberedEdgeManager<T extends ISSABasicBlock>- Returns:
- the numbers identifying the immediate predecessors of node
-
getEntry
-
getExit
-
getReturnSites
- Parameters:
callBlock- node in the IPCFG that ends in a call- Returns:
- the nodes that are return sites for this call.
- Throws:
IllegalArgumentException- if bb is null
-
getCallSites
public Iterator<BasicBlockInContext<T>> getCallSites(BasicBlockInContext<T> returnBlock, CGNode callee) get the basic blocks which are call sites that may call callee and return to returnBlock if callee is null, answer return sites for which no callee was found. -
isReturn
- Throws:
IllegalArgumentException
-
getCallGraph
-