Debian Codegraph @

internal/refactor/inline/calleefx.go

raw symbols SCIP
1 // Copyright 2023 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 package inlinescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/
6
7 // This file defines the analysis of callee effects.
8
9 import (
10 "go/astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/"
11 "go/tokenscip-go gomod github.com/golang/go/src go1.25.0 `go/token`/"
12 "go/typesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/"
13
14 "golang.org/x/tools/internal/typesinternalscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/typesinternal`/"
15 )
16
17 const (
18 rinfscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/rinf. = -1 // R∞: arbitrary read from memory
19 winfscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/winf. = -2 // W∞: arbitrary write to memory (or unknown control)
20 )
21
22 // calleefx returns a list of parameter indices indicating the order
23 // in which parameters are first referenced during evaluation of the
24 // callee, relative both to each other and to other effects of the
25 // callee (if any), such as arbitrary reads (rinf) and arbitrary
26 // effects (winf), including unknown control flow. Each parameter
27 // that is referenced appears once in the list.
28 //
29 // For example, the effects list of this function:
30 //
31 // func f(x, y, z int) int {
32 // return y + x + g() + z
33 // }
34 //
35 // is [1 0 -2 2], indicating reads of y and x, followed by the unknown
36 // effects of the g() call, and finally the read of parameter z. This
37 // information is used during inlining to ascertain when it is safe
38 // for parameter references to be replaced by their corresponding
39 // argument expressions. Such substitutions are permitted only when
40 // they do not cause "write" operations (those with effects) to
41 // commute with "read" operations (those that have no effect but are
42 // not pure). Impure operations may be reordered with other impure
43 // operations, and pure operations may be reordered arbitrarily.
44 //
45 // The analysis ignores the effects of runtime panics, on the
46 // assumption that well-behaved programs shouldn't encounter them.
47 func calleefxscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/calleefx().(info *typesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/.Infoscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Info#, body *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.BlockStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/BlockStmt#, paramInfos map[*typesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/.Varscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Var#]*paramInfoscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/paramInfo#) []int {
48 // This traversal analyzes the callee's statements (in syntax
49 // form, though one could do better with SSA) to compute the
50 // sequence of events of the following kinds:
51 //
52 // 1 read of a parameter variable.
53 // 2. reads from other memory.
54 // 3. writes to memory
55
56 var effects []int // indices of parameters, or rinf/winf (-ve)
57 seen := make(map[int]bool)
58 effect := func(i int) {
59 if !seen[i] {
60 seen[i] = true
61 effects = append(effects, i)
62 }
63 }
64
65 // unknown is called for statements of unknown effects (or control).
66 unknown := func() {
67 effect(winfscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/winf.)
68
69 // Ensure that all remaining parameters are "seen"
70 // after we go into the unknown (unless they are
71 // unreferenced by the function body). This lets us
72 // not bother implementing the complete traversal into
73 // control structures.
74 //
75 // TODO(adonovan): add them in a deterministic order.
76 // (This is not a bug but determinism is good.)
77 for _, pinfo := range paramInfos {
78 if !pinfo.IsResultscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/paramInfo#IsResult. && len(pinfo.Refsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/paramInfo#Refs.) > 0 {
79 effect(pinfo.Indexscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/paramInfo#Index.)
80 }
81 }
82 }
83
84 var visitExpr func(n astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.Exprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/Expr#)
85 var visitStmt func(n astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.Stmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/Stmt#) bool
86 visitExpr = func(n astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.Exprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/Expr#) {
87 switch n := n.(type) {
88 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.Identscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/Ident#:
89 if v, ok := info.Usesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Info#Uses.[n].(*typesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/.Varscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Var#); ok && !v.IsFieldscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Var#IsField().() {
90 // Use of global?
91 if v.Parentscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/object#Parent().() == v.Pkgscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/object#Pkg().().Scopescip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Package#Scope().() {
92 effect(rinfscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/rinf.) // read global var
93 }
94
95 // Use of parameter?
96 if pinfo, ok := paramInfos[v]; ok && !pinfo.IsResultscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/paramInfo#IsResult. {
97 effect(pinfo.Indexscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/paramInfo#Index.) // read parameter var
98 }
99
100 // Use of local variables is ok.
101 }
102
103 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.BasicLitscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/BasicLit#:
104 // no effect
105
106 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.FuncLitscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/FuncLit#:
107 // A func literal has no read or write effect
108 // until called, and (most) function calls are
109 // considered to have arbitrary effects.
110 // So, no effect.
111
112 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.CompositeLitscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/CompositeLit#:
113 for _, elt := range n.Eltsscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/CompositeLit#Elts. {
114 visitExpr(elt) // note: visits KeyValueExpr
115 }
116
117 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.ParenExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/ParenExpr#:
118 visitExpr(n.Xscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/ParenExpr#X.)
119
120 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.SelectorExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SelectorExpr#:
121 if seln, ok := info.Selectionsscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Info#Selections.[n]; ok {
122 visitExpr(n.Xscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SelectorExpr#X.)
123
124 // See types.SelectionKind for background.
125 switch seln.Kindscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Selection#Kind().() {
126 case typesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/.MethodExprscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/MethodExpr.:
127 // A method expression T.f acts like a
128 // reference to a func decl,
129 // so it doesn't read x until called.
130
131 case typesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/.MethodValscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/MethodVal., typesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/.FieldValscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/FieldVal.:
132 // A field or method value selection x.f
133 // reads x if the selection indirects a pointer.
134
135 if indirectSelectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/indirectSelection().(seln) {
136 effect(rinfscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/rinf.)
137 }
138 }
139 } else {
140 // qualified identifier: treat like unqualified
141 visitExpr(n.Selscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SelectorExpr#Sel.)
142 }
143
144 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.IndexExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/IndexExpr#:
145 if tv := info.Typesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Info#Types.[n.Indexscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/IndexExpr#Index.]; tv.IsTypescip-go gomod github.com/golang/go/src go1.25.0 `go/types`/TypeAndValue#IsType().() {
146 // no effect (G[T] instantiation)
147 } else {
148 visitExpr(n.Xscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/IndexExpr#X.)
149 visitExpr(n.Indexscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/IndexExpr#Index.)
150 switch tv.Typescip-go gomod github.com/golang/go/src go1.25.0 `go/types`/TypeAndValue#Type..Underlyingscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Type#Underlying().().(type) {
151 case *typesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/.Slicescip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Slice#, *typesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/.Pointerscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Pointer#: // []T, *[n]T (not string, [n]T)
152 effect(rinfscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/rinf.) // indirect read of slice/array element
153 }
154 }
155
156 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.IndexListExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/IndexListExpr#:
157 // no effect (M[K,V] instantiation)
158
159 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.SliceExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SliceExpr#:
160 visitExpr(n.Xscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SliceExpr#X.)
161 visitExpr(n.Lowscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SliceExpr#Low.)
162 visitExpr(n.Highscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SliceExpr#High.)
163 visitExpr(n.Maxscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SliceExpr#Max.)
164
165 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.TypeAssertExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/TypeAssertExpr#:
166 visitExpr(n.Xscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/TypeAssertExpr#X.)
167
168 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.CallExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/CallExpr#:
169 if info.Typesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Info#Types.[n.Funscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/CallExpr#Fun.].IsTypescip-go gomod github.com/golang/go/src go1.25.0 `go/types`/TypeAndValue#IsType().() {
170 // conversion T(x)
171 visitExpr(n.Argsscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/CallExpr#Args.[0])
172 } else {
173 // call f(args)
174 visitExpr(n.Funscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/CallExpr#Fun.)
175 for i, arg := range n.Argsscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/CallExpr#Args. {
176 if i == 0 && info.Typesscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Info#Types.[arg].IsTypescip-go gomod github.com/golang/go/src go1.25.0 `go/types`/TypeAndValue#IsType().() {
177 continue // new(T), make(T, n)
178 }
179 visitExpr(arg)
180 }
181
182 // The pure built-ins have no effects beyond
183 // those of their operands (not even memory reads).
184 // All other calls have unknown effects.
185 if !typesinternalscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/typesinternal`/.CallsPureBuiltinscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/typesinternal`/CallsPureBuiltin().(info, n) {
186 unknown() // arbitrary effects
187 }
188 }
189
190 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.StarExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/StarExpr#:
191 visitExpr(n.Xscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/StarExpr#X.)
192 effect(rinfscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/refactor/inline`/rinf.) // *ptr load or store depends on state of heap
193
194 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.UnaryExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/UnaryExpr#: // + - ! ^ & ~ <-
195 visitExpr(n.Xscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/UnaryExpr#X.)
196 if n.Opscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/UnaryExpr#Op. == tokenscip-go gomod github.com/golang/go/src go1.25.0 `go/token`/.ARROWscip-go gomod github.com/golang/go/src go1.25.0 `go/token`/ARROW. {
197 unknown() // effect: channel receive
198 }
199
200 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.BinaryExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/BinaryExpr#:
201 visitExpr(n.Xscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/BinaryExpr#X.)
202 visitExpr(n.Yscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/BinaryExpr#Y.)
203
204 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.KeyValueExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/KeyValueExpr#:
205 visitExpr(n.Keyscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/KeyValueExpr#Key.) // may be a struct field
206 visitExpr(n.Valuescip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/KeyValueExpr#Value.)
207
208 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.BadExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/BadExpr#:
209 // no effect
210
211 case nil:
212 // optional subtree
213
214 default:
215 // type syntax: unreachable given traversal
216 panic(n)
217 }
218 }
219
220 // visitStmt's result indicates the continuation:
221 // false for return, true for the next statement.
222 //
223 // We could treat return as an unknown, but this way
224 // yields definite effects for simple sequences like
225 // {S1; S2; return}, so unreferenced parameters are
226 // not spuriously added to the effects list, and thus
227 // not spuriously disqualified from elimination.
228 visitStmt = func(n astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.Stmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/Stmt#) bool {
229 switch n := n.(type) {
230 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.DeclStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/DeclStmt#:
231 decl := n.Declscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/DeclStmt#Decl..(*astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.GenDeclscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/GenDecl#)
232 for _, spec := range decl.Specsscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/GenDecl#Specs. {
233 switch spec := spec.(type) {
234 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.ValueSpecscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/ValueSpec#:
235 for _, v := range spec.Valuesscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/ValueSpec#Values. {
236 visitExpr(v)
237 }
238
239 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.TypeSpecscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/TypeSpec#:
240 // no effect
241 }
242 }
243
244 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.LabeledStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/LabeledStmt#:
245 return visitStmt(n.Stmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/LabeledStmt#Stmt.)
246
247 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.ExprStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/ExprStmt#:
248 visitExpr(n.Xscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/ExprStmt#X.)
249
250 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.SendStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SendStmt#:
251 visitExpr(n.Chanscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SendStmt#Chan.)
252 visitExpr(n.Valuescip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SendStmt#Value.)
253 unknown() // effect: channel send
254
255 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.IncDecStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/IncDecStmt#:
256 visitExpr(n.Xscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/IncDecStmt#X.)
257 unknown() // effect: variable increment
258
259 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.AssignStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/AssignStmt#:
260 for _, lhs := range n.Lhsscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/AssignStmt#Lhs. {
261 visitExpr(lhs)
262 }
263 for _, rhs := range n.Rhsscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/AssignStmt#Rhs. {
264 visitExpr(rhs)
265 }
266 for _, lhs := range n.Lhsscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/AssignStmt#Lhs. {
267 id, _ := lhs.(*astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.Identscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/Ident#)
268 if id != nil && id.Namescip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/Ident#Name. == "_" {
269 continue // blank assign has no effect
270 }
271 if n.Tokscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/AssignStmt#Tok. == tokenscip-go gomod github.com/golang/go/src go1.25.0 `go/token`/.DEFINEscip-go gomod github.com/golang/go/src go1.25.0 `go/token`/DEFINE. && id != nil && info.Defsscip-go gomod github.com/golang/go/src go1.25.0 `go/types`/Info#Defs.[id] != nil {
272 continue // new var declared by := has no effect
273 }
274 unknown() // assignment to existing var
275 break
276 }
277
278 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.GoStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/GoStmt#:
279 visitExpr(n.Callscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/GoStmt#Call..Funscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/CallExpr#Fun.)
280 for _, arg := range n.Callscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/GoStmt#Call..Argsscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/CallExpr#Args. {
281 visitExpr(arg)
282 }
283 unknown() // effect: create goroutine
284
285 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.DeferStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/DeferStmt#:
286 visitExpr(n.Callscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/DeferStmt#Call..Funscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/CallExpr#Fun.)
287 for _, arg := range n.Callscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/DeferStmt#Call..Argsscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/CallExpr#Args. {
288 visitExpr(arg)
289 }
290 unknown() // effect: push defer
291
292 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.ReturnStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/ReturnStmt#:
293 for _, res := range n.Resultsscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/ReturnStmt#Results. {
294 visitExpr(res)
295 }
296 return false
297
298 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.BlockStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/BlockStmt#:
299 for _, stmt := range n.Listscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/BlockStmt#List. {
300 if !visitStmt(stmt) {
301 return false
302 }
303 }
304
305 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.BranchStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/BranchStmt#:
306 unknown() // control flow
307
308 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.IfStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/IfStmt#:
309 visitStmt(n.Initscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/IfStmt#Init.)
310 visitExpr(n.Condscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/IfStmt#Cond.)
311 unknown() // control flow
312
313 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.SwitchStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SwitchStmt#:
314 visitStmt(n.Initscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SwitchStmt#Init.)
315 visitExpr(n.Tagscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SwitchStmt#Tag.)
316 unknown() // control flow
317
318 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.TypeSwitchStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/TypeSwitchStmt#:
319 visitStmt(n.Initscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/TypeSwitchStmt#Init.)
320 visitStmt(n.Assignscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/TypeSwitchStmt#Assign.)
321 unknown() // control flow
322
323 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.SelectStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/SelectStmt#:
324 unknown() // control flow
325
326 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.ForStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/ForStmt#:
327 visitStmt(n.Initscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/ForStmt#Init.)
328 visitExpr(n.Condscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/ForStmt#Cond.)
329 unknown() // control flow
330
331 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.RangeStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/RangeStmt#:
332 visitExpr(n.Xscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/RangeStmt#X.)
333 unknown() // control flow
334
335 case *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.EmptyStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/EmptyStmt#, *astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.BadStmtscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/BadStmt#:
336 // no effect
337
338 case nil:
339 // optional subtree
340
341 default:
342 panic(n)
343 }
344 return true
345 }
346 visitStmt(body)
347
348 return effects
349 }