golang.org/x/tools@v0.21.1-0.20240520172518-788d39e776b1/go/callgraph/vta/testdata/src/store.go (about) 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 // Tests graph creation for store/load and make instructions. 10 // Note that ssa package does not have a load instruction per 11 // se. Yet, one is encoded as a unary instruction with the 12 // * operator. 13 14 type A struct{} 15 16 type I interface{ foo() } 17 18 func (a A) foo() {} 19 20 func main() { 21 a := A{} 22 var i I 23 i = a 24 ii := &i 25 (*ii).foo() 26 } 27 28 // Relevant SSA: 29 // t0 = new I (i) 30 // t1 = make I <- A (struct{}{}:A) A -> t1 31 // *t0 = t1 t1 -> t0 32 // t2 = *t0 t0 -> t2 33 // t3 = invoke t2.foo() 34 // return 35 36 // WANT: 37 // Constant(testdata.A) -> Local(t1) 38 // Local(t1) -> Local(t0) 39 // Local(t0) -> Local(t2)