Node.Addrtaken is treated as a bool, so make it a bool.
I'll start to batch these changes if they are simple.
Change-Id: I02a3d1131efc4e12b78b83372c1b50f8b160c194
Reviewed-on: https://go-review.googlesource.com/6911
Reviewed-by: Ian Lance Taylor <iant@golang.org>
v.Outerexpr = nil
// out parameters will be assigned to implicitly upon return.
- if outer.Class != PPARAMOUT && v.Closure.Addrtaken == 0 && v.Closure.Assigned == 0 && v.Type.Width <= 128 {
+ if outer.Class != PPARAMOUT && !v.Closure.Addrtaken && v.Closure.Assigned == 0 && v.Type.Width <= 128 {
v.Byval = 1
} else {
- v.Closure.Addrtaken = 1
+ v.Closure.Addrtaken = true
outer = Nod(OADDR, outer, nil)
}
fp += fmt.Sprintf(" embedded(%d)", n.Embedded)
}
- if n.Addrtaken != 0 {
+ if n.Addrtaken {
fp += " addrtaken"
}
// non-tail-call return instructions; see note above
// the for loop for details.
case PPARAMOUT:
- if node.Addrtaken == 0 && prog.To.Type == obj.TYPE_NONE {
+ if !node.Addrtaken && prog.To.Type == obj.TYPE_NONE {
bvset(uevar, int32(i))
}
}
for i, node := range vars {
switch node.Class &^ PHEAP {
case PPARAM:
- if node.Addrtaken != 0 {
+ if node.Addrtaken {
bvset(avarinit, int32(i))
}
bvset(varkill, int32(i))
if pos >= int32(len(vars)) || vars[pos] != from.Node {
Fatal("bad bookkeeping in liveness %v %d", Nconv(from.Node.(*Node), 0), pos)
}
- if ((from.Node).(*Node)).Addrtaken != 0 {
+ if ((from.Node).(*Node)).Addrtaken {
bvset(avarinit, pos)
} else {
if info.Flags&(LeftRead|LeftAddr) != 0 {
if pos >= int32(len(vars)) || vars[pos] != to.Node {
Fatal("bad bookkeeping in liveness %v %d", Nconv(to.Node.(*Node), 0), pos)
}
- if ((to.Node).(*Node)).Addrtaken != 0 {
+ if ((to.Node).(*Node)).Addrtaken {
if prog.As != obj.AVARKILL {
bvset(avarinit, pos)
}
p = "^"
}
a := ""
- if node.Addrtaken != 0 {
+ if node.Addrtaken {
a = "@"
}
fmt.Printf(" %v%s%s", Nconv(node, 0), p, a)
// If we were better about _ elision, _ = &x would suffice too.
// The broader := in a closure problem is mentioned in a comment in
// closure.c:/^typecheckclosure and dcl.c:/^oldname.
- if node.Addrtaken != 0 {
+ if node.Addrtaken {
v.addr = 1
}
* assignment to it.
*/
func localexpr(n *Node, t *Type, init **NodeList) *Node {
- if n.Op == ONAME && (n.Addrtaken == 0 || strings.HasPrefix(n.Sym.Name, "autotmp_")) && (n.Class == PAUTO || n.Class == PPARAM || n.Class == PPARAMOUT) && convertop(n.Type, t, nil) == OCONVNOP {
+ if n.Op == ONAME && (!n.Addrtaken || strings.HasPrefix(n.Sym.Name, "autotmp_")) && (n.Class == PAUTO || n.Class == PPARAM || n.Class == PPARAMOUT) && convertop(n.Type, t, nil) == OCONVNOP {
return n
}
Isddd uint8
Readonly bool
Implicit uint8
- Addrtaken uint8 // address taken, even if not moved to heap
+ Addrtaken bool // address taken, even if not moved to heap
Assigned uint8 // is the variable ever assigned to
Captured uint8 // is the variable captured by a closure
Byval uint8 // is the variable captured by value or by reference
r := outervalue(n.Left)
var l *Node
for l = n.Left; l != r; l = l.Left {
- l.Addrtaken = 1
+ l.Addrtaken = true
if l.Closure != nil {
- l.Closure.Addrtaken = 1
+ l.Closure.Addrtaken = true
}
}
if l.Orig != l && l.Op == ONAME {
Fatal("found non-orig name node %v", Nconv(l, 0))
}
- l.Addrtaken = 1
+ l.Addrtaken = true
if l.Closure != nil {
- l.Closure.Addrtaken = 1
+ l.Closure.Addrtaken = true
}
defaultlit(&n.Left, nil)
l = n.Left
switch l.N.Class {
case PPARAMOUT,
PPARAMOUT | PHEAP:
- return int(l.N.Addrtaken)
+ return bool2int(l.N.Addrtaken)
// stop early - parameters are over
case PAUTO,
case PAUTO,
PPARAM,
PPARAMOUT:
- if n.Addrtaken != 0 {
+ if n.Addrtaken {
varwrite = 1
continue
}
case PAUTO,
PPARAM,
PPARAMOUT:
- if n.Addrtaken == 0 {
+ if !n.Addrtaken {
return true
}
}