Skip to content

Commit 52d5578

Browse files
committed
Swift: Dataflow through second argument of ??.
1 parent 2dbb891 commit 52d5578

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,14 @@ private module Cached {
156156
// flow through nil-coalescing operator `??`
157157
exists(BinaryExpr nco |
158158
nco.getFunction().(DeclRefExpr).getDecl().(FreeFunctionDecl).getName() = "??(_:_:)" and
159-
nodeFrom.asExpr() = nco.getAnOperand() and
159+
(
160+
// value argument
161+
nodeFrom.asExpr() = nco.getAnOperand()
162+
or
163+
// unpack closure (the second argument is typically an `AutoClosureExpr` argument)
164+
nodeFrom.asExpr() =
165+
nco.getAnOperand().(AbstractClosureExpr).getBody().getAnElement().(ReturnStmt).getResult()
166+
) and
160167
nodeTo.asExpr() = nco
161168
)
162169
or

0 commit comments

Comments
 (0)