Documentation
¶
Overview ¶
Package ssabuilder provides a wrapper for building SSA IR from Go source code.
Index ¶
- Variables
- func MainPkg(prog *ssa.Program) *ssa.Package
- type ChanOp
- type ChanOpType
- type Config
- type Members
- type Mode
- type SSAInfo
- func (info *SSAInfo) CallGraph() *callgraph.Node
- func (info *SSAInfo) DecodePos(pos token.Pos) token.Position
- func (info *SSAInfo) FindChan(ch ssa.Value) []ChanOp
- func (info *SSAInfo) NewPta(vals ...ssa.Value) *pointer.Result
- func (info *SSAInfo) WriteAll(w io.Writer) (int64, error)
- func (info *SSAInfo) WriteTo(w io.Writer) (int64, error)
Constants ¶
This section is empty.
Variables ¶
var ErrPtaInternal = errors.New("internal error: pointer analysis failed")
Functions ¶
Types ¶
type ChanOp ¶
type ChanOp struct { Value ssa.Value Type ChanOpType Pos token.Pos }
ChanOp abstracts an ssa.Send, ssa.Unop(ARROW) or a SelectState.
type ChanOpType ¶
type ChanOpType int
const ( ChanMake ChanOpType = iota ChanSend ChanRecv ChanClose )
type Config ¶
type Config struct { BuildMode Mode Files []string // (Initial) files to load. Source string // Source code. BuildLog io.Writer // Build log. PtaLog io.Writer // Pointer analysis log. LogFlags int // Flags for build/pta log. BadPkgs map[string]string // Packages not to load (with reasons). }
Config holds the configuration for building SSA IR.
func NewConfigFromString ¶
NewConfigFromString creates a new default build configuration.
type SSAInfo ¶
type SSAInfo struct { BuildConf *Config // Build configuration (initial files, logs). IgnoredPkgs []string // Packages not loaded (respects BuildConf.BadPkgs). FSet *token.FileSet // FileSet for parsed source files. Prog *ssa.Program // SSA IR for whole program. PtaConf *pointer.Config // Pointer analysis config. Logger *log.Logger // Build logger. }
SSAInfo is the SSA IR + metainfo built from a given Config.
func (*SSAInfo) CallGraph ¶
CallGraph builds the call graph from the 'main.main' function.
The call graph is rooted at 'main.main', all nodes appear only once in the graph. A side-effect of building the call graph is obtaining a list of functions used in a program (as functions not called will not appear in the CallGraph). TODO(nickng) cache previously built CallGraph.
func (*SSAInfo) DecodePos ¶
DecodePos converts a token.Pos (offset) to an actual token.Position.
This is just a shortcut to .FSet.Position.
func (*SSAInfo) FindChan ¶
FindChan performs a ptr analysis on a given chan ssa.Value, returns a list of related ChanOp on the chan.