aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/ld/deadcode.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-04-18 23:08:36 -0400
committerCherry Zhang <cherryyz@google.com>2020-04-19 03:23:59 +0000
commitaf9ab6b2e852c4177db06cf91edc7a869b4cb93e (patch)
treef0cce77d09f2d7e10b1cccf06b61138ba1359d9e /src/cmd/link/internal/ld/deadcode.go
parenta32262d4625e6f54cedd765e4807c215d1deb992 (diff)
downloadgo-af9ab6b2e852c4177db06cf91edc7a869b4cb93e.tar.xz
cmd/link: check for reflect.Value.MethodByName explicitly
Currently we only check for reflect.Value.Method. And reflect.Value.MethodByName is covered since it calls reflect.Value.Method internally. But it is brittle to rely on implementation detail of the reflect package. Check for MethodByName explicitly. Change-Id: Ifa8920e997524003dade03abc4fb3c4e64723643 Reviewed-on: https://go-review.googlesource.com/c/go/+/228881 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/link/internal/ld/deadcode.go')
-rw-r--r--src/cmd/link/internal/ld/deadcode.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go
index b5bc508356..ae676935fc 100644
--- a/src/cmd/link/internal/ld/deadcode.go
+++ b/src/cmd/link/internal/ld/deadcode.go
@@ -22,7 +22,8 @@ import (
//
// 1. direct call
// 2. through a reachable interface type
-// 3. reflect.Value.Method, or reflect.Type.Method
+// 3. reflect.Value.Method (or MethodByName), or reflect.Type.Method
+// (or MethodByName)
//
// The first case is handled by the flood fill, a directly called method
// is marked as reachable.
@@ -33,7 +34,7 @@ import (
// as reachable. This is extremely conservative, but easy and correct.
//
// The third case is handled by looking to see if any of:
-// - reflect.Value.Method is reachable
+// - reflect.Value.Method or MethodByName is reachable
// - reflect.Type.Method or MethodByName is called (through the
// REFLECTMETHOD attribute marked by the compiler).
// If any of these happen, all bets are off and all exported methods