ssautil

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package ssautil contains shared helpers for SSA-backed analyzers. Its API is unsupported and may change without notice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AliasesValue

func AliasesValue(value, target ssa.Value) bool

AliasesValue reports conservative SSA identity through common conversion and storage forms.

func CallName

func CallName(common *ssa.CallCommon) string

CallName returns statically known method, function, or builtin name.

func CallPackage

func CallPackage(common *ssa.CallCommon) string

CallPackage returns statically known package path for a call.

func CallReceiver

func CallReceiver(common *ssa.CallCommon) ssa.Value

CallReceiver returns receiver value for method calls and invocations.

func CallReturnsDeferredCleanup

func CallReturnsDeferredCleanup(instruction ssa.Instruction, value ssa.Value) bool

CallReturnsDeferredCleanup reports whether a call consumes value and one of its function results is subsequently deferred by the caller.

func CallTransfersValueToField

func CallTransfersValueToField(instruction ssa.Instruction, value ssa.Value) bool

CallTransfersValueToField reports whether a call consumes value and stores its result in a struct field, transferring cleanup to the receiving owner.

func CapturedBindingAliases

func CapturedBindingAliases(binding, target ssa.Value) bool

CapturedBindingAliases reports whether a closure binding directly contains target or refers to an addressable local that has contained target. Unlike CapturedBindingValue, it handles variables reassigned before a callback is installed without depending on referrer iteration order.

func CapturedBindingValue

func CapturedBindingValue(binding ssa.Value) ssa.Value

CapturedBindingValue recovers value stored through an addressable closure binding.

func ChannelType

func ChannelType(value ssa.Value) bool

ChannelType reports whether value has channel type.

func ClosureCallsMethod

func ClosureCallsMethod(instruction ssa.Instruction, method string, target ssa.Value) bool

ClosureCallsMethod reports whether a call-like closure calls method on target. It maps both captured free variables and explicit closure parameters back to the values supplied by the enclosing function.

func ClosureCallsMethodBeforeBranch

func ClosureCallsMethodBeforeBranch(instruction ssa.Instruction, method string, target ssa.Value) bool

ClosureCallsMethodBeforeBranch reports whether a called function invokes method on target along an unconditional path from its entry block.

func ClosureCallsValue

func ClosureCallsValue(instruction ssa.Instruction, target ssa.Value) bool

ClosureCallsValue reports whether a call-like closure or created callback calls target.

func ClosureCapturesValue

func ClosureCapturesValue(instruction ssa.Instruction, value ssa.Value) bool

ClosureCapturesValue reports whether instruction creates a closure that owns value.

func ClosureOwnsValue

func ClosureOwnsValue(instruction ssa.Instruction, value ssa.Value) bool

ClosureOwnsValue reports whether a started closure captures value.

func DeferredClosureCalls

func DeferredClosureCalls(instruction ssa.Instruction, method string, target ssa.Value) bool

DeferredClosureCalls reports whether deferred closure calls method on target.

func DeferredClosureCallsValue

func DeferredClosureCallsValue(instruction ssa.Instruction, target ssa.Value) bool

DeferredClosureCallsValue reports whether a deferred closure calls target.

func DefinitelyNil

func DefinitelyNil(value ssa.Value) bool

DefinitelyNil reports whether every represented SSA value is nil.

func ExternallyOwnedValue

func ExternallyOwnedValue(value ssa.Value) bool

ExternallyOwnedValue reports whether value comes from storage that outlives the current function invocation.

func FeasibleSuccessors

func FeasibleSuccessors(block, predecessor *ssa.BasicBlock) []*ssa.BasicBlock

FeasibleSuccessors preserves constants selected by predecessor-sensitive phis. This prevents impossible first-iteration loop exits from faking leaks.

func FunctionFile

func FunctionFile(pass *analysis.Pass, function *ssa.Function) *ast.File

FunctionFile returns source file containing function.

func InstructionCall

func InstructionCall(instruction ssa.Instruction) *ssa.CallCommon

InstructionCall returns call metadata carried by call-like SSA instructions.

func InstructionIndex

func InstructionIndex(instruction ssa.Instruction) int

InstructionIndex returns instruction position within its basic block.

func ReachableReturns

func ReachableReturns(start ssa.Instruction) []*ssa.Return

ReachableReturns returns normal returns reachable after start.

func ReturnedValueOwnsValue

func ReturnedValueOwnsValue(returned *ssa.Return, value ssa.Value) bool

ReturnedValueOwnsValue reports whether a returned aggregate contains value in one of its fields. This recognizes constructors that transfer cleanup to a newly returned owner instead of returning the resource itself.

func SourceSSAFunctions

func SourceSSAFunctions(pass *analysis.Pass) ([]*ssa.Function, error)

SourceSSAFunctions returns non-generated source functions from buildssa results.

func StoresOwnerOfValueInField

func StoresOwnerOfValueInField(instruction ssa.Instruction, value ssa.Value) bool

StoresOwnerOfValueInField reports whether instruction stores a callback or aggregate that transitively captures value into a struct field.

func StoresValueInField

func StoresValueInField(instruction ssa.Instruction, value ssa.Value) bool

StoresValueInField reports whether instruction transfers value into a struct field.

func StoresValueInGlobal

func StoresValueInGlobal(instruction ssa.Instruction, value ssa.Value) bool

StoresValueInGlobal reports whether instruction transfers value into package-owned storage.

func StoresValueInOwnedMap

func StoresValueInOwnedMap(instruction ssa.Instruction, value ssa.Value) bool

StoresValueInOwnedMap reports whether instruction transfers value into a map that belongs to a caller, receiver, closure, or package owner.

func UnownedReturn

func UnownedReturn(
	start ssa.Instruction,
	owns func(ssa.Instruction) bool,
	allowReturn func(*ssa.Return) bool,
) bool

UnownedReturn reports whether any normal return reachable after start lacks an ownership action. Tracking owned state through CFG makes conditional cleanup visible without pretending infeasible branches are impossible.

func UnownedReturnFromEntry

func UnownedReturnFromEntry(function *ssa.Function, owns func(ssa.Instruction) bool) bool

UnownedReturnFromEntry reports whether any normal return lacks an ownership action.

func ValueCallsMethod

func ValueCallsMethod(value ssa.Value, method string, target ssa.Value) bool

ValueCallsMethod reports whether value is, or wraps, a callback that invokes method on target.

func ValueCallsValue

func ValueCallsValue(value, target ssa.Value) bool

ValueCallsValue reports whether value is, or wraps, a callback that invokes target. It follows common callback wrappers and addressable locals so callers can recognize cleanup registered through higher-order APIs.

func ValueSources

func ValueSources(value ssa.Value) map[ssa.Value]bool

ValueSources returns error-bearing SSA values contributing to value.

func ValuesShareErrorSource

func ValuesShareErrorSource(left, right ssa.Value) bool

ValuesShareErrorSource reports whether values derive from one error-bearing SSA value.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL