File tree Expand file tree Collapse file tree 2 files changed +24
-13
lines changed
java/ql/lib/semmle/code/java Expand file tree Collapse file tree 2 files changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ module;
8282 */
8383
8484import java
85+ private import codeql.controlflow.SuccessorType
8586private import codeql.util.Boolean
8687private import Completion
8788private import controlflow.internal.Preconditions
@@ -124,6 +125,28 @@ module ControlFlow {
124125 result = succ ( this , NormalCompletion ( ) )
125126 }
126127
128+ /** Gets an immediate successor of this node of a given type, if any. */
129+ Node getASuccessor ( SuccessorType t ) {
130+ result = branchSuccessor ( this , t .( BooleanSuccessor ) .getValue ( ) )
131+ or
132+ exists ( Completion completion |
133+ result = succ ( this , completion ) and
134+ not result = branchSuccessor ( this , _)
135+ |
136+ completion = NormalCompletion ( ) and t instanceof DirectSuccessor
137+ or
138+ completion = ReturnCompletion ( ) and t instanceof ReturnSuccessor
139+ or
140+ completion = BreakCompletion ( _) and t instanceof BreakSuccessor
141+ or
142+ completion = YieldCompletion ( _) and t instanceof BreakSuccessor
143+ or
144+ completion = ContinueCompletion ( _) and t instanceof ContinueSuccessor
145+ or
146+ completion = ThrowCompletion ( _) and t instanceof ExceptionSuccessor
147+ )
148+ }
149+
127150 /** Gets the basic block that contains this node. */
128151 BasicBlock getBasicBlock ( ) { result .getANode ( ) = this }
129152
Original file line number Diff line number Diff line change @@ -22,20 +22,8 @@ private module Input implements BB::InputSig<Location> {
2222 /** Gets the CFG scope in which this node occurs. */
2323 CfgScope nodeGetCfgScope ( Node node ) { node .getEnclosingCallable ( ) = result }
2424
25- private Node getASpecificSuccessor ( Node node , SuccessorType t ) {
26- node .( ConditionNode ) .getABranchSuccessor ( t .( BooleanSuccessor ) .getValue ( ) ) = result
27- or
28- node .getAnExceptionSuccessor ( ) = result and t instanceof ExceptionSuccessor
29- }
30-
3125 /** Gets an immediate successor of this node. */
32- Node nodeGetASuccessor ( Node node , SuccessorType t ) {
33- result = getASpecificSuccessor ( node , t )
34- or
35- node .getASuccessor ( ) = result and
36- t instanceof DirectSuccessor and
37- not result = getASpecificSuccessor ( node , _)
38- }
26+ Node nodeGetASuccessor ( Node node , SuccessorType t ) { result = node .getASuccessor ( t ) }
3927
4028 /**
4129 * Holds if `node` represents an entry node to be used when calculating
You can’t perform that action at this time.
0 commit comments