Removes unnecessary nil-check when referencing offset from an
address. Suggested by Keith Randall in golang/go#27180.
Updates golang/go#27180
Change-Id: I326ed7fda7cfa98b7e4354c811900707fee26021
Reviewed-on: https://go-review.googlesource.com/131735
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
// a value resulting from taking the address of a
// value, or a value constructed from an offset of a
// non-nil ptr (OpAddPtr) implies it is non-nil
- if v.Op == OpAddr || v.Op == OpLocalAddr || v.Op == OpAddPtr {
+ if v.Op == OpAddr || v.Op == OpLocalAddr || v.Op == OpAddPtr || v.Op == OpOffPtr {
nonNilValues[v.ID] = true
}
}
func f(t *TT) *byte {
// See issue 17242.
- s := &t.SS // ERROR "removed nil check"
- return &s.x // ERROR "generated nil check"
+ s := &t.SS // ERROR "generated nil check"
+ return &s.x // ERROR "removed nil check"
}
// make sure not to do nil check for newobject