Skip to content

Commit f0427ad

Browse files
committed
Preemptively change toString() for SSA classes
1 parent 8d456df commit f0427ad

33 files changed

Lines changed: 671 additions & 673 deletions

File tree

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class SsaVariable extends TSsaDefinition {
8585
IR::Instruction getAUse() { result = this.getAUseIn(_) }
8686

8787
/** Gets a textual representation of this element. */
88-
string toString() { result = this.getDefinition().prettyPrintRef() }
88+
string toString() { result = this.getDefinition().toString() }
8989

9090
/** Gets the location of this SSA variable. */
9191
Location getLocation() { result = this.getDefinition().getLocation() }
@@ -203,7 +203,7 @@ class SsaExplicitDefinition extends SsaDefinition, TExplicitDef {
203203
)
204204
}
205205

206-
override string prettyPrintDef() { result = "definition of " + this.getSourceVariable() }
206+
override string prettyPrintDef() { result = "SSA def(" + this.getSourceVariable() + ")" }
207207

208208
override Location getLocation() { result = this.getInstruction().getLocation() }
209209
}
@@ -254,7 +254,7 @@ class SsaVariableCapture extends SsaImplicitDefinition, TCapture {
254254

255255
override string getKind() { result = "capture" }
256256

257-
override string prettyPrintDef() { result = "capture variable " + this.getSourceVariable() }
257+
override string prettyPrintDef() { result = "SSA def(" + this.getSourceVariable() + ")" }
258258

259259
override Location getLocation() {
260260
exists(ReachableBasicBlock bb, int i | this.definesAt(bb, i, _) |
@@ -300,9 +300,7 @@ class SsaPhiNode extends SsaPseudoDefinition, TPhi {
300300

301301
override string getKind() { result = "phi" }
302302

303-
override string prettyPrintDef() {
304-
result = this.getSourceVariable() + " = phi(" + this.ppInputs() + ")"
305-
}
303+
override string prettyPrintDef() { result = "SSA phi(" + this.getSourceVariable() + ")" }
306304

307305
override Location getLocation() { result = this.getBasicBlock().getLocation() }
308306
}

go/ql/test/example-tests/snippets/typeinfo.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
| file://:0:0:0:0 | [summary param] -1 in Clone |
33
| file://:0:0:0:0 | [summary param] -1 in Write |
44
| file://:0:0:0:0 | [summary param] -1 in WriteProxy |
5+
| main.go:18:12:18:14 | SSA def(req) |
56
| main.go:18:12:18:14 | argument corresponding to req |
6-
| main.go:18:12:18:14 | definition of req |
77
| main.go:20:5:20:7 | req |
88
| main.go:20:5:20:7 | req [postupdate] |

go/ql/test/experimental/CWE-522-DecompressionBombs/DecompressionBombs.expected

Lines changed: 97 additions & 97 deletions
Large diffs are not rendered by default.

go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ edges
1010
| WrongUsageOfUnsafe.go:166:33:166:57 | type conversion | WrongUsageOfUnsafe.go:166:16:166:58 | type conversion | provenance | |
1111
| WrongUsageOfUnsafe.go:189:31:189:55 | type conversion | WrongUsageOfUnsafe.go:189:16:189:56 | type conversion | provenance | |
1212
| WrongUsageOfUnsafe.go:211:31:211:60 | type conversion | WrongUsageOfUnsafe.go:211:16:211:61 | type conversion | provenance | |
13-
| WrongUsageOfUnsafe.go:227:31:227:55 | type conversion | WrongUsageOfUnsafe.go:236:21:236:23 | definition of req | provenance | |
14-
| WrongUsageOfUnsafe.go:236:21:236:23 | definition of req | WrongUsageOfUnsafe.go:243:9:243:27 | type conversion | provenance | |
13+
| WrongUsageOfUnsafe.go:227:31:227:55 | type conversion | WrongUsageOfUnsafe.go:236:21:236:23 | SSA def(req) | provenance | |
14+
| WrongUsageOfUnsafe.go:236:21:236:23 | SSA def(req) | WrongUsageOfUnsafe.go:243:9:243:27 | type conversion | provenance | |
1515
| WrongUsageOfUnsafe.go:256:28:256:52 | type conversion | WrongUsageOfUnsafe.go:256:16:256:53 | type conversion | provenance | |
1616
| WrongUsageOfUnsafe.go:274:25:274:49 | type conversion | WrongUsageOfUnsafe.go:274:16:274:50 | type conversion | provenance | |
1717
| WrongUsageOfUnsafe.go:292:23:292:47 | type conversion | WrongUsageOfUnsafe.go:292:16:292:48 | type conversion | provenance | |
@@ -39,7 +39,7 @@ nodes
3939
| WrongUsageOfUnsafe.go:211:16:211:61 | type conversion | semmle.label | type conversion |
4040
| WrongUsageOfUnsafe.go:211:31:211:60 | type conversion | semmle.label | type conversion |
4141
| WrongUsageOfUnsafe.go:227:31:227:55 | type conversion | semmle.label | type conversion |
42-
| WrongUsageOfUnsafe.go:236:21:236:23 | definition of req | semmle.label | definition of req |
42+
| WrongUsageOfUnsafe.go:236:21:236:23 | SSA def(req) | semmle.label | SSA def(req) |
4343
| WrongUsageOfUnsafe.go:243:9:243:27 | type conversion | semmle.label | type conversion |
4444
| WrongUsageOfUnsafe.go:256:16:256:53 | type conversion | semmle.label | type conversion |
4545
| WrongUsageOfUnsafe.go:256:28:256:52 | type conversion | semmle.label | type conversion |

go/ql/test/library-tests/semmle/go/concepts/Regexp/RegexpPattern.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
| stdlib.go:13:21:13:24 | "ab" | ab | stdlib.go:13:21:13:24 | "ab" |
44
| stdlib.go:15:26:15:39 | "[so]me\|regex" | [so]me\|regex | stdlib.go:15:2:15:40 | ... := ...[0] |
55
| stdlib.go:15:26:15:39 | "[so]me\|regex" | [so]me\|regex | stdlib.go:15:26:15:39 | "[so]me\|regex" |
6-
| stdlib.go:16:30:16:37 | "posix?" | posix? | stdlib.go:16:2:16:3 | definition of re |
6+
| stdlib.go:16:30:16:37 | "posix?" | posix? | stdlib.go:16:2:16:3 | SSA def(re) |
77
| stdlib.go:16:30:16:37 | "posix?" | posix? | stdlib.go:16:2:16:38 | ... = ...[0] |
88
| stdlib.go:16:30:16:37 | "posix?" | posix? | stdlib.go:16:30:16:37 | "posix?" |
99
| stdlib.go:16:30:16:37 | "posix?" | posix? | stdlib.go:17:2:17:3 | re |

go/ql/test/library-tests/semmle/go/dataflow/ExternalTaintFlow/srcs.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ invalidModelRow
2222
| test.go:187:24:187:31 | call to Src1 | qltest |
2323
| test.go:191:24:191:31 | call to Src1 | qltest |
2424
| test.go:201:10:201:28 | selection of SourceVariable | qltest |
25-
| test.go:208:15:208:17 | definition of src | qltest |
25+
| test.go:208:15:208:17 | SSA def(src) | qltest |

go/ql/test/library-tests/semmle/go/dataflow/ExternalValueFlow/srcs.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ invalidModelRow
2222
| test.go:187:24:187:31 | call to Src1 | qltest |
2323
| test.go:191:24:191:31 | call to Src1 | qltest |
2424
| test.go:209:10:209:28 | selection of SourceVariable | qltest |
25-
| test.go:216:15:216:17 | definition of src | qltest |
25+
| test.go:216:15:216:17 | SSA def(src) | qltest |

0 commit comments

Comments
 (0)