Skip to content

Commit 887452d

Browse files
committed
Swift: Update SSA to reference the new use-use predicates.
1 parent e8e9403 commit 887452d

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,23 @@ module Ssa {
151151

152152
cached
153153
ControlFlowNode getAFirstRead() {
154-
exists(SsaInput::BasicBlock bb1, int i1, SsaInput::BasicBlock bb2, int i2 |
155-
this.definesAt(_, bb1, i1) and
156-
SsaImpl::adjacentDefRead(this, bb1, i1, bb2, i2) and
157-
result = bb2.getNode(i2)
154+
exists(SsaInput::BasicBlock bb, int i |
155+
SsaImpl::firstUse(this, bb, i, true) and
156+
result = bb.getNode(i)
158157
)
159158
}
160159

161160
cached
162161
predicate adjacentReadPair(ControlFlowNode read1, ControlFlowNode read2) {
163162
exists(SsaInput::BasicBlock bb1, int i1, SsaInput::BasicBlock bb2, int i2 |
164163
read1 = bb1.getNode(i1) and
165-
SsaInput::variableRead(bb1, i1, _, true) and
166-
SsaImpl::adjacentDefRead(this, bb1, i1, bb2, i2) and
164+
SsaImpl::adjacentUseUse(bb1, i1, bb2, i2, _, true) and
167165
read2 = bb2.getNode(i2)
168166
)
169167
}
170168

171169
cached
172-
predicate lastRefRedef(SsaInput::BasicBlock bb, int i, Definition next) {
170+
deprecated predicate lastRefRedef(SsaInput::BasicBlock bb, int i, Definition next) {
173171
SsaImpl::lastRefRedef(this, bb, i, next)
174172
}
175173
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,8 @@ private class CaptureNodeImpl extends CaptureNode, NodeImpl {
111111
}
112112

113113
private predicate localFlowSsaInput(Node nodeFrom, Ssa::Definition def, Ssa::Definition next) {
114-
exists(BasicBlock bb, int i | def.lastRefRedef(bb, i, next) |
115-
def.definesAt(_, bb, i) and
116-
def = nodeFrom.asDefinition()
117-
)
114+
next.(Ssa::PhiDefinition).getAPhiInput() = def and
115+
def = nodeFrom.asDefinition()
118116
}
119117

120118
/** A collection of cached types and predicates to be evaluated in the same stage. */

0 commit comments

Comments
 (0)