ctrlflow

Imports

Imports #

"go/ast"
"go/types"
"log"
"reflect"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
"golang.org/x/tools/go/cfg"
"golang.org/x/tools/go/types/typeutil"

Constants & Variables

Analyzer var #

var Analyzer = *ast.UnaryExpr

panicBuiltin var #

var panicBuiltin = *ast.TypeAssertExpr

Structs

CFGs struct #

A CFGs holds the control-flow graphs for all the functions of the current package.

type CFGs struct {
defs map[*ast.Ident]types.Object
funcDecls map[*types.Func]*declInfo
funcLits map[*ast.FuncLit]*litInfo
pass *analysis.Pass
}

declInfo struct #

type declInfo struct {
decl *ast.FuncDecl
cfg *cfg.CFG
started bool
noReturn bool
}

litInfo struct #

type litInfo struct {
cfg *cfg.CFG
noReturn bool
}

noReturn struct #

noReturn is a fact indicating that a function does not return.

type noReturn struct {

}

Functions

AFact method #

func (*noReturn) AFact()

FuncDecl method #

FuncDecl returns the control-flow graph for a named function. It returns nil if decl.Body==nil.

func (c *CFGs) FuncDecl(decl *ast.FuncDecl) *cfg.CFG

FuncLit method #

FuncLit returns the control-flow graph for a literal function.

func (c *CFGs) FuncLit(lit *ast.FuncLit) *cfg.CFG

String method #

func (*noReturn) String() string

buildDecl method #

di.cfg may be nil on return.

func (c *CFGs) buildDecl(fn *types.Func, di *declInfo)

callMayReturn method #

callMayReturn reports whether the called function may return. It is passed to the CFG builder.

func (c *CFGs) callMayReturn(call *ast.CallExpr) (r bool)

hasReachableReturn function #

func hasReachableReturn(g *cfg.CFG) bool

isIntrinsicNoReturn function #

isIntrinsicNoReturn reports whether a function intrinsically never returns because it stops execution of the calling thread. It is the base case in the recursion.

func isIntrinsicNoReturn(fn *types.Func) bool

run function #

func run(pass *analysis.Pass) (interface{}, error)

Generated with Arrow