Skip to content

Commit 4eee375

Browse files
committed
Swift: Add AutoClosureExpr.getExpr.
1 parent 13d6deb commit 4eee375

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private module Cached {
162162
nodeFrom.asExpr() = nco.getAnOperand()
163163
or
164164
// unpack closure (the second argument is typically an `AutoClosureExpr` argument)
165-
nodeFrom.asExpr() = nco.getAnOperand().(AutoClosureExpr).getReturn().getResult()
165+
nodeFrom.asExpr() = nco.getAnOperand().(AutoClosureExpr).getExpr()
166166
)
167167
or
168168
// flow through ternary operator `? :`
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
private import codeql.swift.generated.expr.AutoClosureExpr
22
private import codeql.swift.elements.stmt.ReturnStmt
3+
private import codeql.swift.elements.expr.Expr
34

45
class AutoClosureExpr extends Generated::AutoClosureExpr {
56
/** Gets the implicit return statement generated by this autoclosure expression. */
67
ReturnStmt getReturn() { result = unique( | | this.getBody().getAnElement()) }
78

9+
/**
10+
* Gets the expression returned by this autoclosure expression.
11+
*/
12+
Expr getExpr() { result = this.getReturn().getResult() }
13+
814
override string toString() { result = this.getBody().toString() }
915
}

0 commit comments

Comments
 (0)