1
1
/**
2
2
* Provides classes and predicates for computing expression-level intra-procedural control flow graphs.
3
3
*
4
- * The only API exported by this library are the toplevel classes `ControlFlowNode `
4
+ * The only API exported by this library are the toplevel classes `ControlFlow::Node `
5
5
* and its subclass `ConditionNode`, which wrap the successor relation and the
6
6
* concept of true- and false-successors of conditions. A cfg node may either be a
7
7
* statement, an expression, or an exit node for a callable, indicating that
@@ -164,7 +164,7 @@ module ControlFlow {
164
164
}
165
165
166
166
/**
167
- * Get the most appropriate AST node for this control flow node, if any.
167
+ * Gets the most appropriate AST node for this control flow node, if any.
168
168
*
169
169
* This is needed for the equivalence relation on basic blocks in range
170
170
* analysis.
@@ -176,7 +176,7 @@ module ControlFlow {
176
176
}
177
177
}
178
178
179
- /** A synthetic node for the exit of a callable. */
179
+ /** A control flow node indicating the termination of a callable. */
180
180
class ExitNode extends Node , TExitNode { }
181
181
}
182
182
@@ -197,7 +197,7 @@ private module ControlFlowGraphImpl {
197
197
result = this .( Expr ) .getEnclosingStmt ( )
198
198
}
199
199
200
- Node getCFGNode ( ) { result .asExpr ( ) = this or result .asStmt ( ) = this }
200
+ Node getCfgNode ( ) { result .asExpr ( ) = this or result .asStmt ( ) = this }
201
201
}
202
202
203
203
/**
@@ -931,7 +931,6 @@ private module ControlFlowGraphImpl {
931
931
)
932
932
or
933
933
// The last node of a node executed in post-order is the node itself.
934
- // n.(PostOrderNode).mayCompleteNormally() and last = n and completion = NormalCompletion()
935
934
exists ( PostOrderNode p | p = n |
936
935
p .mayCompleteNormally ( ) and last = p .getCFGNode ( ) and completion = NormalCompletion ( )
937
936
)
@@ -1195,7 +1194,7 @@ private module ControlFlowGraphImpl {
1195
1194
*/
1196
1195
cached
1197
1196
Node succ ( Node n , Completion completion ) {
1198
- // The successor of a callable is its exit node.
1197
+ // After executing the callable body, the final node is the exit node.
1199
1198
exists ( Callable c | last ( c .getBody ( ) , n , completion ) |
1200
1199
result .( ExitNode ) .getEnclosingCallable ( ) = c
1201
1200
)
@@ -1404,7 +1403,7 @@ private module ControlFlowGraphImpl {
1404
1403
switchExpr = switch .( SwitchStmt ) .getExpr ( ) or switchExpr = switch .( SwitchExpr ) .getExpr ( )
1405
1404
|
1406
1405
// From the entry point control is transferred first to the expression...
1407
- ( n . asStmt ( ) = switch or n . asExpr ( ) = switch ) and
1406
+ n . getAstNode ( ) = switch and
1408
1407
result = first ( switchExpr ) and
1409
1408
completion = NormalCompletion ( )
1410
1409
or
@@ -1601,6 +1600,6 @@ class ConditionNode extends ControlFlow::Node {
1601
1600
/** Gets a false-successor of the `ConditionNode`. */
1602
1601
ControlFlow:: Node getAFalseSuccessor ( ) { result = this .getABranchSuccessor ( false ) }
1603
1602
1604
- /** Gets the condition of this `ConditionNode`. This is equal to the node itself. */
1603
+ /** Gets the condition of this `ConditionNode`. */
1605
1604
ExprParent getCondition ( ) { result = this .asExpr ( ) or result = this .asStmt ( ) }
1606
1605
}
0 commit comments