diff options
author | Matthew Dempsky <mdempsky@google.com> | 2019-09-12 10:18:03 -0700 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2019-09-16 15:30:51 +0000 |
commit | 606019cb4b1c8fb57e5a83747ee0aff1054291d8 (patch) | |
tree | 04ff2c4bbf57c97d339663d2d46999702983121d /test/escape_field.go | |
parent | 4ae25ff1405f9d6b25f40141f42196e8f142f207 (diff) | |
download | go-606019cb4b1c8fb57e5a83747ee0aff1054291d8.tar.gz go-606019cb4b1c8fb57e5a83747ee0aff1054291d8.zip |
cmd/compile: trim function name prefix from escape diagnostics
This information is redundant with the position information already
provided. Also, no other -m diagnostics print out function name.
While here, report parameter leak diagnostics against the parameter
declaration position rather than the function, and use Warnl for
"moved to heap" messages.
Test cases updated programmatically by removing the first word from
every "no match for" error emitted by run.go:
go run run.go |& \
sed -E -n 's/^(.*):(.*): no match for `([^ ]* (.*))` in:$/\1!\2!\3!\4/p' | \
while IFS='!' read -r fn line before after; do
before=$(echo "$before" | sed 's/[.[\*^$()+?{|]/\\&/g')
after=$(echo "$after" | sed -E 's/(\&|\\)/\\&/g')
fn=$(find . -name "${fn}" | head -1)
sed -i -E -e "${line}s/\"${before}\"/\"${after}\"/" "${fn}"
done
Passes toolstash-check.
Change-Id: I6e02486b1409e4a8dbb2b9b816d22095835426b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/195040
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'test/escape_field.go')
-rw-r--r-- | test/escape_field.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/test/escape_field.go b/test/escape_field.go index 8bb1a99553..bf1dfb18ff 100644 --- a/test/escape_field.go +++ b/test/escape_field.go @@ -127,14 +127,14 @@ func field12() { func field13() { i := 0 // ERROR "moved to heap: i$" - x := &X{p1: &i} // ERROR "field13 &X literal does not escape$" + x := &X{p1: &i} // ERROR "&X literal does not escape$" sink = x.p1 } func field14() { i := 0 // ERROR "moved to heap: i$" // BAD: &i should not escape - x := &X{p1: &i} // ERROR "field14 &X literal does not escape$" + x := &X{p1: &i} // ERROR "&X literal does not escape$" sink = x.p2 } @@ -149,7 +149,7 @@ func field16() { var x X // BAD: &i should not escape x.p1 = &i - var iface interface{} = x // ERROR "field16 x does not escape" + var iface interface{} = x // ERROR "x does not escape" x1 := iface.(X) sink = x1.p2 } @@ -158,7 +158,7 @@ func field17() { i := 0 // ERROR "moved to heap: i$" var x X x.p1 = &i - var iface interface{} = x // ERROR "field17 x does not escape" + var iface interface{} = x // ERROR "x does not escape" x1 := iface.(X) sink = x1.p1 } @@ -168,7 +168,7 @@ func field18() { var x X // BAD: &i should not escape x.p1 = &i - var iface interface{} = x // ERROR "field18 x does not escape" + var iface interface{} = x // ERROR "x does not escape" y, _ := iface.(Y) // Put X, but extracted Y. The cast will fail, so y is zero initialized. sink = y // ERROR "y escapes to heap" } |