Skip to content

Commit cb59053

Browse files
committed
Fix compiler errors
1 parent 341354f commit cb59053

File tree

2 files changed

+20
-38
lines changed

2 files changed

+20
-38
lines changed

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

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ private predicate unresolvedIdentifier(Ident id, string name) {
6464
* An SSA variable.
6565
*/
6666
class SsaVariable extends Definition {
67-
/** Gets the source variable corresponding to this SSA variable. */
68-
override SsaSourceVariable getSourceVariable() { this.definesAt(result, _, _) }
69-
7067
/** Gets the (unique) definition of this SSA variable. */
7168
SsaDefinition getDefinition() { result = this }
7269

@@ -85,21 +82,17 @@ class SsaVariable extends Definition {
8582
/** Gets a use that refers to this SSA variable. */
8683
IR::Instruction getAUse() { result = this.getAUseIn(_) }
8784

88-
/**
89-
* Gets a textual representation of this element.
90-
*
91-
* The format is `kind@LINE:COL`, where `kind` is one of `def`, `capture`, or `phi`.
92-
*/
93-
override string toString() {
94-
exists(Location loc | loc = this.(SsaDefinition).getLocation() |
95-
result =
96-
this.(SsaDefinition).getKind() + "@" + loc.getStartLine() + ":" + loc.getStartColumn()
97-
)
98-
}
99-
100-
/** Gets the location of this SSA variable. */
101-
override Location getLocation() { result = this.(SsaDefinition).getLocation() }
102-
85+
// /**
86+
// * Gets a textual representation of this element.
87+
// *
88+
// * The format is `kind@LINE:COL`, where `kind` is one of `def`, `capture`, or `phi`.
89+
// */
90+
// override string toString() {
91+
// exists(Location loc | loc = this.(SsaDefinition).getLocation() |
92+
// result =
93+
// this.(SsaDefinition).getKind() + "@" + loc.getStartLine() + ":" + loc.getStartColumn()
94+
// )
95+
// }
10396
/**
10497
* DEPRECATED: Use `getLocation()` instead.
10598
*
@@ -123,9 +116,6 @@ class SsaDefinition extends Definition {
123116
/** Gets the SSA variable defined by this definition. */
124117
SsaVariable getVariable() { result = this }
125118

126-
/** Gets the source variable defined by this definition. */
127-
override SsaSourceVariable getSourceVariable() { this.definesAt(result, _, _) }
128-
129119
/** Gets the innermost function or file to which this SSA definition belongs. */
130120
ControlFlow::Root getRoot() { result = this.getBasicBlock().getScope() }
131121

@@ -180,8 +170,7 @@ class SsaExplicitDefinition extends SsaDefinition, WriteDefinition {
180170
IR::Instruction getRhs() { this.getInstruction().writes(_, result) }
181171

182172
override string getKind() { result = "def" }
183-
184-
override string toString() { result = "definition of " + this.getSourceVariable() }
173+
// override string toString() { result = "definition of " + this.getSourceVariable() }
185174
}
186175

187176
/** Provides a helper predicate for working with explicit SSA definitions. */
@@ -195,9 +184,7 @@ module SsaExplicitDefinition {
195184
/**
196185
* An SSA definition that does not correspond to an explicit variable definition.
197186
*/
198-
abstract class SsaImplicitDefinition extends SsaDefinition {
199-
override Location getLocation() { result = this.getBasicBlock().getLocation() }
200-
}
187+
abstract class SsaImplicitDefinition extends SsaDefinition { }
201188

202189
/**
203190
* An SSA definition representing the capturing of an SSA-convertible variable
@@ -207,15 +194,8 @@ abstract class SsaImplicitDefinition extends SsaDefinition {
207194
* at any function call that may affect the value of the variable.
208195
*/
209196
class SsaVariableCapture extends SsaImplicitDefinition, UncertainWriteDefinition {
210-
override Location getLocation() {
211-
exists(BasicBlock bb, int i | this.definesAt(_, bb, i) |
212-
result = bb.getNode(i).getLocation()
213-
)
214-
}
215-
216197
override string getKind() { result = "capture" }
217-
218-
override string toString() { result = "capture variable " + this.getSourceVariable() }
198+
// override string toString() { result = "capture variable " + this.getSourceVariable() }
219199
}
220200

221201
/**
@@ -247,10 +227,9 @@ class SsaPhiNode extends SsaPseudoDefinition, PhiNode {
247227
override SsaVariable getAnInput() { phiHasInputFromBlock(this, result, _) }
248228

249229
override string getKind() { result = "phi" }
250-
251-
override string toString() {
252-
result = this.getSourceVariable() + " = phi(" + this.ppInputs() + ")"
253-
}
230+
// override string toString() {
231+
// result = this.getSourceVariable() + " = phi(" + this.ppInputs() + ")"
232+
// }
254233
}
255234

256235
/**

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ private module Internal {
7676
any(IR::Instruction def | def.writes(v, _)).getRoot() != v.getDeclaringFunction()
7777
}
7878

79+
cached
7980
module SsaInput implements SsaImplCommon::InputSig<Location, BasicBlock> {
8081
class SourceVariable = SsaSourceVariable;
8182

@@ -85,6 +86,7 @@ private module Internal {
8586
*
8687
* Certain writes are explicit definitions; uncertain writes are captures.
8788
*/
89+
cached
8890
predicate variableWrite(BasicBlock bb, int i, SourceVariable v, boolean certain) {
8991
defAt(bb, i, v) and certain = true
9092
or
@@ -99,6 +101,7 @@ private module Internal {
99101
* variables are included in the SSA graph even when the variable is not
100102
* locally read in the declaring function (but may be read by a nested function).
101103
*/
104+
cached
102105
predicate variableRead(BasicBlock bb, int i, SourceVariable v, boolean certain) {
103106
useAt(bb, i, v) and certain = true
104107
or

0 commit comments

Comments
 (0)