]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: use ir.NewNameAt in SubstArgTypes
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 4 Jan 2021 03:37:48 +0000 (10:37 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 4 Jan 2021 08:38:01 +0000 (08:38 +0000)
So we can remove Name.CloneName now.

Passes toolstash -cmp.

Change-Id: I63e57ba52a7031e06fe9c4ee9aee7de6dec70792
Reviewed-on: https://go-review.googlesource.com/c/go/+/281312
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/compile/internal/ir/name.go
src/cmd/compile/internal/typecheck/syms.go

index afee6e1308fd49b6c9c16f8caa48d9d40eb121c9..689ef983f61f7d5721c1295dace47a66064a2c58 100644 (file)
@@ -147,12 +147,6 @@ func (n *Name) copy() Node                         { panic(n.no("copy")) }
 func (n *Name) doChildren(do func(Node) bool) bool { return false }
 func (n *Name) editChildren(edit func(Node) Node)  {}
 
-// CloneName makes a cloned copy of the name.
-// It's not ir.Copy(n) because in general that operation is a mistake on names,
-// which uniquely identify variables.
-// Callers must use n.CloneName to make clear they intend to create a separate name.
-func (n *Name) CloneName() *Name { c := *n; return &c }
-
 // TypeDefn returns the type definition for a named OTYPE.
 // That is, given "type T Defn", it returns Defn.
 // It is used by package types.
index 2251062e16c6e63af43a8b58e21641d6fb72373f..01c03b5f9f714925e0f4ec36629a1221badf935b 100644 (file)
@@ -26,12 +26,12 @@ func LookupRuntime(name string) *ir.Name {
 // The result of SubstArgTypes MUST be assigned back to old, e.g.
 //     n.Left = SubstArgTypes(n.Left, t1, t2)
 func SubstArgTypes(old *ir.Name, types_ ...*types.Type) *ir.Name {
-       n := old.CloneName()
-
        for _, t := range types_ {
                types.CalcSize(t)
        }
-       n.SetType(types.SubstAny(n.Type(), &types_))
+       n := ir.NewNameAt(old.Pos(), old.Sym())
+       n.Class_ = old.Class()
+       n.SetType(types.SubstAny(old.Type(), &types_))
        if len(types_) > 0 {
                base.Fatalf("substArgTypes: too many argument types")
        }