cmd/compile, etc: use nameOff for rtype string

linux/amd64:
	cmd/go:   -8KB (basically nothing)

linux/amd64 PIE:
	cmd/go: -191KB (1.6%)
	jujud:  -1.5MB (1.9%)

Updates #6853
Fixes #15064

Change-Id: I0adbb95685e28be92e8548741df0e11daa0a9b5f
Reviewed-on: https://go-review.googlesource.com/21777
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
David Crawshaw 2016-04-07 16:29:16 -04:00
parent bb52ceafea
commit 1492e7db05
14 changed files with 231 additions and 145 deletions

View file

@ -4175,12 +4175,12 @@ func TestStructOfExportRules(t *testing.T) {
},
{
field: StructField{Name: "", Type: TypeOf(ΦType{})},
mustPanic: true, // TODO(sbinet): creating a struct with UTF-8 fields not supported
mustPanic: false,
exported: true,
},
{
field: StructField{Name: "", Type: TypeOf(φType{})},
mustPanic: true, // TODO(sbinet): creating a struct with UTF-8 fields not supported
mustPanic: false,
exported: false,
},
{
@ -5674,6 +5674,42 @@ func TestNames(t *testing.T) {
}
}
func TestExported(t *testing.T) {
type ΦExported struct{}
type φUnexported struct{}
type BigP *big
type P int
type p *P
type P2 p
type p3 p
type exportTest struct {
v interface{}
want bool
}
exportTests := []exportTest{
{D1{}, true},
{(*D1)(nil), true},
{big{}, false},
{(*big)(nil), false},
{(BigP)(nil), true},
{(*BigP)(nil), true},
{ΦExported{}, true},
{φUnexported{}, false},
{P(0), true},
{(p)(nil), false},
{(P2)(nil), true},
{(p3)(nil), false},
}
for i, test := range exportTests {
typ := TypeOf(test.v)
if got := IsExported(typ); got != test.want {
t.Errorf("%d: %s exported=%v, want %v", i, typ.Name(), got, test.want)
}
}
}
type embed struct {
EmbedWithUnexpMeth
}