Skip to content

Commit 2c35af5

Browse files
committed
Swift: Move logic into Ssa::WriteDefinition.assigns.
1 parent 8a77906 commit 2c35af5

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

swift/ql/lib/codeql/swift/dataflow/Ssa.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ module Ssa {
165165
// TODO: We should probably enumerate more cfg nodes here.
166166
value.(PropertyGetterCfgNode).getRef() = init
167167
)
168+
or
169+
exists(VarDecl var, SsaInput::BasicBlock bb, int blockIndex, ConditionElement ce, Expr init |
170+
this.definesAt(var, bb, blockIndex) and
171+
ce.getPattern() = bb.getNode(blockIndex).getNode().asAstNode() and
172+
init = ce.getInitializer()
173+
|
174+
value.getNode().asAstNode() = init
175+
)
168176
}
169177
}
170178

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,6 @@ 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
129122
// step from def to first read
130123
nodeFrom.asDefinition() = def and
131124
nodeTo.getCfgNode() = def.getAFirstRead() and

0 commit comments

Comments
 (0)