diff options
author | Russ Cox <rsc@golang.org> | 2020-12-10 18:48:33 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2020-12-17 04:43:53 +0000 |
commit | 9c384e881e28d322b854ac702ce8f052868f5f41 (patch) | |
tree | 4a066b7c256bc8814818a8272ec4f3546bfd66cd /src/cmd/compile/internal/gc/export.go | |
parent | be64c8becebace2304e6c16408f6988d1da55900 (diff) | |
download | go-9c384e881e28d322b854ac702ce8f052868f5f41.tar.gz go-9c384e881e28d322b854ac702ce8f052868f5f41.zip |
[dev.regabi] cmd/compile: cleanup for concrete types - mop-up
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL handles all the little files that are left.
Passes buildall w/ toolstash -cmp.
Change-Id: I6588c92dbbdd37342a77b365d70e02134a033d2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/277932
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/gc/export.go')
-rw-r--r-- | src/cmd/compile/internal/gc/export.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/gc/export.go b/src/cmd/compile/internal/gc/export.go index 593dd3b2f8..16d45a00aa 100644 --- a/src/cmd/compile/internal/gc/export.go +++ b/src/cmd/compile/internal/gc/export.go @@ -74,7 +74,7 @@ func dumpexport(bout *bio.Writer) { } } -func importsym(ipkg *types.Pkg, s *types.Sym, op ir.Op) ir.Node { +func importsym(ipkg *types.Pkg, s *types.Sym, op ir.Op) *ir.Name { n := ir.AsNode(s.PkgDef()) if n == nil { // iimport should have created a stub ONONAME @@ -92,7 +92,7 @@ func importsym(ipkg *types.Pkg, s *types.Sym, op ir.Op) ir.Node { if n.Op() != ir.ONONAME && n.Op() != op { redeclare(base.Pos, s, fmt.Sprintf("during import %q", ipkg.Path)) } - return n + return n.(*ir.Name) } // importtype returns the named type declared by symbol s. @@ -102,7 +102,6 @@ func importtype(ipkg *types.Pkg, pos src.XPos, s *types.Sym) *types.Type { n := importsym(ipkg, s, ir.OTYPE) if n.Op() != ir.OTYPE { t := types.NewNamed(n) - n.SetOp(ir.OTYPE) n.SetPos(pos) n.SetType(t) @@ -121,7 +120,7 @@ func importtype(ipkg *types.Pkg, pos src.XPos, s *types.Sym) *types.Type { func importobj(ipkg *types.Pkg, pos src.XPos, s *types.Sym, op ir.Op, ctxt ir.Class, t *types.Type) ir.Node { n := importsym(ipkg, s, op) if n.Op() != ir.ONONAME { - if n.Op() == op && (n.Class() != ctxt || !types.Identical(n.Type(), t)) { + if n.Op() == op && (op == ir.ONAME && n.Class() != ctxt || !types.Identical(n.Type(), t)) { redeclare(base.Pos, s, fmt.Sprintf("during import %q", ipkg.Path)) } return nil |