Commit 9d4623fe authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: handle OCONV[NOP] in samesafeexpr

This increases the effectiveness of the
"integer-in-range" CL that follows.

Change-Id: I23b7b6809f0b2c25ed1d59dd2d5429c30f1db89c
Reviewed-on: https://go-review.googlesource.com/27651
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 507051d6
......@@ -3186,9 +3186,14 @@ func samesafeexpr(l *Node, r *Node) bool {
case ODOT, ODOTPTR:
return l.Sym != nil && r.Sym != nil && l.Sym == r.Sym && samesafeexpr(l.Left, r.Left)
case OIND:
case OIND, OCONVNOP:
return samesafeexpr(l.Left, r.Left)
case OCONV:
// Some conversions can't be reused, such as []byte(str).
// Allow only numeric-ish types. This is a bit conservative.
return issimple[l.Type.Etype] && samesafeexpr(l.Left, r.Left)
case OINDEX:
return samesafeexpr(l.Left, r.Left) && samesafeexpr(l.Right, r.Right)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment