Documentation
¶
Overview ¶
Package analysis loads Go packages, builds the SSA program, constructs the call graph, and pre-computes loop information that mem-guard heuristics consume.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnalyzedFunctions ¶
AnalyzedFunctions returns all functions in the analyzed packages, including methods on named types and anonymous closures defined inside them.
Types ¶
type Boundedness ¶
type Boundedness int
Boundedness classifies whether a loop is provably bounded.
const ( BoundUnknown Boundedness = iota // assume unbounded (fail-open) BoundBounded // provably bounded BoundUnbounded // provably unbounded )
func (Boundedness) String ¶
func (b Boundedness) String() string
type Context ¶
type Context struct {
Prog *ssa.Program
Packages []*ssa.Package
CallGraph *callgraph.Graph
LoopInfo *LoopAnalysis
Fset *token.FileSet
}
Context bundles everything a heuristic needs to inspect a program.
type LoopAnalysis ¶
LoopAnalysis stores pre-computed loop information for all functions.
func AnalyzeLoops ¶
func AnalyzeLoops(prog *ssa.Program, pkgs []*ssa.Package) *LoopAnalysis
AnalyzeLoops detects and classifies all natural loops in the given packages.
func (*LoopAnalysis) InLoop ¶
func (la *LoopAnalysis) InLoop(fn *ssa.Function, block *ssa.BasicBlock) []*LoopDesc
InLoop returns the loops that contain the given block in the given function.
type LoopDesc ¶
type LoopDesc struct {
Header *ssa.BasicBlock
BackEdges []*ssa.BasicBlock // blocks with back-edges to Header
Body blockSet // all blocks in the loop body
Bounded Boundedness
Kind string // human-readable classification
}
LoopDesc describes a single natural loop detected in the CFG.
func (*LoopDesc) HasExitFromBlock ¶
func (loop *LoopDesc) HasExitFromBlock(block *ssa.BasicBlock) bool
HasExitFromBlock checks if there's a conditional exit path from the given block that leads outside the loop. Used to check if a break/return guards a growth site.
func (*LoopDesc) IsUnbounded ¶
IsUnbounded returns true if the loop is not provably bounded.