Skip to content

Commit f74913a

Browse files
authored
Merge pull request #20411 from owen-mc/go/improve-pun-tests
Go: improve post-update node tests
2 parents 59fc7aa + d9e7c89 commit f74913a

File tree

3 files changed

+39
-16
lines changed

3 files changed

+39
-16
lines changed
Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
| test.go:19:2:19:2 | definition of a |
2-
| test.go:20:11:20:14 | &... |
3-
| test.go:20:12:20:14 | selection of b |
4-
| test.go:21:2:21:5 | selection of bs |
5-
| test.go:21:2:21:8 | index expression |
6-
| test.go:21:17:21:20 | &... |
7-
| test.go:21:18:21:20 | struct literal |
8-
| test.go:22:2:22:5 | selection of bs |
9-
| test.go:22:2:22:8 | index expression |
10-
| test.go:22:2:22:13 | implicit dereference |
11-
| test.go:22:2:22:13 | selection of cptr |
12-
| test.go:23:2:23:7 | implicit dereference |
13-
| test.go:23:2:23:7 | selection of bptr |
14-
| test.go:23:2:23:12 | implicit dereference |
15-
| test.go:23:2:23:12 | selection of cptr |
1+
| file://:0:0:0:0 | [summary] to write: Argument[0] in copy | file://:0:0:0:0 | [summary param] 0 in copy |
2+
| test.go:22:2:22:2 | definition of a | test.go:23:2:23:2 | a |
3+
| test.go:22:2:22:2 | definition of a | test.go:24:2:24:2 | a |
4+
| test.go:22:2:22:2 | definition of a | test.go:25:2:25:2 | a |
5+
| test.go:22:2:22:2 | definition of a | test.go:26:2:26:2 | a |
6+
| test.go:22:2:22:2 | definition of a | test.go:29:6:29:6 | a |
7+
| test.go:22:2:22:2 | definition of a | test.go:30:7:30:7 | a |
8+
| test.go:22:2:22:2 | definition of a | test.go:35:4:35:4 | a |
9+
| test.go:22:2:22:2 | definition of a | test.go:36:5:36:5 | a |
10+
| test.go:23:11:23:14 | &... | test.go:23:11:23:14 | &... |
11+
| test.go:23:12:23:14 | selection of b | test.go:23:12:23:14 | selection of b |
12+
| test.go:24:2:24:5 | selection of bs | test.go:24:2:24:5 | selection of bs |
13+
| test.go:24:2:24:8 | index expression | test.go:24:2:24:8 | index expression |
14+
| test.go:24:17:24:20 | &... | test.go:24:17:24:20 | &... |
15+
| test.go:24:18:24:20 | struct literal | test.go:24:18:24:20 | struct literal |
16+
| test.go:25:2:25:5 | selection of bs | test.go:25:2:25:5 | selection of bs |
17+
| test.go:25:2:25:8 | index expression | test.go:25:2:25:8 | index expression |
18+
| test.go:25:2:25:13 | implicit dereference | test.go:25:2:25:13 | implicit dereference |
19+
| test.go:25:2:25:13 | selection of cptr | test.go:25:2:25:13 | selection of cptr |
20+
| test.go:26:2:26:7 | implicit dereference | test.go:26:2:26:7 | implicit dereference |
21+
| test.go:26:2:26:7 | selection of bptr | test.go:26:2:26:7 | selection of bptr |
22+
| test.go:26:2:26:12 | implicit dereference | test.go:26:2:26:12 | implicit dereference |
23+
| test.go:26:2:26:12 | selection of cptr | test.go:26:2:26:12 | selection of cptr |
24+
| test.go:28:2:28:2 | definition of c | test.go:29:2:29:2 | c |
25+
| test.go:28:2:28:2 | definition of c | test.go:30:2:30:2 | c |
26+
| test.go:28:7:28:10 | struct literal | test.go:28:7:28:10 | struct literal |

go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ type C struct {
44
field int
55
}
66

7+
func (c C) m(a A) {}
8+
func (c *C) mp(a A) {}
9+
710
type B struct {
811
cptr *C
912
}
@@ -22,4 +25,13 @@ func f() {
2225
a.bs[3].cptr.field = 100
2326
a.bptr.cptr.field = 101
2427

28+
c := C{0}
29+
c.m(a)
30+
c.mp(a)
31+
32+
// Indirect method calls - missing post-update nodes for the receivers
33+
f := c.m
34+
fp := c.mp
35+
f(a)
36+
fp(a)
2537
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import go
22

33
from DataFlow::PostUpdateNode pun
4-
select pun
4+
select pun, pun.getPreUpdateNode()

0 commit comments

Comments
 (0)