Skip to content

Commit bd095ab

Browse files
authored
Merge pull request github#9388 from MathiasVP/cfg-for-yield
Swift: CFG for `yield`
2 parents f417c12 + 5f9d03f commit bd095ab

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,14 @@ module Stmts {
203203
}
204204
}
205205

206+
private class YieldStmtTree extends AstStandardPostOrderTree {
207+
override YieldStmt ast;
208+
209+
final override ControlFlowElement getChildElement(int i) {
210+
result.asAstNode() = ast.getResult(i).getFullyConverted()
211+
}
212+
}
213+
206214
private class FailTree extends AstLeafTree {
207215
override FailStmt ast;
208216
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5032,6 +5032,11 @@ cfg.swift:
50325032
# 394| enter set
50335033
#-----| -> set
50345034

5035+
# 394| exit (unnamed function decl)
5036+
5037+
# 394| exit (unnamed function decl) (normal)
5038+
#-----| -> exit (unnamed function decl)
5039+
50355040
# 394| exit get
50365041

50375042
# 394| exit get (normal)
@@ -5049,6 +5054,9 @@ cfg.swift:
50495054

50505055
# 394| value
50515056

5057+
# 394| yield ...
5058+
#-----| -> exit (unnamed function decl) (normal)
5059+
50525060
# 395| deinit
50535061
#-----| -> self
50545062

0 commit comments

Comments
 (0)