structfield

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package structfield implements a sub-analyzer that collects struct fields accessed within a function to aid the analysis of the main function analyzer.

Index

Constants

View Source
const (
	Assigned fieldUse = 1 << iota // 0b01
	Accessed                      // 0b10
)

The use of a field can be represented as `assigned` (e.g., s.f = v) or `accessed` (e.g., g(s.f))

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:       "nilaway_struct_field_analyzer",
	Doc:        _doc,
	Run:        analysishelper.WrapRun(run),
	ResultType: reflect.TypeOf((*analysishelper.Result[*FieldContext])(nil)),
	Requires:   []*analysis.Analyzer{config.Analyzer},
}

Analyzer collects struct fields accessed (e.g., assignments) from within a function.

Functions

This section is empty.

Types

type FieldContext

type FieldContext struct {
	// contains filtered or unexported fields
}

FieldContext stores field information (i.e., assignment and/or access) collected by parsing a function

func (*FieldContext) IsFieldUsedInFunc

func (f *FieldContext) IsFieldUsedInFunc(funcDecl *types.Func, param int, fieldName string, expectedUse fieldUse) bool

IsFieldUsedInFunc returns true if the passed `fieldName` of struct at index `param` is found to be direct used in the function `funcDecl` for assignment or access

Jump to

Keyboard shortcuts

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