GoPLS Viewer

Home|gopls/go/callgraph/vta/testdata/src/callgraph_nested_ptr.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    Foo()
11}
12
13type A struct{}
14
15func (a AFoo() {}
16
17type B struct{}
18
19func (b BFoo() {}
20
21func Do(i **I) {
22    **i = A{}
23}
24
25func Bar(i **I) {
26    **i = B{}
27}
28
29func Baz(i **I) {
30    Do(i)
31    (**i).Foo()
32}
33
34// Relevant SSA:
35//  func Baz(i **I):
36//   t0 = Do(i)
37//   t1 = *i
38//   t2 = *t1
39//   t3 = invoke t2.Foo()
40//   return
41
42//  func Bar(i **I):
43//   t0 = *i
44//   t1 = local B (complit)
45//   t2 = *t1
46//   t3 = make I <- B (t2)
47//   *t0 = t3
48//   return
49
50// func Do(i **I):
51//   t0 = *i
52//   t1 = local A (complit)
53//   t2 = *t1
54//   t3 = make I <- A (t2)
55//   *t0 = t3
56//   return
57
58// WANT:
59// Baz: Do(i) -> Do; invoke t2.Foo() -> A.Foo, B.Foo
60
MembersX
Baz.i
Do.i
Bar
Bar.i
Members
X