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
ConstructorDescriptionBuild 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 TypeMethodDescriptionvoid
addEdge
(BasicBlockInContext<T> src, BasicBlockInContext<T> dst) 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.void
add a node to this graphvoid
Should be invoked when the underlying call graph has changed.boolean
protected CallSiteReference
get theCallSiteReference
corresponding 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 SSAInstruction
getLastInstructionForBlock
(T pb, SSAInstruction[] instrs) int
getNode
(int number) int
int
int
Return the number ofimmediate predecessor
nodes of nReturn anIterator
over the immediate predecessor nodes of ngetReturnSites
(BasicBlockInContext<T> callBlock) int
Return the number ofimmediate successor
nodes of this Node in the GraphReturn an Iterator over the immediate successor nodes of nboolean
protected boolean
hasCall
(BasicBlockInContext<T> B, ControlFlowGraph<SSAInstruction, T> cfg) boolean
hasEdge
(BasicBlockInContext<T> src, BasicBlockInContext<T> dst) boolean
isReturn
(BasicBlockInContext<T> bb) iterator()
void
void
removeEdge
(BasicBlockInContext<T> src, BasicBlockInContext<T> dst) void
void
remove a node from this graphvoid
remove a node and all its incident edgesvoid
stream()
toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.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:Graph
remove a node and all its incident edges- Specified by:
removeNodeAndEdges
in interfaceGraph<T extends ISSABasicBlock>
- Throws:
UnsupportedOperationException
- if the graph implementation does not allow removal- See Also:
-
iterator
- Specified by:
iterator
in interfaceIterable<T extends ISSABasicBlock>
- Specified by:
iterator
in interfaceNodeManager<T extends ISSABasicBlock>
- Returns:
- an
Iterator
of the nodes in this graph - See Also:
-
stream
- Specified by:
stream
in interfaceNodeManager<T extends ISSABasicBlock>
- Returns:
- a
Stream
of the nodes in this graph - See Also:
-
getNumberOfNodes
public int getNumberOfNodes()- Specified by:
getNumberOfNodes
in interfaceNodeManager<T extends ISSABasicBlock>
- Returns:
- the number of nodes in this graph
- See Also:
-
addNode
Description copied from interface:NodeManager
add a node to this graph- Specified by:
addNode
in interfaceNodeManager<T extends ISSABasicBlock>
- Throws:
UnsupportedOperationException
- See Also:
-
removeNode
Description copied from interface:NodeManager
remove a node from this graph- Specified by:
removeNode
in interfaceNodeManager<T extends ISSABasicBlock>
- Throws:
UnsupportedOperationException
- See Also:
-
getPredNodes
Description copied from interface:EdgeManager
Return anIterator
over the immediate predecessor nodes of nThis method never returns
null
.- Specified by:
getPredNodes
in interfaceEdgeManager<T extends ISSABasicBlock>
- Returns:
- an
Iterator
over the immediate predecessor nodes of this Node. - See Also:
-
getPredNodeCount
Description copied from interface:EdgeManager
Return the number ofimmediate predecessor
nodes of n- Specified by:
getPredNodeCount
in interfaceEdgeManager<T extends ISSABasicBlock>
- Returns:
- the number of immediate predecessors of n.
- See Also:
-
getSuccNodes
Description copied from interface:EdgeManager
Return an Iterator over the immediate successor nodes of nThis method never returns
null
.- Specified by:
getSuccNodes
in interfaceEdgeManager<T extends ISSABasicBlock>
- Returns:
- an Iterator over the immediate successor nodes of n
- See Also:
-
getSuccNodeCount
Description copied from interface:EdgeManager
Return the number ofimmediate successor
nodes of this Node in the Graph- Specified by:
getSuccNodeCount
in 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:
addEdge
in interfaceEdgeManager<T extends ISSABasicBlock>
- Throws:
UnsupportedOperationException
- See Also:
-
removeEdge
public void removeEdge(BasicBlockInContext<T> src, BasicBlockInContext<T> dst) throws UnsupportedOperationException - Specified by:
removeEdge
in interfaceEdgeManager<T extends ISSABasicBlock>
- Throws:
UnsupportedOperationException
-
removeAllIncidentEdges
public void removeAllIncidentEdges(BasicBlockInContext<T> node) throws UnsupportedOperationException - Specified by:
removeAllIncidentEdges
in interfaceEdgeManager<T extends ISSABasicBlock>
- Throws:
UnsupportedOperationException
- See Also:
-
toString
-
containsNode
- Specified by:
containsNode
in 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 instuction
-
hasCall
- Returns:
- true iff basic block B ends in a call instuction
-
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 theCallSiteReference
corresponding to the last instruction in B (assumed to be a call) -
removeIncomingEdges
- Specified by:
removeIncomingEdges
in interfaceEdgeManager<T extends ISSABasicBlock>
- Throws:
UnsupportedOperationException
-
removeOutgoingEdges
- Specified by:
removeOutgoingEdges
in interfaceEdgeManager<T extends ISSABasicBlock>
- Throws:
UnsupportedOperationException
-
hasEdge
- Specified by:
hasEdge
in interfaceEdgeManager<T extends ISSABasicBlock>
-
getNumber
- Specified by:
getNumber
in interfaceNumberedNodeManager<T extends ISSABasicBlock>
-
getNode
- Specified by:
getNode
in interfaceNumberedNodeManager<T extends ISSABasicBlock>
- Throws:
UnimplementedError
-
getMaxNumber
public int getMaxNumber()- Specified by:
getMaxNumber
in interfaceNumberedNodeManager<T extends ISSABasicBlock>
-
iterateNodes
- Specified by:
iterateNodes
in interfaceNumberedNodeManager<T extends ISSABasicBlock>
- Returns:
- iterator of nodes with the numbers in set s
- Throws:
UnimplementedError
-
getSuccNodeNumbers
- Specified by:
getSuccNodeNumbers
in interfaceNumberedEdgeManager<T extends ISSABasicBlock>
- Returns:
- the numbers identifying the immediate successors of node
-
getPredNodeNumbers
- Specified by:
getPredNodeNumbers
in 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
-