Skip to content

Commit 8a77906

Browse files
committed
Swift: Use Ssa::Definition rather than ConcreteVarDecl.
1 parent 4e54837 commit 8a77906

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ private module Cached {
119119
def.(Ssa::WriteDefinition).assigns(nodeFrom.getCfgNode()) and
120120
nodeTo.asDefinition() = def
121121
or
122+
// flow through optional binding `if let`, similarly to assignment
123+
exists(ConditionElement ce |
124+
ce.getInitializer() = nodeFrom.asExpr() and
125+
ce.getPattern() = def.getSourceVariable().getParentPattern() and
126+
nodeTo.asDefinition() = def
127+
)
128+
or
122129
// step from def to first read
123130
nodeFrom.asDefinition() = def and
124131
nodeTo.getCfgNode() = def.getAFirstRead() and
@@ -153,13 +160,6 @@ private module Cached {
153160
or
154161
nodeFrom.asExpr() = nodeTo.asExpr().(OptionalEvaluationExpr).getSubExpr()
155162
or
156-
// flow through optional binding `if let`
157-
exists(ConditionElement ce, ConcreteVarDecl v |
158-
ce.getInitializer() = nodeFrom.asExpr() and
159-
ce.getPattern() = v.getParentPattern() and
160-
nodeTo.asDefinition().getSourceVariable() = v
161-
)
162-
or
163163
// flow through nil-coalescing operator `??`
164164
exists(BinaryExpr nco |
165165
nco.getOperator().(FreeFunctionDecl).getName() = "??(_:_:)" and

0 commit comments

Comments
 (0)