Skip to content

Commit 1904daf

Browse files
committed
Include first step from SsaVariableCapture
Without this change the test go/ql/test/query-tests/InconsistentCode/UnhandledCloseWritableHandle/UnhandledCloseWritableHandle.qlref was failing.
1 parent d8002a0 commit 1904daf

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

go/ql/lib/semmle/go/dataflow/SSA.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ class SsaDefinition extends TSsaDefinition {
166166
) {
167167
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
168168
}
169+
170+
/**
171+
* Gets the first instruction that the value of this `SsaDefinition` can
172+
* reach without passing through any other instructions, but possibly through
173+
* phi nodes.
174+
*/
175+
IR::Instruction getAFirstUse() { firstUse(this, result) }
169176
}
170177

171178
/**
@@ -197,13 +204,6 @@ class SsaExplicitDefinition extends SsaDefinition, TExplicitDef {
197204
override string prettyPrintDef() { result = "definition of " + this.getSourceVariable() }
198205

199206
override Location getLocation() { result = this.getInstruction().getLocation() }
200-
201-
/**
202-
* Gets the first instruction that the value of this `SsaDefinition` can
203-
* reach without passing through any other instructions, but possibly through
204-
* phi nodes.
205-
*/
206-
IR::Instruction getAFirstUse() { firstUse(this, result) }
207207
}
208208

209209
/** Provides a helper predicate for working with explicit SSA definitions. */

go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ predicate basicLocalFlowStep(Node nodeFrom, Node nodeTo) {
8383
)
8484
or
8585
// SSA defn -> first SSA use
86-
exists(SsaExplicitDefinition pred, IR::Instruction succ | succ = pred.getAFirstUse() |
86+
exists(SsaDefinition pred, IR::Instruction succ | succ = pred.getAFirstUse() |
87+
(pred instanceof SsaExplicitDefinition or pred instanceof SsaVariableCapture) and
8788
nodeFrom = ssaNode(pred.getVariable()) and
8889
nodeTo = instructionNode(succ)
8990
)

0 commit comments

Comments
 (0)