aboutsummaryrefslogtreecommitdiff
path: root/go/callgraph/vta/testdata/src/callgraph_ho.go
blob: 0e5fa0d26a8fb1e08f894f3006bbbf9a11e69c8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// go:build ignore

package testdata

func Foo() {}

func Do(b bool) func() {
	if b {
		return Foo
	}
	return func() {}
}

func Finish(h func()) {
	h()
}

func Baz(b bool) {
	Finish(Do(b))
}

// Relevant SSA:
// func Baz(b bool):
//   t0 = Do(b)
//   t1 = Finish(t0)
//   return

// func Do(b bool) func():
//   if b goto 1 else 2
//  1:
//   return Foo
//  2:
//   return Do$1

// func Finish(h func()):
//   t0 = h()
//   return

// WANT:
// Baz: Do(b) -> Do; Finish(t0) -> Finish
// Finish: h() -> Do$1, Foo