MCPcopy Index your code
hub / github.com/coder/coder / bodyUsesOuterStore

Function bodyUsesOuterStore

scripts/intxcheck/analyzer.go:216–269  ·  view source on GitHub ↗
(pass *analysis.Pass, body *ast.BlockStmt, outerStore outerStoreMatcher)

Source from the content-addressed store, hash-verified

214}
215
216func bodyUsesOuterStore(pass *analysis.Pass, body *ast.BlockStmt, outerStore outerStoreMatcher) bool {
217 outerStore = outerStore.withAliases(pass, body)
218
219 found := false
220 ast.Inspect(body, func(n ast.Node) bool {
221 if found {
222 return false
223 }
224
225 switch n := n.(type) {
226 case *ast.FuncLit:
227 return false
228 case *ast.GoStmt:
229 if kind, _ := classifyCall(pass, n.Call, outerStore); kind != misuseNone {
230 found = true
231 return false
232 }
233 if funcLit, ok := funcLitCall(n.Call); ok {
234 found = bodyUsesOuterStore(pass, funcLit.Body, outerStore)
235 return false
236 }
237 return true
238 case *ast.DeferStmt:
239 if kind, _ := classifyCall(pass, n.Call, outerStore); kind != misuseNone {
240 found = true
241 return false
242 }
243 if funcLit, ok := funcLitCall(n.Call); ok {
244 found = bodyUsesOuterStore(pass, funcLit.Body, outerStore)
245 return false
246 }
247 return true
248 }
249
250 call, ok := n.(*ast.CallExpr)
251 if !ok {
252 return true
253 }
254
255 kind, _ := classifyCall(pass, call, outerStore)
256 if kind != misuseNone {
257 found = true
258 return false
259 }
260 if funcLit, ok := funcLitCall(call); ok {
261 found = bodyUsesOuterStore(pass, funcLit.Body, outerStore)
262 if found {
263 return false
264 }
265 }
266 return true
267 })
268 return found
269}
270
271func resolveSamePackageCallee(pass *analysis.Pass, call *ast.CallExpr, ctx txContext, decls map[types.Object]*ast.FuncDecl) (*ast.FuncDecl, outerStoreMatcher, bool) {
272 switch fun := unparen(call.Fun).(type) {

Callers 1

inspectInTxBodyFunction · 0.85

Calls 3

classifyCallFunction · 0.85
funcLitCallFunction · 0.85
withAliasesMethod · 0.45

Tested by

no test coverage detected