Class ControlFlowGraph
java.lang.Object
org.checkerframework.dataflow.cfg.ControlFlowGraph
- All Implemented Interfaces:
org.plumelib.util.UniqueId
A control flow graph (CFG for short) of a single method.
The graph is represented by the successors (methods SingleSuccessorBlock.getSuccessor()
,
ConditionalBlock.getThenSuccessor()
, ConditionalBlock.getElseSuccessor()
, ExceptionBlock.getExceptionalSuccessors()
, RegularBlock.getRegularSuccessor()
) and
predecessors (method Block.getPredecessors()
) of the entry and exit blocks.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final IdentityHashMap<com.sun.source.tree.Tree,
Set<Node>> Map from ASTTree
s to post-conversion sets ofNode
s.protected final List<com.sun.source.tree.ClassTree>
Class declarations that have been encountered when building the control-flow graph for a method.protected final List<com.sun.source.tree.LambdaExpressionTree>
Lambdas encountered when building the control-flow graph for a method, variable initializer, or initializer.protected final SpecialBlock
The entry block of the control flow graph.protected final SpecialBlock
The exceptional exit block of the control flow graph.protected final IdentityHashMap<com.sun.source.tree.UnaryTree,
com.sun.source.tree.BinaryTree> Map from postfix increment or decrement trees that are ASTUnaryTree
s to the synthetic tree that isv + 1
orv - 1
.protected final SpecialBlock
The regular exit block of the control flow graph.protected final List<ReturnNode>
All return nodes (if any) encountered.protected final IdentityHashMap<com.sun.source.tree.Tree,
Set<Node>> Maps from ASTTree
s to sets ofNode
s.final UnderlyingAST
The AST this CFG corresponds to. -
Constructor Summary
ConstructorDescriptionControlFlowGraph
(SpecialBlock entryBlock, SpecialBlockImpl regularExitBlock, SpecialBlockImpl exceptionalExitBlock, UnderlyingAST underlyingAST, IdentityHashMap<com.sun.source.tree.Tree, Set<Node>> treeLookup, IdentityHashMap<com.sun.source.tree.Tree, Set<Node>> convertedTreeLookup, IdentityHashMap<com.sun.source.tree.UnaryTree, com.sun.source.tree.BinaryTree> postfixNodeLookup, List<ReturnNode> returnNodes, List<com.sun.source.tree.ClassTree> declaredClasses, List<com.sun.source.tree.LambdaExpressionTree> declaredLambdas) -
Method Summary
Modifier and TypeMethodDescriptionReturns the set of all basic blocks in this control flow graph.Returns all nodes in this control flow graph.@Nullable com.sun.source.tree.ClassTree
getContainingClass
(com.sun.source.tree.Tree t) @Nullable com.sun.source.tree.MethodTree
getContainingMethod
(com.sun.source.tree.Tree t) List<com.sun.source.tree.ClassTree>
List<com.sun.source.tree.LambdaExpressionTree>
Returns all basic blocks in this control flow graph, in reversed depth-first postorder.Returns the entry block of the control flow graph.getNodesCorrespondingToTree
(com.sun.source.tree.Tree t) Returns the set ofNode
s to which theTree
t
corresponds, or null for trees that don't produce a value.org.plumelib.util.UnmodifiableIdentityHashMap<com.sun.source.tree.UnaryTree,
com.sun.source.tree.BinaryTree> Returns an unmodifiable view of the lookup-map of the binary tree for a postfix expression.Returns an unmodifiable view of the tree-lookup map.long
getUid()
Returns the AST this CFG corresponds to.toString()
Returns a verbose string representation of this, useful for debugging.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.plumelib.util.UniqueId
getClassAndUid
-
Field Details
-
entryBlock
The entry block of the control flow graph. -
regularExitBlock
The regular exit block of the control flow graph. -
exceptionalExitBlock
The exceptional exit block of the control flow graph. -
underlyingAST
The AST this CFG corresponds to. -
treeLookup
Maps from ASTTree
s to sets ofNode
s.- Most Trees that produce a value will have at least one corresponding Node.
- Trees that undergo conversions, such as boxing or unboxing, can map to two distinct
Nodes. The Node for the pre-conversion value is stored in
treeLookup
, while the Node for the post-conversion value is stored inconvertedTreeLookup
.
treeLookup
andconvertedTreeLookup
) do not appear ingetAllNodes()
because their blocks are not reachable in the control flow graph. Dataflow will not compute abstract values for these nodes. -
convertedTreeLookup
Map from ASTTree
s to post-conversion sets ofNode
s. -
postfixNodeLookup
protected final IdentityHashMap<com.sun.source.tree.UnaryTree,com.sun.source.tree.BinaryTree> postfixNodeLookupMap from postfix increment or decrement trees that are ASTUnaryTree
s to the synthetic tree that isv + 1
orv - 1
. -
returnNodes
All return nodes (if any) encountered. Only includes return statements that actually return something -
declaredClasses
Class declarations that have been encountered when building the control-flow graph for a method. -
declaredLambdas
Lambdas encountered when building the control-flow graph for a method, variable initializer, or initializer.
-
-
Constructor Details
-
ControlFlowGraph
public ControlFlowGraph(SpecialBlock entryBlock, SpecialBlockImpl regularExitBlock, SpecialBlockImpl exceptionalExitBlock, UnderlyingAST underlyingAST, IdentityHashMap<com.sun.source.tree.Tree, Set<Node>> treeLookup, IdentityHashMap<com.sun.source.tree.Tree, Set<Node>> convertedTreeLookup, IdentityHashMap<com.sun.source.tree.UnaryTree, com.sun.source.tree.BinaryTree> postfixNodeLookup, List<ReturnNode> returnNodes, List<com.sun.source.tree.ClassTree> declaredClasses, List<com.sun.source.tree.LambdaExpressionTree> declaredLambdas)
-
-
Method Details
-
getUid
- Specified by:
getUid
in interfaceorg.plumelib.util.UniqueId
-
getNodesCorrespondingToTree
Returns the set ofNode
s to which theTree
t
corresponds, or null for trees that don't produce a value.- Parameters:
t
- a tree- Returns:
- the set of
Node
s to which theTree
t
corresponds, or null for trees that don't produce a value
-
getEntryBlock
Returns the entry block of the control flow graph.- Returns:
- the entry block of the control flow graph
-
getReturnNodes
-
getRegularExitBlock
-
getExceptionalExitBlock
-
getUnderlyingAST
Returns the AST this CFG corresponds to.- Returns:
- the AST this CFG corresponds to
-
getAllBlocks
public Set<Block> getAllBlocks(@UnknownInitialization(ControlFlowGraph.class) ControlFlowGraph this) Returns the set of all basic blocks in this control flow graph.- Returns:
- the set of all basic blocks in this control flow graph
-
getAllNodes
Returns all nodes in this control flow graph.- Returns:
- all nodes in this control flow graph
-
getDepthFirstOrderedBlocks
Returns all basic blocks in this control flow graph, in reversed depth-first postorder. Blocks may appear more than once in the sequence.- Returns:
- the list of all basic block in this control flow graph in reversed depth-first postorder sequence
-
getTreeLookup
public org.plumelib.util.UnmodifiableIdentityHashMap<com.sun.source.tree.Tree,Set<Node>> getTreeLookup()Returns an unmodifiable view of the tree-lookup map. Ignores convertedTreeLookup, thoughgetNodesCorrespondingToTree(com.sun.source.tree.Tree)
uses that field.- Returns:
- the unmodifiable tree-lookup map
-
getPostfixNodeLookup
public org.plumelib.util.UnmodifiableIdentityHashMap<com.sun.source.tree.UnaryTree,com.sun.source.tree.BinaryTree> getPostfixNodeLookup()Returns an unmodifiable view of the lookup-map of the binary tree for a postfix expression.- Returns:
- the unmodifiable lookup-map of the binary tree for a postfix expression
-
getContainingMethod
-
getContainingClass
-
getDeclaredClasses
-
getDeclaredLambdas
-
toString
-
toStringDebug
Returns a verbose string representation of this, useful for debugging.- Returns:
- a string representation of this
-