-
Notifications
You must be signed in to change notification settings - Fork 4
/
analyzer_go118.go
40 lines (33 loc) · 989 Bytes
/
analyzer_go118.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//go:build go1.18
// +build go1.18
package analyzer
import (
"go/types"
"github.com/gostaticanalysis/analysisutil"
"golang.org/x/tools/go/analysis"
)
func (t thelper) buildFuzzCheckFuncOpts(pass *analysis.Pass, ctxType types.Type) (checkFuncOpts, bool) {
fObj := analysisutil.ObjectOf(pass, "testing", "F")
if fObj == nil {
return checkFuncOpts{}, false
}
fHelper, _, _ := types.LookupFieldOrMethod(fObj.Type(), true, fObj.Pkg(), "Helper")
if fHelper == nil {
return checkFuncOpts{}, false
}
tFuzz, _, _ := types.LookupFieldOrMethod(fObj.Type(), true, fObj.Pkg(), "Fuzz")
if tFuzz == nil {
return checkFuncOpts{}, false
}
return checkFuncOpts{
skipPrefix: "Fuzz",
varName: "f",
fnHelper: fHelper,
subRun: tFuzz,
hpType: types.NewPointer(fObj.Type()),
ctxType: ctxType,
checkBegin: t.enabledChecks.Enabled(checkFBegin),
checkFirst: t.enabledChecks.Enabled(checkFFirst),
checkName: t.enabledChecks.Enabled(checkFName),
}, true
}