mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.regabi] cmd/compile: remove SetOp(OEMPTY) calls
In preparation for OEMPTY being its own Node implementation, remove SetOp(OEMPTY) calls that assume other implementations can be turned into OEMPTY. Passes buildall w/ toolstash -cmp. Change-Id: Icac16d12548f35f52a5efa9d09dacf8260f42075 Reviewed-on: https://go-review.googlesource.com/c/go/+/274090 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
171787efcd
commit
b09dbc6913
3 changed files with 10 additions and 7 deletions
|
|
@ -959,6 +959,9 @@ func anylit(n ir.Node, var_ ir.Node, init *ir.Nodes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// oaslit handles special composite literal assignments.
|
||||||
|
// It returns true if n's effects have been added to init,
|
||||||
|
// in which case n should be dropped from the program by the caller.
|
||||||
func oaslit(n ir.Node, init *ir.Nodes) bool {
|
func oaslit(n ir.Node, init *ir.Nodes) bool {
|
||||||
if n.Left() == nil || n.Right() == nil {
|
if n.Left() == nil || n.Right() == nil {
|
||||||
// not a special composite literal assignment
|
// not a special composite literal assignment
|
||||||
|
|
@ -990,8 +993,6 @@ func oaslit(n ir.Node, init *ir.Nodes) bool {
|
||||||
anylit(n.Right(), n.Left(), init)
|
anylit(n.Right(), n.Left(), init)
|
||||||
}
|
}
|
||||||
|
|
||||||
n.SetOp(ir.OEMPTY)
|
|
||||||
n.SetRight(nil)
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1985,8 +1985,7 @@ func typecheck1(n ir.Node, top int) (res ir.Node) {
|
||||||
// Empty identifier is valid but useless.
|
// Empty identifier is valid but useless.
|
||||||
// Eliminate now to simplify life later.
|
// Eliminate now to simplify life later.
|
||||||
// See issues 7538, 11589, 11593.
|
// See issues 7538, 11589, 11593.
|
||||||
n.SetOp(ir.OEMPTY)
|
n = ir.NodAt(n.Pos(), ir.OEMPTY, nil, nil)
|
||||||
n.SetLeft(nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case ir.ODEFER:
|
case ir.ODEFER:
|
||||||
|
|
|
||||||
|
|
@ -152,10 +152,12 @@ func walkstmt(n ir.Node) ir.Node {
|
||||||
init := n.Init()
|
init := n.Init()
|
||||||
n.PtrInit().Set(nil)
|
n.PtrInit().Set(nil)
|
||||||
n = walkexpr(n, &init)
|
n = walkexpr(n, &init)
|
||||||
n = addinit(n, init.Slice())
|
if wascopy && n.Op() == ir.ONAME {
|
||||||
if wascopy && n.Op() == ir.OCONVNOP {
|
// copy rewrote to a statement list and a temp for the length.
|
||||||
n.SetOp(ir.OEMPTY) // don't leave plain values as statements.
|
// Throw away the temp to avoid plain values as statements.
|
||||||
|
n = ir.NodAt(n.Pos(), ir.OEMPTY, nil, nil)
|
||||||
}
|
}
|
||||||
|
n = addinit(n, init.Slice())
|
||||||
|
|
||||||
// special case for a receive where we throw away
|
// special case for a receive where we throw away
|
||||||
// the value received.
|
// the value received.
|
||||||
|
|
@ -609,6 +611,7 @@ opswitch:
|
||||||
}
|
}
|
||||||
|
|
||||||
if oaslit(n, init) {
|
if oaslit(n, init) {
|
||||||
|
n = ir.NodAt(n.Pos(), ir.OEMPTY, nil, nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue