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 = local A (complit) |
31 | // t4 = *t3 |
32 | // t5 = make I <- A (t4) |
33 | // *t2 = t5 |
34 | // t6 = *t0 |
35 | // t7 = invoke t6.foo() |
36 | // t8 = *t1 |
37 | // t9 = *t8 |
38 | // t10 = invoke t9.foo() |
39 | |
40 | // Flow chain showing that A reaches i.foo(): |
41 | // t4 (A) -> t5 -> t2 <-> PtrInterface(I) <-> t0 -> t6 |
42 | // Flow chain showing that A reaches (**k).foo(): |
43 | // t4 (A) -> t5 -> t2 <-> PtrInterface(I) <-> t8 -> t9 |
44 | |
45 | // WANT: |
46 | // Local(i) -> Local(t0) |
47 | // Local(t0) -> Local(t6), PtrInterface(testdata.I) |
48 | // PtrInterface(testdata.I) -> Local(t0), Local(t2), Local(t8) |
49 | // Local(t2) -> PtrInterface(testdata.I) |
50 | // Local(t4) -> Local(t5) |
51 | // Local(t5) -> Local(t2) |
52 | // Local(t8) -> Local(t9), PtrInterface(testdata.I) |
53 |
Members