MCPcopy Index your code
hub / github.com/google/gvisor / postFunctionCallUpdate

Method postFunctionCallUpdate

tools/checklocks/analysis.go:437–469  ·  view source on GitHub ↗

postFunctionCallUpdate updates all conditions.

(call callCommon, lff *lockFunctionFacts, ls *lockState)

Source from the content-addressed store, hash-verified

435
436// postFunctionCallUpdate updates all conditions.
437func (pc *passContext) postFunctionCallUpdate(call callCommon, lff *lockFunctionFacts, ls *lockState) {
438 // Release all locks not still held.
439 for fieldName, fg := range lff.HeldOnEntry {
440 if _, ok := lff.HeldOnExit[fieldName]; ok {
441 continue
442 }
443 r := fg.Resolver.resolveCall(pc, ls, call.Common().Args, call.Value())
444 if !r.valid() {
445 // See above: this cannot be forced.
446 pc.maybeFail(call.Pos(), "field %s cannot be resolved", fieldName)
447 continue
448 }
449 if s, ok := ls.unlockField(r, fg.Exclusive); !ok && !lff.Ignore {
450 if _, ok := pc.forced[pc.positionKey(call.Pos())]; !ok && !lff.Ignore {
451 pc.maybeFail(call.Pos(), "attempt to release %s (%s), but not held (locks: %s)", fieldName, s, ls.String())
452 }
453 }
454 }
455
456 // Update all held locks if acquired.
457 for fieldName, fg := range lff.HeldOnExit {
458 if _, ok := lff.HeldOnEntry[fieldName]; ok {
459 continue
460 }
461 // Acquire the lock per the annotation.
462 r := fg.Resolver.resolveCall(pc, ls, call.Common().Args, call.Value())
463 if s, ok := ls.lockField(r, fg.Exclusive); !ok && !lff.Ignore {
464 if _, ok := pc.forced[pc.positionKey(call.Pos())]; !ok && !lff.Ignore {
465 pc.maybeFail(call.Pos(), "attempt to acquire %s (%s), but already held (locks: %s)", fieldName, s, ls.String())
466 }
467 }
468 }
469}
470
471// exclusiveStr returns a string describing exclusive requirements.
472func exclusiveStr(exclusive bool) string {

Callers 2

checkFunctionCallMethod · 0.95
checkFunctionMethod · 0.95

Calls 10

maybeFailMethod · 0.95
positionKeyMethod · 0.95
CommonMethod · 0.80
unlockFieldMethod · 0.80
lockFieldMethod · 0.80
resolveCallMethod · 0.65
ValueMethod · 0.65
PosMethod · 0.65
StringMethod · 0.65
validMethod · 0.45

Tested by

no test coverage detected