postFunctionCallUpdate updates all conditions.
(call callCommon, lff *lockFunctionFacts, ls *lockState)
| 435 | |
| 436 | // postFunctionCallUpdate updates all conditions. |
| 437 | func (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. |
| 472 | func exclusiveStr(exclusive bool) string { |
no test coverage detected