File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
rust/ql/lib/codeql/rust/controlflow/internal Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -119,3 +119,9 @@ predicate completionIsSimple(Completion c) { c instanceof SimpleCompletion }
119
119
120
120
/** Holds if `c` is a valid completion for `n`. */
121
121
predicate completionIsValidFor ( Completion c , AstNode n ) { c .isValidFor ( n ) }
122
+
123
+ /** Holds if `c` is a completion that interacts with a loop such as `loop`, `for`, `while`. */
124
+ predicate isLoopCompletion ( Completion c ) {
125
+ c instanceof BreakCompletion or
126
+ c instanceof ContinueCompletion
127
+ }
Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ class LetStmtTree extends StandardPostOrderTree instanceof LetStmt {
174
174
}
175
175
176
176
class LoopExprTree extends PostOrderTree instanceof LoopExpr {
177
- override predicate propagatesAbnormal ( AstNode child ) { child = super . getBody ( ) }
177
+ override predicate propagatesAbnormal ( AstNode child ) { none ( ) }
178
178
179
179
override predicate first ( AstNode node ) { first ( super .getBody ( ) , node ) }
180
180
@@ -189,6 +189,14 @@ class LoopExprTree extends PostOrderTree instanceof LoopExpr {
189
189
c instanceof BreakCompletion and
190
190
succ = this
191
191
}
192
+
193
+ override predicate last ( AstNode last , Completion c ) {
194
+ super .last ( last , c )
195
+ or
196
+ last ( super .getBody ( ) , last , c ) and
197
+ not completionIsNormal ( c ) and
198
+ not isLoopCompletion ( c )
199
+ }
192
200
}
193
201
194
202
class ReturnExprTree extends PostOrderTree instanceof ReturnExpr {
You can’t perform that action at this time.
0 commit comments