looppointer

package
v0.0.0-...-c7609e9 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2021 License: MIT, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:             "looppointer",
	Doc:              "checks for pointers to enclosing loop variables; modified for sweeping GitHub",
	Run:              run,
	RunDespiteErrors: true,
	Requires:         []*analysis.Analyzer{inspect.Analyzer, packid.Analyzer, callgraph.Analyzer, nogofunc.Analyzer, pointerescapes.Analyzer},
}

Analyzer checks for pointers to enclosing loop variables; modified for sweeping GitHub

Functions

This section is empty.

Types

type Reason

type Reason uint8

Reason describes why an instance is being reported.

const (
	// ReasonNone indicates nothing is being reported.
	ReasonNone Reason = iota
	// ReasonPointerReassigned indicates a reference to a range loop variable was reassigned.
	ReasonPointerReassigned
	// ReasonCallMayWritePtr indicates some function call may store a reference to a range loop variable.
	ReasonCallMayWritePtr
	// ReasonCallMaybeAsync indicates some function call taking a reference to a range loop variable may start a Goroutine.
	ReasonCallMaybeAsync
	// ReasonCallPassesToThirdParty indicates some function call passes a pointer to third-party code
	ReasonCallPassesToThirdParty
	// ReasonPointerStoredInCompositeLit indicates a pointer to a range-loop variable was used in a composite literal.
	ReasonPointerStoredInCompositeLit
)

func (Reason) Message

func (r Reason) Message(name string, pos token.Position) string

Message returns a human-readable message, provided the name of the varaible and its position in the source code.

type Searcher

type Searcher struct {
	Stats map[token.Pos]*ast.RangeStmt
}

Searcher stores the set of range loops found in the source code, keyed by its position in the repository.

Jump to

Keyboard shortcuts

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