]> Cypherpunks repositories - gostls13.git/commit
cmd/cover: skip function declarations with blank names
authorzikaeroh <zikaeroh@gmail.com>
Thu, 12 Mar 2020 00:02:50 +0000 (17:02 -0700)
committerBryan C. Mills <bcmills@google.com>
Fri, 13 Mar 2020 14:29:27 +0000 (14:29 +0000)
commitc3b9042132efc4e9f3485cd12b07acd1ca9c7d57
tree472a49b2f8ca66a00cbfd1fce856e9ec407ea76b
parentc6bcdeafd2a2f11373dec9a82fccc75d332cd0cc
cmd/cover: skip function declarations with blank names

Function declarations with blank ("_") names do not introduce a binding,
and therefore cannot be referenced or executed (in fact, they do not
make it into the final compiled binary at all). As such, counters
defined while annotating their bodies will always be zero.

These types of functions are commonly used to create compile-time
checks (e.g., stringer) which are not expected to be executed.

Skip over these functions when annotating a file, preventing the unused
counters from being generated and appearing as uncovered lines in
coverage reports.

Fixes #36264

Change-Id: I6b516cf43c430a6248d68d5f483a3902253fbdab
Reviewed-on: https://go-review.googlesource.com/c/go/+/223117
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/cover/cover.go
src/cmd/go/testdata/script/cover_blank_func_decl.txt [new file with mode: 0644]