Documentation ¶
Index ¶
- func BinOp(b *ssa.BasicBlock) (binops []*ssa.BinOp)
- func Called(instr ssa.Instruction, recv ssa.Value, f *types.Func) bool
- func CalledBeforeAndEqualTo(b *ssa.BasicBlock, receiver ssa.Value, method *types.Func, o types.Object) bool
- func CalledFrom(b *ssa.BasicBlock, i int, receiver types.Type, methods ...*types.Func) (called, ok bool)
- func CalledFromAfter(b *ssa.BasicBlock, i int, receiver ssa.Value, methods ...*types.Func) (called, ok bool)
- func CalledFromBefore(b *ssa.BasicBlock, i int, receiver ssa.Value, methods ...*types.Func) (called, ok bool)
- 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 Interfaces(pkg *types.Package) map[string]*types.Interface
- func LookupFromImports(imports []*types.Package, path, name string) types.Object
- func MethodOf(typ types.Type, name string) *types.Func
- func ObjectOf(pass *analysis.Pass, pkg, name string) types.Object
- func Phi(b *ssa.BasicBlock) (phis []*ssa.Phi)
- func PkgUsedInFunc(pass *analysis.Pass, pkgPath string, f *ssa.Function) bool
- func PkgUsedInPass(pkgPath string, pass *analysis.Pass) bool
- func RemoveVendor(path string) string
- func ReturnReceiverIfCalled(instr ssa.Instruction, f *types.Func) ssa.Value
- 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
- type CalledChecker
- func (c *CalledChecker) Before(b *ssa.BasicBlock, i int, receiver types.Type, methods ...*types.Func) (called, ok bool)
- func (c *CalledChecker) BeforeAndEqualTo(b *ssa.BasicBlock, receiver ssa.Value, method *types.Func, o types.Object) bool
- func (c *CalledChecker) From(b *ssa.BasicBlock, i int, receiver types.Type, methods ...*types.Func) (called, ok bool)
- func (c *CalledChecker) FromAfter(b *ssa.BasicBlock, i int, receiver ssa.Value, methods ...*types.Func) (called, ok bool)
- func (c *CalledChecker) FromBefore(b *ssa.BasicBlock, i int, receiver ssa.Value, methods ...*types.Func) (called, ok bool)
- func (c *CalledChecker) Func(instr ssa.Instruction, recv ssa.Value, f *types.Func) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinOp ¶
func BinOp(b *ssa.BasicBlock) (binops []*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 CalledBeforeAndEqualTo ¶ added in v0.0.6
func CalledBeforeAndEqualTo(b *ssa.BasicBlock, receiver ssa.Value, method *types.Func, o types.Object) bool
CalledBeforeAndEqualTo checks like CalledFromBefore and if the result of call is equal to o.
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. CalledFrom uses types.Type and return value of i-th instruction as the receiver and check it.
func CalledFromAfter ¶ added in v0.0.6
func CalledFromAfter(b *ssa.BasicBlock, i int, receiver ssa.Value, methods ...*types.Func) (called, ok bool)
CalledFromAfter checks whether receiver's method is called in instructions which belongs to after i-th instructions, or in succs blocks of b. The second result is whether type of i-th instruction does not much receiver or matches with ignore cases. FromAfter takes receiver as a value of ssa.Value.
func CalledFromBefore ¶ added in v0.0.6
func CalledFromBefore(b *ssa.BasicBlock, i int, receiver ssa.Value, methods ...*types.Func) (called, ok bool)
CalledFromBefore checks whether receiver's method is called in an instruction which belongs to before i-th instructions, or in preds 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 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 Interfaces ¶
Interfaces returns a map of interfaces which are declared in the package.
func LookupFromImports ¶
LookupFromImports finds an object from import paths.
func Phi ¶
func Phi(b *ssa.BasicBlock) (phis []*ssa.Phi)
Phi returns phi values which are contained in the block b.
func PkgUsedInFunc ¶
PkgUsedInFunc returns true when the given f imports the pkg.
func PkgUsedInPass ¶
PkgUsedInPass returns true when the given pass imports the pkg.
func RemoveVendor ¶
RemoVendor removes vendoring information from import path.
func ReturnReceiverIfCalled ¶ added in v0.0.6
ReturnReceiverIfCalled returns value of the first argment which is probablly the receiver when f is called in the instr. If recv is not nil, Called also checks the receiver.
Types ¶
type CalledChecker ¶
type CalledChecker struct {
Ignore func(instr ssa.Instruction) bool
}
CalledChecker checks a function is called. See From and Func.
func (*CalledChecker) Before ¶ added in v0.0.6
func (c *CalledChecker) Before(b *ssa.BasicBlock, i int, receiver types.Type, methods ...*types.Func) (called, ok bool)
Before checks whether receiver's method is called in an instruction which belongs to before i-th instructions, or in preds 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. Before uses types.Type and return value of i-th instruction as the receiver and check it.
func (*CalledChecker) BeforeAndEqualTo ¶ added in v0.0.6
func (c *CalledChecker) BeforeAndEqualTo(b *ssa.BasicBlock, receiver ssa.Value, method *types.Func, o types.Object) bool
BeforeAndEqualTo as a method of CalledChecker checks like CalledFromBefore and if the result of call is equal to o.
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 match receiver or matches with ignore cases. This compares a types.Type to the type of return value of i-th instruction and use it as the receiver and check it.
func (*CalledChecker) FromAfter ¶ added in v0.0.6
func (c *CalledChecker) FromAfter(b *ssa.BasicBlock, i int, receiver ssa.Value, methods ...*types.Func) (called, ok bool)
FromAfter checks whether receiver's method is called in instructions which belongs to after i-th instructions, or in succs blocks of b. The second result is whether type of i-th instruction does not much receiver or matches with ignore cases. FromAfter takes receiver as a value of ssa.Value.
func (*CalledChecker) FromBefore ¶ added in v0.0.6
func (c *CalledChecker) FromBefore(b *ssa.BasicBlock, i int, receiver ssa.Value, methods ...*types.Func) (called, ok bool)
FromBefore checks whether receiver's method is called in instructions which belongs to before i-th instructions, or in preds blocks of b. The second result is whether type of i-th instruction does not much receiver or matches with ignore cases. FromBefore takes receiver as a value of ssa.Value.
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, Called also checks the receiver.