]> Cypherpunks repositories - gostls13.git/commit
cmd/gc: distinguish unnamed vs blank-named return variables better
authorRuss Cox <rsc@golang.org>
Fri, 14 Feb 2014 01:59:39 +0000 (20:59 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 14 Feb 2014 01:59:39 +0000 (20:59 -0500)
commita069cf048dcfcd4c657d59b40ff318c8ab09b65c
treecb55e77288611e0a7429ed2332cd5b87662981ef
parente5d742fcadf9677a40336d6cecd3ff464a94730f
cmd/gc: distinguish unnamed vs blank-named return variables better

Before, an unnamed return value turned into an ONAME node n with n->sym
named ~anon%d, and n->orig == n.

A blank-named return value turned into an ONAME node n with n->sym
named ~anon%d but n->orig == the original blank n. Code generation and
printing uses n->orig, so that this node formatted as _.

But some code does not use n->orig. In particular the liveness code does
not know about the n->orig convention and so mishandles blank identifiers.
It is possible to fix but seemed better to avoid the confusion entirely.

Now the first kind of node is named ~r%d and the second ~b%d; both have
n->orig == n, so that it doesn't matter whether code uses n or n->orig.

After this change the ->orig field is only used for other kinds of expressions,
not for ONAME nodes.

This requires distinguishing ~b from ~r names in a few places that care.
It fixes a liveness analysis bug without actually changing the liveness code.

TBR=ken2
CC=golang-codereviews
https://golang.org/cl/63630043
src/cmd/gc/dcl.c
src/cmd/gc/fmt.c
src/cmd/gc/walk.c
test/escape5.go
test/live.go