Skip to content

Commit 28f111b

Browse files
committed
Rust: Remove erroneous CFG edge from return to break
1 parent 4ca6b0e commit 28f111b

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class BreakExprTree extends PostOrderTree, BreakExpr {
159159
override predicate last(AstNode last, Completion c) { none() }
160160

161161
override predicate succ(AstNode pred, AstNode succ, Completion c) {
162-
last(super.getExpr(), pred, c) and succ = this
162+
last(super.getExpr(), pred, c) and completionIsNormal(c) and succ = this
163163
or
164164
pred = this and
165165
c.isValidFor(pred) and

rust/ql/test/library-tests/controlflow/Cfg.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,8 @@ edges
207207
| test.rs:102:13:102:14 | ExprStmt | test.rs:102:13:102:13 | 1 | |
208208
| test.rs:106:5:110:5 | enter break_with_return | test.rs:108:13:108:27 | ExprStmt | |
209209
| test.rs:106:5:110:5 | exit break_with_return (normal) | test.rs:106:5:110:5 | exit break_with_return | |
210-
| test.rs:106:35:110:5 | BlockExpr | test.rs:106:5:110:5 | exit break_with_return (normal) | |
211-
| test.rs:107:9:109:9 | LoopExpr | test.rs:106:35:110:5 | BlockExpr | |
212-
| test.rs:108:13:108:26 | BreakExpr | test.rs:107:9:109:9 | LoopExpr | break |
213210
| test.rs:108:13:108:27 | ExprStmt | test.rs:108:26:108:26 | 1 | |
214211
| test.rs:108:19:108:26 | ReturnExpr | test.rs:106:5:110:5 | exit break_with_return (normal) | return |
215-
| test.rs:108:19:108:26 | ReturnExpr | test.rs:108:13:108:26 | BreakExpr | return |
216212
| test.rs:108:26:108:26 | 1 | test.rs:108:19:108:26 | ReturnExpr | |
217213
| test.rs:113:1:116:1 | enter test_nested_function | test.rs:113:25:113:25 | n | |
218214
| test.rs:113:1:116:1 | exit test_nested_function (normal) | test.rs:113:1:116:1 | exit test_nested_function | |

0 commit comments

Comments
 (0)