Debian Codegraph @

go/callgraph/vta/testdata/src/returns.go

raw symbols SCIP
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
7 package testdata
8
9 type I interface{}
10
11 func Bar(ii I) (I, I) {
12 return Foo(ii)
13 }
14
15 func Foo(iii I) (I, I) {
16 return iii, iii
17 }
18
19 func Do(j I) *I {
20 return &j
21 }
22
23 func 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) -> Return(Foo[0]), Return(Foo[1])
55 // Local(t1) -> Return(Baz[0])
56 // Local(t1) -> Return(Bar[0])
57 // Local(t2) -> Return(Bar[1])
58 // Local(t0) -> Return(Do[0])
59 // Return(Do[0]) -> Local(t1)