Include first step from SsaVariableCapture

Without this change the test
go/ql/test/query-tests/InconsistentCode/UnhandledCloseWritableHandle/UnhandledCloseWritableHandle.qlref
was failing.
This commit is contained in:
Owen Mansel-Chan
2023-11-28 15:47:55 +00:00
parent 5267671b15
commit b4743155f6
2 changed files with 9 additions and 8 deletions

View File

@@ -166,6 +166,13 @@ class SsaDefinition extends TSsaDefinition {
) { ) {
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
} }
/**
* Gets the first instruction that the value of this `SsaDefinition` can
* reach without passing through any other instructions, but possibly through
* phi nodes.
*/
IR::Instruction getAFirstUse() { firstUse(this, result) }
} }
/** /**
@@ -197,13 +204,6 @@ class SsaExplicitDefinition extends SsaDefinition, TExplicitDef {
override string prettyPrintDef() { result = "definition of " + this.getSourceVariable() } override string prettyPrintDef() { result = "definition of " + this.getSourceVariable() }
override Location getLocation() { result = this.getInstruction().getLocation() } override Location getLocation() { result = this.getInstruction().getLocation() }
/**
* Gets the first instruction that the value of this `SsaDefinition` can
* reach without passing through any other instructions, but possibly through
* phi nodes.
*/
IR::Instruction getAFirstUse() { firstUse(this, result) }
} }
/** Provides a helper predicate for working with explicit SSA definitions. */ /** Provides a helper predicate for working with explicit SSA definitions. */

View File

@@ -83,7 +83,8 @@ predicate basicLocalFlowStep(Node nodeFrom, Node nodeTo) {
) )
or or
// SSA defn -> first SSA use // SSA defn -> first SSA use
exists(SsaExplicitDefinition pred, IR::Instruction succ | succ = pred.getAFirstUse() | exists(SsaDefinition pred, IR::Instruction succ | succ = pred.getAFirstUse() |
(pred instanceof SsaExplicitDefinition or pred instanceof SsaVariableCapture) and
nodeFrom = ssaNode(pred.getVariable()) and nodeFrom = ssaNode(pred.getVariable()) and
nodeTo = instructionNode(succ) nodeTo = instructionNode(succ)
) )