if l == n.Left {
return n
}
- a := *n
- a.Orig = &a
+ a := n.copy()
+ a.Orig = a
a.Left = l
- return typecheck(&a, Erv)
+ return typecheck(a, Erv)
}
return o.copyExpr(n, n.Type, false)
if l == n.Left {
return n
}
- a := *n
- a.Orig = &a
+ a := n.copy()
+ a.Orig = a
a.Left = l
- return typecheck(&a, Erv)
+ return typecheck(a, Erv)
case ODOTPTR, OIND:
l := o.cheapExpr(n.Left)
if l == n.Left {
return n
}
- a := *n
- a.Orig = &a
+ a := n.copy()
+ a.Orig = a
a.Left = l
- return typecheck(&a, Erv)
+ return typecheck(a, Erv)
case OINDEX, OINDEXMAP:
var l *Node
if l == n.Left && r == n.Right {
return n
}
- a := *n
- a.Orig = &a
+ a := n.copy()
+ a.Orig = a
a.Left = l
a.Right = r
- return typecheck(&a, Erv)
+ return typecheck(a, Erv)
default:
Fatalf("ordersafeexpr %v", n.Op)
// nodpc is the PC of the caller as extracted by
// getcallerpc. We use -widthptr(FP) for x86.
// BUG: this will not work on arm.
- nodpc := *nodfp
+ nodpc := nodfp.copy()
nodpc.Type = types.Types[TUINTPTR]
nodpc.Xoffset = int64(-Widthptr)
savedLineno := lineno
lineno = src.NoXPos
- nd := mkcall("racefuncenter", nil, nil, &nodpc)
+ nd := mkcall("racefuncenter", nil, nil, nodpc)
fn.Func.Enter.Prepend(nd)
nd = mkcall("racefuncexit", nil, nil)
fn.Func.Exit.Append(nd)
- fn.Func.Dcl = append(fn.Func.Dcl, &nodpc)
+ fn.Func.Dcl = append(fn.Func.Dcl, nodpc)
lineno = savedLineno
}
// copy slice
a := inittemps[r]
- n := *l
+ n := l.copy()
n.Xoffset = l.Xoffset + int64(array_array)
- gdata(&n, nod(OADDR, a, nil), Widthptr)
+ gdata(n, nod(OADDR, a, nil), Widthptr)
n.Xoffset = l.Xoffset + int64(array_nel)
- gdata(&n, r.Right, Widthptr)
+ gdata(n, r.Right, Widthptr)
n.Xoffset = l.Xoffset + int64(array_cap)
- gdata(&n, r.Right, Widthptr)
+ gdata(n, r.Right, Widthptr)
return true
case OARRAYLIT, OSTRUCTLIT:
p := initplans[r]
- n := *l
+ n := l.copy()
for i := range p.E {
e := &p.E[i]
n.Xoffset = l.Xoffset + e.Xoffset
n.Type = e.Expr.Type
if e.Expr.Op == OLITERAL {
- gdata(&n, e.Expr, int(n.Type.Width))
+ gdata(n, e.Expr, int(n.Type.Width))
} else {
- ll := nod(OXXX, nil, nil)
- *ll = n
+ ll := n.copy()
ll.Orig = ll // completely separate copy
if !staticassign(ll, e.Expr, out) {
// Requires computation, but we're
// copying someone else's computation.
- rr := nod(OXXX, nil, nil)
-
- *rr = *orig
+ rr := orig.copy()
rr.Orig = rr // completely separate copy
rr.Type = ll.Type
rr.Xoffset += e.Xoffset
ta := types.NewArray(r.Type.Elem(), bound)
a := staticname(ta)
inittemps[r] = a
- n := *l
+ n := l.copy()
n.Xoffset = l.Xoffset + int64(array_array)
- gdata(&n, nod(OADDR, a, nil), Widthptr)
+ gdata(n, nod(OADDR, a, nil), Widthptr)
n.Xoffset = l.Xoffset + int64(array_nel)
- gdata(&n, r.Right, Widthptr)
+ gdata(n, r.Right, Widthptr)
n.Xoffset = l.Xoffset + int64(array_cap)
- gdata(&n, r.Right, Widthptr)
+ gdata(n, r.Right, Widthptr)
// Fall through to init underlying array.
l = a
initplan(r)
p := initplans[r]
- n := *l
+ n := l.copy()
for i := range p.E {
e := &p.E[i]
n.Xoffset = l.Xoffset + e.Xoffset
n.Type = e.Expr.Type
if e.Expr.Op == OLITERAL {
- gdata(&n, e.Expr, int(n.Type.Width))
+ gdata(n, e.Expr, int(n.Type.Width))
} else {
setlineno(e.Expr)
- a := nod(OXXX, nil, nil)
- *a = n
+ a := n.copy()
a.Orig = a // completely separate copy
if !staticassign(a, e.Expr, out) {
*out = append(*out, nod(OAS, a, e.Expr))
// Copy val directly into n.
n.Type = val.Type
setlineno(val)
- a := nod(OXXX, nil, nil)
- *a = n
- a.Orig = a
- if !staticassign(a, val, out) {
- *out = append(*out, nod(OAS, a, val))
+ a := n
+ a.Orig = &a
+ if !staticassign(&a, val, out) {
+ *out = append(*out, nod(OAS, &a, val))
}
} else {
// Construct temp to hold val, write pointer to temp into n.
return n
}
+func (n *Node) copy() *Node {
+ n2 := *n
+ return &n2
+}
+
// methcmp sorts methods by name with exported methods first,
// and then non-exported methods by their package path.
type methcmp []*types.Field
switch n.Op {
default:
- m := *n
- m.Orig = &m
+ m := n.copy()
+ m.Orig = m
m.Left = treecopy(n.Left, pos)
m.Right = treecopy(n.Right, pos)
m.List.Set(listtreecopy(n.List.Slice(), pos))
Dump("treecopy", n)
Fatalf("treecopy Name")
}
- return &m
+ return m
case OPACK:
// OPACK nodes are never valid in const value declarations,
if l == n.Left {
return n
}
- r := nod(OXXX, nil, nil)
- *r = *n
+ r := n.copy()
r.Left = l
r = typecheck(r, Erv)
r = walkexpr(r, init)
if l == n.Left {
return n
}
- a := nod(OXXX, nil, nil)
- *a = *n
+ a := n.copy()
a.Left = l
a = walkexpr(a, init)
return a
if l == n.Left && r == n.Right {
return n
}
- a := nod(OXXX, nil, nil)
- *a = *n
+ a := n.copy()
a.Left = l
a.Right = r
a = walkexpr(a, init)