pointerescapes

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 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:             "pointerescapes",
	Doc:              "gathers a list of function signatures and their pointer arguments which definitely do not escape during the lifetime of the function",
	Run:              run,
	RunDespiteErrors: true,
	Requires:         []*analysis.Analyzer{inspect.Analyzer, packid.Analyzer, callgraph.Analyzer},
	ResultType:       reflect.TypeOf((*Result)(nil)),
}

Analyzer gathers a list of function signatures and indices of their pointer arguments which can be proven safe. A pointer argument to a function is considered safe if 1) it does not appear alone on the right-hand side of any assignment statement in the function body, and 2) it does not appear alone in the body of any composite literal.

Functions

This section is empty.

Types

type Result

type Result struct {
	// SafePtrs maps function signatures to a list of indices of pointer arguments which are safe.
	SafePtrs map[callgraph.Signature][]int
	// DangerGraph descripts the subgraph of the callgraph which consist of dangerous pointer calls.
	DangerGraph callgraph.CallGraph
	// WritesPtr is a set of signatures which were found to write a pointer.
	WritesPtr map[callgraph.Signature]struct{}
	// ThirdPartyPtrPassed is a set of signatures which were found to pass a pointer into a third-party function.
	ThirdPartyPtrPassed map[callgraph.Signature]struct{}
}

Result maps function signatures to the indices of all of their safe pointer arguments.

Jump to

Keyboard shortcuts

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