1
0
mirror of https://github.com/golang/go synced 2024-11-26 06:17:57 -07:00

[dev.regabi] cmd/compile: change ir.IsAssignable -> ir.IsAddressable

ir.IsAssignable does not include map index expression, so it should be
named ir.IsAddressable instead.

[git-generate]

cd src/cmd/compile/internal/ir
rf '
  mv IsAssignable IsAddressable
'

Change-Id: Ief6188e7b784ba9592d7b0cbec33b5f70d78f638
Reviewed-on: https://go-review.googlesource.com/c/go/+/279436
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Cuong Manh Le 2020-12-24 18:16:44 +07:00
parent 27b248b307
commit 082cc8b7d9
8 changed files with 11 additions and 11 deletions

View File

@ -776,12 +776,12 @@ func IsZero(n Node) bool {
}
// lvalue etc
func IsAssignable(n Node) bool {
func IsAddressable(n Node) bool {
switch n.Op() {
case OINDEX:
n := n.(*IndexExpr)
if n.X.Type() != nil && n.X.Type().IsArray() {
return IsAssignable(n.X)
return IsAddressable(n.X)
}
if n.X.Type() != nil && n.X.Type().IsString() {
return false
@ -792,7 +792,7 @@ func IsAssignable(n Node) bool {
case ODOT:
n := n.(*SelectorExpr)
return IsAssignable(n.X)
return IsAddressable(n.X)
case ONAME:
n := n.(*Name)

View File

@ -2736,7 +2736,7 @@ func (s *state) expr(n ir.Node) *ssa.Value {
// SSA, then load just the selected field. This
// prevents false memory dependencies in race/msan
// instrumentation.
if ir.IsAssignable(n) && !s.canSSA(n) {
if ir.IsAddressable(n) && !s.canSSA(n) {
p := s.addr(n)
return s.load(n.Type(), p)
}

View File

@ -842,7 +842,7 @@ func tcSlice(n *ir.SliceExpr) ir.Node {
return n
}
if l.Type().IsArray() {
if !ir.IsAssignable(n.X) {
if !ir.IsAddressable(n.X) {
base.Errorf("invalid operation %v (slice of unaddressable value)", n)
n.SetType(nil)
return n

View File

@ -1638,7 +1638,7 @@ func nonexported(sym *types.Sym) bool {
}
func checklvalue(n ir.Node, verb string) {
if !ir.IsAssignable(n) {
if !ir.IsAddressable(n) {
base.Errorf("cannot %s %v", verb, n)
}
}
@ -1656,7 +1656,7 @@ func checkassign(stmt ir.Node, n ir.Node) {
}
}
if ir.IsAssignable(n) {
if ir.IsAddressable(n) {
return
}
if n.Op() == ir.OINDEXMAP {

View File

@ -155,7 +155,7 @@ func walkCompare(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
// Chose not to inline. Call equality function directly.
if !inline {
// eq algs take pointers; cmpl and cmpr must be addressable
if !ir.IsAssignable(cmpl) || !ir.IsAssignable(cmpr) {
if !ir.IsAddressable(cmpl) || !ir.IsAddressable(cmpr) {
base.Fatalf("arguments of comparison must be lvalues - %v %v", cmpl, cmpr)
}

View File

@ -178,7 +178,7 @@ func walkConvInterface(n *ir.ConvExpr, init *ir.Nodes) ir.Node {
// with a non-interface, especially in a switch on interface value
// with non-interface cases, is not visible to order.stmt, so we
// have to fall back on allocating a temp here.
if !ir.IsAssignable(v) {
if !ir.IsAddressable(v) {
v = copyExpr(v, v.Type(), init)
}
v = typecheck.NodAddr(v)

View File

@ -429,7 +429,7 @@ func safeExpr(n ir.Node, init *ir.Nodes) ir.Node {
}
// make a copy; must not be used as an lvalue
if ir.IsAssignable(n) {
if ir.IsAddressable(n) {
base.Fatalf("missing lvalue case in safeexpr: %v", n)
}
return cheapExpr(n, init)

View File

@ -235,7 +235,7 @@ func (o *orderState) safeExpr(n ir.Node) ir.Node {
// because we emit explicit VARKILL instructions marking the end of those
// temporaries' lifetimes.
func isaddrokay(n ir.Node) bool {
return ir.IsAssignable(n) && (n.Op() != ir.ONAME || n.(*ir.Name).Class_ == ir.PEXTERN || ir.IsAutoTmp(n))
return ir.IsAddressable(n) && (n.Op() != ir.ONAME || n.(*ir.Name).Class_ == ir.PEXTERN || ir.IsAutoTmp(n))
}
// addrTemp ensures that n is okay to pass by address to runtime routines.