Skip to content

Commit 7d36bc1

Browse files
committed
Swift: Fix CFG for 'foreach' statements.
1 parent 73c1899 commit 7d36bc1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ module Stmts {
476476
or
477477
// Flow from last element of variable declaration ...
478478
astLast(ast.getPattern().getFullyUnresolved(), pred, c) and
479-
c instanceof SimpleCompletion and
479+
c instanceof NormalCompletion and
480480
(
481481
// ... to first element of loop body if no 'where' clause exists,
482482
astFirst(ast.getBody(), succ) and

swift/ql/test/library-tests/controlflow/graph/Cfg.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,7 @@ cfg.swift:
12451245
#-----| empty -> switch x { ... }
12461246

12471247
# 138| _
1248+
#-----| no-match -> { ... }
12481249

12491250
# 138| 0
12501251
#-----| -> 10
@@ -1265,6 +1266,9 @@ cfg.swift:
12651266
# 138| 10
12661267
#-----| -> ... call to ... ...
12671268

1269+
# 138| { ... }
1270+
#-----| -> for ... in ... { ... }
1271+
12681272
# 140| switch x { ... }
12691273
#-----| -> x
12701274

0 commit comments

Comments
 (0)