Documentation ¶
Index ¶
- func BinOp(b *ssa.BasicBlock) []*ssa.BinOp
- func Called(instr ssa.Instruction, recv ssa.Value, f *types.Func) bool
- func CalledFrom(b *ssa.BasicBlock, i int, receiver types.Type, methods ...*types.Func) (called, ok bool)
- func Field(t types.Type, name string) (int, *types.Var)
- func File(pass *analysis.Pass, pos token.Pos) *ast.File
- func HasField(s *types.Struct, f *types.Var) bool
- func IfInstr(b *ssa.BasicBlock) *ssa.If
- func ImplementsError(t types.Type) bool
- func Imported(pkgPath string, pass *analysis.Pass) bool
- func InspectFuncs(funcs []*ssa.Function, f func(i int, instr ssa.Instruction) bool)
- func InspectInstr(start *ssa.BasicBlock, i int, f func(i int, instr ssa.Instruction) bool)
- func Interfaces(pkg *types.Package) map[string]*types.Interface
- func IsGeneratedFile(file *ast.File) bool
- func LookupFromImports(imports []*types.Package, path, name string) types.Object
- func MethodOf(typ types.Type, name string) *types.Func
- func NotCalledIn(f *ssa.Function, receiver types.Type, methods ...*types.Func) []ssa.Instruction
- func ObjectOf(pass *analysis.Pass, pkg, name string) types.Object
- func Phi(b *ssa.BasicBlock) []*ssa.Phi
- func RemoveVendor(path string) string
- func ReportWithoutIgnore(pass *analysis.Pass, names ...string) func(analysis.Diagnostic)
- func Returns(v ssa.Value) []*ssa.Return
- func Structs(pkg *types.Package) map[string]*types.Struct
- func TypeOf(pass *analysis.Pass, pkg, name string) types.Type
- func TypesInfo(info ...*types.Info) *types.Info
- func Under(t types.Type) types.Type
- func Used(v ssa.Value, instrs []ssa.Instruction) ssa.Instruction
- type CalledChecker
- func (c *CalledChecker) From(b *ssa.BasicBlock, i int, receiver types.Type, methods ...*types.Func) (called, ok bool)
- func (c *CalledChecker) Func(instr ssa.Instruction, recv ssa.Value, f *types.Func) bool
- func (c *CalledChecker) NotIn(f *ssa.Function, receiver types.Type, methods ...*types.Func) []ssa.Instruction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinOp ¶ added in v0.0.4
func BinOp(b *ssa.BasicBlock) []*ssa.BinOp
BinOp returns binary operator values which are contained in the block b.
func Called ¶
Called returns true when f is called in the instr. If recv is not nil, Called also checks the receiver.
func CalledFrom ¶
func CalledFrom(b *ssa.BasicBlock, i int, receiver types.Type, methods ...*types.Func) (called, ok bool)
CalledFrom checks whether receiver's method is called in an instruction which belogns to after i-th instructions, or in succsor blocks of b. The first result is above value. The second result is whether type of i-th instruction does not much receiver or matches with ignore cases.
func Field ¶ added in v0.5.0
Field returns field of the struct type. If the type is not struct or has not the field, Field returns -1, nil. If the type is a named type or a pointer type, Field calls itself recursively with an underlying type or an element type of pointer.
func IfInstr ¶
func IfInstr(b *ssa.BasicBlock) *ssa.If
IfInstr returns *ssa.If which is contained in the block b. If the block b has not any if instruction, IfInstr returns nil.
func ImplementsError ¶
ImplementsError return whether t implements error interface.
func InspectFuncs ¶ added in v0.6.3
InspectFuncs inspects functions.
func InspectInstr ¶ added in v0.2.0
func InspectInstr(start *ssa.BasicBlock, i int, f func(i int, instr ssa.Instruction) bool)
InspectInstr inspects from i-th instruction of start block to succsessor blocks.
func Interfaces ¶
Interfaces returns a map of interfaces which are declared in the package.
func IsGeneratedFile ¶ added in v0.6.0
IsGeneratedFile reports whether the file has been generated automatically. If file is nil, IsGeneratedFile will return false.
func LookupFromImports ¶
LookupFromImports finds an object from import paths.
func NotCalledIn ¶ added in v0.2.0
NotCalledIn checks whether receiver's method is called in a function. If there is no methods calling at a path from an instruction which type is receiver to all return instruction, NotCalledIn returns these instructions.
func Phi ¶
func Phi(b *ssa.BasicBlock) []*ssa.Phi
Phi returns phi values which are contained in the block b.
func RemoveVendor ¶
RemoVendor removes vendoring information from import path.
func ReportWithoutIgnore ¶ added in v0.1.0
func ReportWithoutIgnore(pass *analysis.Pass, names ...string) func(analysis.Diagnostic)
ReportWithoutIgnore returns a report function which can set to (analysis.Pass).Report. The report function ignores a diagnostic which annotated by ignore comment as the below.
//lint:ignore Check1[,Check2,...,CheckN] reason
names is a list of checker names. If names was omitted, the report function ignores by pass.Analyzer.Name.
func TypeOf ¶
TypeOf returns types.Type by given name in the package. TypeOf accepts pointer types such as *T.
func Under ¶ added in v0.3.0
Under returns the most bottom underlying type. Deprecated: (types.Type).Underlying returns same value of it.
func Used ¶ added in v0.4.0
func Used(v ssa.Value, instrs []ssa.Instruction) ssa.Instruction
Used returns an instruction which uses the value in the instructions.
Types ¶
type CalledChecker ¶
type CalledChecker struct {
Ignore func(instr ssa.Instruction) bool
}
CalledChecker checks a function is called. See From and Func.
func (*CalledChecker) From ¶
func (c *CalledChecker) From(b *ssa.BasicBlock, i int, receiver types.Type, methods ...*types.Func) (called, ok bool)
From checks whether receiver's method is called in an instruction which belogns to after i-th instructions, or in succsor blocks of b. The first result is above value. The second result is whether type of i-th instruction does not much receiver or matches with ignore cases.
func (*CalledChecker) Func ¶
func (c *CalledChecker) Func(instr ssa.Instruction, recv ssa.Value, f *types.Func) bool
Func returns true when f is called in the instr. If recv is not nil, Func also checks the receiver.
func (*CalledChecker) NotIn ¶ added in v0.2.0
func (c *CalledChecker) NotIn(f *ssa.Function, receiver types.Type, methods ...*types.Func) []ssa.Instruction
NotIn checks whether receiver's method is called in a function. If there is no methods calling at a path from an instruction which type is receiver to all return instruction, NotIn returns these instructions.