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
Click to show internal directories.
Click to hide internal directories.