MCPcopy
hub / github.com/google/gvisor / maybeFail

Method maybeFail

tools/checklocks/annotations.go:83–101  ·  view source on GitHub ↗

maybeFail checks a potential failure against a specific failure map.

(pos token.Pos, fmtStr string, args ...any)

Source from the content-addressed store, hash-verified

81
82// maybeFail checks a potential failure against a specific failure map.
83func (pc *passContext) maybeFail(pos token.Pos, fmtStr string, args ...any) {
84 if fd, ok := pc.failures[pc.positionKey(pos)]; ok {
85 msg := fmt.Sprintf(fmtStr, args...)
86 index := slices.IndexFunc(fd.wants, func(want string) bool {
87 return strings.Contains(msg, want)
88 })
89 if index != -1 {
90 fd.wants = slices.Delete(fd.wants, index, index+1)
91 return
92 }
93 }
94 if _, ok := pc.exemptions[pc.positionKey(pos)]; ok {
95 return // Ignored, not counted.
96 }
97 if !enableWrappers && !pos.IsValid() {
98 return // Ignored, implicit.
99 }
100 pc.pass.Reportf(pos, fmtStr, args...)
101}
102
103// checkFailure checks for the expected failure counts.
104func (pc *passContext) checkFailures() {

Callers 15

lockKindMethod · 0.95
validateMutexMethod · 0.95
resolveFieldListPartsMethod · 0.95
maybeFindFieldListObjMethod · 0.95
fillLockGuardFactsMethod · 0.95
matchFieldListMethod · 0.95
resolveFunctionGuardMethod · 0.95
typeAliasFactsMethod · 0.95
typeAlignmentMethod · 0.95
checkAtomicCallMethod · 0.95
checkGuardsMethod · 0.95

Calls 5

positionKeyMethod · 0.95
ReportfMethod · 0.80
DeleteMethod · 0.65
ContainsMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected