Skip to content

Commit 5f9d03f

Browse files
committed
Swift: CFG for 'yield'.
1 parent f598b26 commit 5f9d03f

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
@@ -5139,6 +5139,11 @@ cfg.swift:
51395139
# 394| enter set
51405140
#-----| -> set
51415141

5142+
# 394| exit (unnamed function decl)
5143+
5144+
# 394| exit (unnamed function decl) (normal)
5145+
#-----| -> exit (unnamed function decl)
5146+
51425147
# 394| exit get
51435148

51445149
# 394| exit get (normal)
@@ -5156,6 +5161,9 @@ cfg.swift:
51565161

51575162
# 394| value
51585163

5164+
# 394| yield ...
5165+
#-----| -> exit (unnamed function decl) (normal)
5166+
51595167
# 395| deinit
51605168
#-----| -> self
51615169

0 commit comments

Comments
 (0)