1
0
mirror of https://github.com/golang/go synced 2024-11-18 19:44:46 -07:00

Revert "go/analysis/passes/atomicalign: handle pointers to struct"

This reverts CL 158999, commit 8dbcc66f33.

Reason for revert: broke the build, nobody ever ran trybots

Change-Id: I2180ed8f9281b413b2ffea086abbd09fbfc3c99e
Reviewed-on: https://go-review.googlesource.com/c/160839
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Brad Fitzpatrick 2019-02-02 20:07:21 +00:00 committed by Alan Donovan
parent 51e363b66d
commit 718ddee956
2 changed files with 5 additions and 26 deletions

View File

@ -21,7 +21,7 @@ import (
var Analyzer = &analysis.Analyzer{
Name: "atomicalign",
Doc: "check for non-64-bit-aligned arguments to sync/atomic functions",
Doc: "check for non-64-bits-aligned arguments to sync/atomic functions",
Requires: []*analysis.Analyzer{inspect.Analyzer},
Run: run,
}
@ -70,7 +70,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
}
func check64BitAlignment(pass *analysis.Pass, funcName string, arg ast.Expr) {
// Checks the argument is made of the address operator (&) applied
// Checks the argument is made of the address operator (&) applied to
// to a struct field (as opposed to a variable as the first word of
// uint64 and int64 variables can be relied upon to be 64-bit aligned.
unary, ok := arg.(*ast.UnaryExpr)
@ -80,18 +80,16 @@ func check64BitAlignment(pass *analysis.Pass, funcName string, arg ast.Expr) {
// Retrieve the types.Struct in order to get the offset of the
// atomically accessed field.
selector, ok := unary.X.(*ast.SelectorExpr)
sel, ok := unary.X.(*ast.SelectorExpr)
if !ok {
return
}
sel := pass.TypesInfo.Selections[selector]
tvar, ok := sel.Obj().(*types.Var)
tvar, ok := pass.TypesInfo.Selections[sel].Obj().(*types.Var)
if !ok || !tvar.IsField() {
return
}
stype, ok := sel.Recv().Underlying().(*types.Struct)
stype, ok := pass.TypesInfo.Types[sel.X].Type.Underlying().(*types.Struct)
if !ok {
return
}

View File

@ -228,22 +228,3 @@ func embeddedStructFields() {
atomic.AddUint64(&s1.b, 9) // want "address of non 64-bit aligned field .b passed to atomic.AddUint64"
atomic.AddInt64(&s1.c, 9)
}
type t struct {
_ int32
a int64
_ int16
_ int16
b uint64
}
func (t *t) structPointerReceiver() {
atomic.LoadInt64(&t.a) // want "address of non 64-bit aligned field .a passed to atomic.LoadInt64"
atomic.LoadUint64(&t.b)
}
func structPointer() {
t := &t{}
atomic.StoreInt64(&t.a, -1) // want "address of non 64-bit aligned field .a passed to atomic.StoreInt64"
atomic.StoreUint64(&t.b, 1)
}