structinit

package
v0.3.5-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package structinit implements the struct initialization syntactic analysis.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReportResults

func ReportResults(res AnalysisResult) (string, bool)

ReportResults writes res to a string and returns true if the analysis should fail.

Types

type AnalysisResult

type AnalysisResult struct {
	// InitInfos is a mapping from the named struct type to its initialization
	// information.
	InitInfos map[*types.Named]InitInfo
}

AnalysisResult is the result of the struct-init analysis.

func Analyze

func Analyze(state *ptr.State) (AnalysisResult, error)

Analyze runs the analysis on prog.

type InitInfo

type InitInfo struct {
	// Tag is the tag of the problem this initinfo corresponds to
	Tag string
	// ZeroAllocs is a list of the zero-value allocations of the struct.
	ZeroAllocs []ZeroAlloc
	// InvalidWrites is a mapping of the struct field to all the invalid writes
	// to that field.
	InvalidWrites map[*types.Var][]InvalidWrite
	// contains filtered or unexported fields
}

InitInfo is the initialization information for a struct.

type InvalidWrite

type InvalidWrite struct {
	// Got is the value actually written.
	Got ssa.Value
	// Want is the configured value that should have been written.
	Want ssa.Value
	// Instr is the instruction performing the write.
	Instr ssa.Instruction
	// Pos is the position of the instruction.
	Pos token.Position
}

InvalidWrite is a write to a field of the struct of value Got that is not the configured value (Want).

type ZeroAlloc

type ZeroAlloc struct {
	// Alloc is the allocation instruction.
	Alloc ssa.Instruction
	// Pos is the position of the instruction.
	Pos token.Position
}

ZeroAlloc is an empty (zero) allocation of a struct.

Jump to

Keyboard shortcuts

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