GoPLS Viewer

Home|gopls/go/callgraph/vta/testdata/src/returns.go
1// Copyright 2021 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// go:build ignore
6
7package testdata
8
9type I interface{}
10
11func Bar(ii I) (II) {
12    return Foo(ii)
13}
14
15func Foo(iii I) (II) {
16    return iiiiii
17}
18
19func Do(j I) *I {
20    return &j
21}
22
23func Baz(i I) *I {
24    Bar(i)
25    return Do(i)
26}
27
28// Relevant SSA:
29// func Bar(ii I) (I, I):
30//   t0 = Foo(ii)
31//   t1 = extract t0 #0
32//   t2 = extract t0 #1
33//   return t1, t2
34//
35// func Foo(iii I) (I, I):
36//   return iii, iii
37//
38// func Do(j I) *I:
39//   t0 = new I (j)
40//   *t0 = j
41//   return t0
42//
43// func Baz(i I):
44//   t0 = Bar(i)
45//   t1 = Do(i)
46//   return t1
47
48// t0 and t1 in the last edge correspond to the nodes
49// of Do and Baz. This edge is induced by Do(i).
50
51// WANT:
52// Local(i) -> Local(ii), Local(j)
53// Local(ii) -> Local(iii)
54// Local(iii) -> Local(t0[0]), Local(t0[1])
55// Local(t1) -> Local(t0[0])
56// Local(t2) -> Local(t0[1])
57// Local(t0) -> Local(t1)
58
MembersX
Bar.ii
Foo.iii
Do.j
Members
X