Skip to content

Commit 1573f24

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 e935001 commit 1573f24

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
@@ -154,6 +154,13 @@ class SsaDefinition extends TSsaDefinition {
154154
abstract predicate hasLocationInfo(
155155
string filepath, int startline, int startcolumn, int endline, int endcolumn
156156
);
157+
158+
/**
159+
* Gets the first instruction that the value of this `SsaDefinition` can
160+
* reach without passing through any other instructions, but possibly through
161+
* phi nodes.
162+
*/
163+
IR::Instruction getAFirstUse() { firstUse(this, result) }
157164
}
158165

159166
/**
@@ -187,13 +194,6 @@ class SsaExplicitDefinition extends SsaDefinition, TExplicitDef {
187194
) {
188195
this.getInstruction().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
189196
}
190-
191-
/**
192-
* Gets the first instruction that the value of this `SsaDefinition` can
193-
* reach without passing through any other instructions, but possibly through
194-
* phi nodes.
195-
*/
196-
IR::Instruction getAFirstUse() { firstUse(this, result) }
197197
}
198198

199199
/** 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
@@ -82,7 +82,8 @@ predicate basicLocalFlowStep(Node nodeFrom, Node nodeTo) {
8282
)
8383
or
8484
// SSA defn -> first SSA use
85-
exists(SsaExplicitDefinition pred, IR::Instruction succ | succ = pred.getAFirstUse() |
85+
exists(SsaDefinition pred, IR::Instruction succ | succ = pred.getAFirstUse() |
86+
(pred instanceof SsaExplicitDefinition or pred instanceof SsaVariableCapture) and
8687
nodeFrom = ssaNode(pred.getVariable()) and
8788
nodeTo = instructionNode(succ)
8889
)

0 commit comments

Comments
 (0)