cmd/compile: treat empty and absent struct field tags as identical

Fixes #15439.

Change-Id: I5a32384c46e20f8db6968e5a9e854c45ab262fe4
Reviewed-on: https://go-review.googlesource.com/22429
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Matthew Dempsky 2016-04-25 13:24:48 -07:00
parent 6f3f02f80d
commit e48a2958d1
11 changed files with 48 additions and 56 deletions

View file

@ -1181,7 +1181,7 @@ func escassign(e *EscState, dst, src *Node, step *EscStep) {
var tags [1 << (bitsPerOutputInTag + EscReturnBits)]string
// mktag returns the string representation for an escape analysis tag.
func mktag(mask int) *string {
func mktag(mask int) string {
switch mask & EscMask {
case EscNone, EscReturn:
break
@ -1191,22 +1191,22 @@ func mktag(mask int) *string {
}
if mask < len(tags) && tags[mask] != "" {
return &tags[mask]
return tags[mask]
}
s := fmt.Sprintf("esc:0x%x", mask)
if mask < len(tags) {
tags[mask] = s
}
return &s
return s
}
// parsetag decodes an escape analysis tag and returns the esc value.
func parsetag(note *string) uint16 {
if note == nil || !strings.HasPrefix(*note, "esc:") {
func parsetag(note string) uint16 {
if !strings.HasPrefix(note, "esc:") {
return EscUnknown
}
n, _ := strconv.ParseInt((*note)[4:], 0, 0)
n, _ := strconv.ParseInt(note[4:], 0, 0)
em := uint16(n)
if em == 0 {
return EscNone
@ -1268,7 +1268,7 @@ func describeEscape(em uint16) string {
// escassignfromtag models the input-to-output assignment flow of one of a function
// calls arguments, where the flow is encoded in "note".
func escassignfromtag(e *EscState, note *string, dsts Nodes, src *Node) uint16 {
func escassignfromtag(e *EscState, note string, dsts Nodes, src *Node) uint16 {
em := parsetag(note)
if src.Op == OLITERAL {
return em
@ -1997,7 +1997,7 @@ func esctag(e *EscState, func_ *Node) {
}
Warnl(func_.Lineno, "%v assuming %v is unsafe uintptr", funcSym(func_), name)
}
t.Note = &unsafeUintptrTag
t.Note = unsafeUintptrTag
}
}