Documentation
¶
Overview ¶
Package concutils provides shared utilities for detecting and analyzing Go concurrency primitives (sync.Mutex, sync.WaitGroup, channels) in source code. It is used as a foundation by all gostall analyzers.
Index ¶
- func Deref(t types.Type) types.Type
- func ImportsSyncPackage(pkg *types.Package) bool
- func IsInGoStmt(stack []ast.Node) bool
- func IsMutexType(info *types.Info, expr ast.Expr) bool
- func IsSyncMethod(info *types.Info, call *ast.CallExpr, typeName, methodName string) bool
- func IsWaitGroupType(info *types.Info, expr ast.Expr) bool
- func ResolveAddDelta(info *types.Info, call *ast.CallExpr) int
- func ResolveExprID(info *types.Info, expr ast.Expr) string
- type ChanOp
- type LockOp
- type WGOp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ImportsSyncPackage ¶
ImportsSyncPackage reports whether pkg directly imports "sync". Analyzers use this as an early-exit optimization.
func IsInGoStmt ¶
IsInGoStmt reports whether any ancestor in the AST stack is a *ast.GoStmt.
func IsMutexType ¶
IsMutexType reports whether the type of expr is sync.Mutex, sync.RWMutex, or a struct that embeds one of them (supporting s.Lock() via promotion).
func IsSyncMethod ¶
IsSyncMethod checks whether call targets typeName.methodName from the "sync" package.
func IsWaitGroupType ¶
IsWaitGroupType reports whether the receiver of expr is sync.WaitGroup.
func ResolveAddDelta ¶
ResolveAddDelta extracts the integer constant from a wg.Add(n) call. Returns 0 if the argument is not a compile-time constant.
func ResolveExprID ¶
ResolveExprID produces a best-effort stable string identifier for an expression. It handles identifiers, selectors (s.mu), dereferences (*p), and index expressions.
Limitation: array/slice index expressions are collapsed to "[i]", so arr[0].mu and arr[1].mu produce the same ID. This is a known trade-off for Phase 1; full points-to analysis is deferred to Phase 2.
Types ¶
type ChanOp ¶
type ChanOp struct {
Node ast.Node
ChanID string
IsSend bool
InGo bool // true if nested inside a go statement
}
ChanOp represents a channel send or receive operation.
type LockOp ¶
type LockOp struct {
Call *ast.CallExpr
MutexID string
IsLock bool // true for Lock/RLock, false for Unlock/RUnlock
IsRead bool // true for RLock/RUnlock
Pos token.Pos // position of the call expression
}
LockOp represents a mutex lock or unlock operation found in source code.