summaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/inline/inl.go
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-05-21 20:09:55 -0700
committerDan Scales <danscales@google.com>2021-05-24 16:01:17 +0000
commitb18b2d372e263dda8862c1eafef739403ba4521d (patch)
treec91c7f8790d3d677539333c49df0076b21491364 /src/cmd/compile/internal/inline/inl.go
parent5b1120fac7e234af44c09ec0db1982aa2c7b7357 (diff)
downloadgo-git-b18b2d372e263dda8862c1eafef739403ba4521d.tar.gz
[dev.typeparams] cmd/compile: fix case where we were copying a raw Node
Replace the raw Node copy with the creation of a new node, and the copying of the needed flags and fields. Change-Id: I636bf228ba28c0d5dc25f8366d82379d86ecd731 Reviewed-on: https://go-review.googlesource.com/c/go/+/322189 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Trust: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/inline/inl.go')
-rw-r--r--src/cmd/compile/internal/inline/inl.go26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go
index a6829e9835..bd453e40a5 100644
--- a/src/cmd/compile/internal/inline/inl.go
+++ b/src/cmd/compile/internal/inline/inl.go
@@ -1153,17 +1153,21 @@ func (subst *inlsubst) fields(oldt *types.Type) []*types.Field {
// clovar creates a new ONAME node for a local variable or param of a closure
// inside a function being inlined.
func (subst *inlsubst) clovar(n *ir.Name) *ir.Name {
- // TODO(danscales): want to get rid of this shallow copy, with code like the
- // following, but it is hard to copy all the necessary flags in a maintainable way.
- // m := ir.NewNameAt(n.Pos(), n.Sym())
- // m.Class = n.Class
- // m.SetType(n.Type())
- // m.SetTypecheck(1)
- //if n.IsClosureVar() {
- // m.SetIsClosureVar(true)
- //}
- m := &ir.Name{}
- *m = *n
+ m := ir.NewNameAt(n.Pos(), n.Sym())
+ m.Class = n.Class
+ m.SetType(n.Type())
+ m.SetTypecheck(1)
+ if n.IsClosureVar() {
+ m.SetIsClosureVar(true)
+ }
+ if n.Addrtaken() {
+ m.SetAddrtaken(true)
+ }
+ if n.Used() {
+ m.SetUsed(true)
+ }
+ m.Defn = n.Defn
+
m.Curfn = subst.newclofn
switch defn := n.Defn.(type) {