diff options
author | Adin Scannell <ascannell@google.com> | 2021-11-02 18:01:24 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-11-02 18:04:26 -0700 |
commit | 7551b0590d87588deda562a959e09ada425bfea5 (patch) | |
tree | ebf5e58fd75233e06cbf7edbb26b1f8d1ae854a7 /tools/checklocks/test/aliases.go | |
parent | a8eb1895bbc4e1d41cdd621b8eca3f3e4912a446 (diff) |
Minor checklocks improvements.
* Support sync.Locker.
* Prevent runaway recursion when locks are acquired in a loop.
* Allowing ignoring of anonymous functions (inherited from parent function).
* Add support for aliases.
PiperOrigin-RevId: 407221521
Diffstat (limited to 'tools/checklocks/test/aliases.go')
-rw-r--r-- | tools/checklocks/test/aliases.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/checklocks/test/aliases.go b/tools/checklocks/test/aliases.go new file mode 100644 index 000000000..e28027fe5 --- /dev/null +++ b/tools/checklocks/test/aliases.go @@ -0,0 +1,26 @@ +// Copyright 2021 The gVisor Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package test + +// +checklocks:tc.mu +// +checklocksalias:tc2.mu=tc.mu +func testAliasValid(tc *oneGuardStruct, tc2 *oneGuardStruct) { + tc2.guardedField = 1 +} + +// +checklocks:tc.mu +func testAliasInvalid(tc *oneGuardStruct, tc2 *oneGuardStruct) { + tc2.guardedField = 1 // +checklocksfail +} |