Skip to content

Commit

Permalink
cmd/compile: simplify exporting ONAME nodes
Browse files Browse the repository at this point in the history
These two special cases are unnecessary:

1) "~b%d" references only appear during walk, to handle "return"
statements implicitly assigning to blank result parameters. Even if
they could appear, the "inlined and customized version" accidentally
diverged from p.sym in golang.org/cl/33911.

2) The Vargen case is already identical to the default case, and it
never overlaps with the remaining "T.method" case.

Passes toolstash-check.

Change-Id: I03f7e5b75b707b43afc8ed6eb90f43ba93ed17ae
Reviewed-on: https://go-review.googlesource.com/63272
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
  • Loading branch information
mdempsky committed Sep 13, 2017
1 parent 3098cf0 commit c64e793
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/cmd/compile/internal/gc/bexport.go
Expand Up @@ -1190,22 +1190,6 @@ func (p *exporter) expr(n *Node) {
p.value(n.Val())

case ONAME:
// Special case: name used as local variable in export.
// _ becomes ~b%d internally; print as _ for export
if n.Sym != nil && n.Sym.Name[0] == '~' && n.Sym.Name[1] == 'b' {
p.op(ONAME)
p.pos(n)
p.string("_") // inlined and customized version of p.sym(n)
break
}

if n.Sym != nil && !isblank(n) && n.Name.Vargen > 0 {
p.op(ONAME)
p.pos(n)
p.sym(n)
break
}

// Special case: explicit name of func (*T) method(...) is turned into pkg.(*T).method,
// but for export, this should be rendered as (*pkg.T).meth.
// These nodes have the special property that they are names with a left OTYPE and a right ONAME.
Expand Down

0 comments on commit c64e793

Please sign in to comment.