mirror of
https://github.com/golang/go
synced 2024-11-05 16:16:11 -07:00
cmd/compile: remove haslabelgoto
As of CL 39998, it is no longer necessary. Fixes #19699 Change-Id: Ie1c49c8468073c6ddeb96c03668705cf81d40c98 Reviewed-on: https://go-review.googlesource.com/41051 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
d728be70f4
commit
7189a02ca5
@ -3957,16 +3957,10 @@ func deadcodeslice(nn Nodes) {
|
||||
continue
|
||||
}
|
||||
if n.Op == OIF && Isconst(n.Left, CTBOOL) {
|
||||
var dead *Nodes
|
||||
if n.Left.Bool() {
|
||||
dead = &n.Rlist
|
||||
n.Rlist = Nodes{}
|
||||
} else {
|
||||
dead = &n.Nbody
|
||||
}
|
||||
// TODO(mdempsky/josharian): eliminate need for haslabelgoto
|
||||
// by checking labels and gotos earlier. See issue 19699.
|
||||
if !(*dead).haslabelgoto() {
|
||||
*dead = Nodes{}
|
||||
n.Nbody = Nodes{}
|
||||
}
|
||||
}
|
||||
deadcodeslice(n.Ninit)
|
||||
@ -3975,19 +3969,3 @@ func deadcodeslice(nn Nodes) {
|
||||
deadcodeslice(n.Rlist)
|
||||
}
|
||||
}
|
||||
|
||||
// haslabelgoto reports whether the Nodes list contains any label or goto statements.
|
||||
func (l Nodes) haslabelgoto() bool {
|
||||
for _, n := range l.Slice() {
|
||||
if n == nil {
|
||||
continue
|
||||
}
|
||||
if n.Op == OLABEL || n.Op == OGOTO {
|
||||
return true
|
||||
}
|
||||
if n.Ninit.haslabelgoto() || n.Nbody.haslabelgoto() || n.List.haslabelgoto() || n.Rlist.haslabelgoto() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user