Class CFGBuilder
java.lang.Object
org.checkerframework.dataflow.cfg.builder.CFGBuilder
- Direct Known Subclasses:
- CFCFGBuilder
Builds the control flow graph of some Java code (either a method, or an arbitrary statement).
 
The translation of the AST to the CFG is split into three phases:
- Phase one. In the first phase, the AST is translated into a sequence of ExtendedNodes. An extended node can either be aNode, or one of several meta elements such as a conditional or unconditional jump or a node with additional information about exceptions. Some of the extended nodes contain labels (e.g., for the jump target), and phase one additionally creates a mapping from labels to extended nodes. Finally, the list of leaders is computed: A leader is an extended node which will give rise to a basic block in phase two.
- Phase two. In this phase, the sequence of extended nodes is translated to a graph of control flow blocks that contain nodes. The meta elements from phase one are translated into the correct edges.
- Phase three. The control flow graph generated in phase two can contain degenerate basic blocks such as empty regular basic blocks or conditional basic blocks that have the same block as both 'then' and 'else' successor. This phase removes these cases while preserving the control flow structure.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic ControlFlowGraphbuild(CompilationUnitTree root, MethodTree tree, ClassTree classTree, ProcessingEnvironment env) Build the control flow graph of a method.static ControlFlowGraphbuild(CompilationUnitTree root, UnderlyingAST underlyingAST, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled, ProcessingEnvironment env) Build the control flow graph of some code.static ControlFlowGraphbuild(CompilationUnitTree root, UnderlyingAST underlyingAST, ProcessingEnvironment env) Build the control flow graph of some code.static ControlFlowGraphbuild(TreePath bodyPath, UnderlyingAST underlyingAST, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled, ProcessingEnvironment env) Build the control flow graph of some code (method, initializer block, ...).static StringextendedNodeCollectionToStringDebug(Collection<? extends ExtendedNode> nodes) Return a printed representation of a collection of extended nodes.protected static voidprintBlocks(Set<Block> blocks) Print a set ofBlocks and the edges between them.
- 
Constructor Details- 
CFGBuilderprotected CFGBuilder()Creates a CFGBuilder.
 
- 
- 
Method Details- 
buildpublic static ControlFlowGraph build(CompilationUnitTree root, UnderlyingAST underlyingAST, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled, ProcessingEnvironment env) Build the control flow graph of some code.- Parameters:
- root- the compilation unit
- underlyingAST- the AST that underlies the control frow graph
- assumeAssertionsEnabled- can assertions be assumed to be enabled?
- assumeAssertionsDisabled- can assertions be assumed to be disabled?
- env- annotation processing environment containing type utilities
- Returns:
- a control flow graph
 
- 
buildpublic static ControlFlowGraph build(TreePath bodyPath, UnderlyingAST underlyingAST, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled, ProcessingEnvironment env) Build the control flow graph of some code (method, initializer block, ...). bodyPath is the TreePath to the body of that code.
- 
buildpublic static ControlFlowGraph build(CompilationUnitTree root, UnderlyingAST underlyingAST, ProcessingEnvironment env) Build the control flow graph of some code.
- 
buildpublic static ControlFlowGraph build(CompilationUnitTree root, MethodTree tree, ClassTree classTree, ProcessingEnvironment env) Build the control flow graph of a method.
- 
extendedNodeCollectionToStringDebugReturn a printed representation of a collection of extended nodes.- Parameters:
- nodes- a collection of extended nodes to format
- Returns:
- a printed representation of the given collection
 
- 
printBlocksPrint a set ofBlocks and the edges between them. This is useful for examining the results of phase two.- Parameters:
- blocks- the blocks to print
 
 
-