golang.org/x/tools@v0.21.1-0.20240520172518-788d39e776b1/go/callgraph/vta/testdata/src/store_load_alias.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 type A struct{} 10 11 func (a A) foo() {} 12 13 type I interface{ foo() } 14 15 func Baz(i I) { 16 j := &i 17 k := &j 18 **k = A{} 19 i.foo() 20 (**k).foo() 21 } 22 23 // Relevant SSA: 24 // func Baz(i I): 25 // t0 = new I (i) 26 // *t0 = i 27 // t1 = new *I (j) 28 // *t1 = t0 29 // t2 = *t1 30 // t3 = make I <- A (struct{}{}:A) I 31 // *t2 = t3 32 // t4 = *t0 33 // t5 = invoke t4.foo() 34 // t6 = *t1 35 // t7 = *t6 36 // t8 = invoke t7.foo() 37 38 // Flow chain showing that A reaches i.foo(): 39 // Constant(A) -> t3 -> t2 <-> PtrInterface(I) <-> t0 -> t4 40 // Flow chain showing that A reaches (**k).foo(): 41 // Constant(A) -> t3 -> t2 <-> PtrInterface(I) <-> t6 -> t7 42 43 // WANT: 44 // Local(i) -> Local(t0) 45 // Local(t0) -> Local(t4), PtrInterface(testdata.I) 46 // PtrInterface(testdata.I) -> Local(t0), Local(t2), Local(t6) 47 // Local(t2) -> PtrInterface(testdata.I) 48 // Constant(testdata.A) -> Local(t3) 49 // Local(t3) -> Local(t2) 50 // Local(t6) -> Local(t7), PtrInterface(testdata.I)