aboutsummaryrefslogtreecommitdiff
path: root/cover
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2015-01-07 12:46:00 +1100
committerAndrew Gerrand <adg@golang.org>2015-01-07 02:00:16 +0000
commit57335a8a8f27199b135705be1f8dca2e2441c67b (patch)
tree29c2d519a749133e0ec39fe05f93fdf08669569f /cover
parentc836fe615a448dbf9ff5448c1aa657479a0d0aeb (diff)
downloadgolang-x-tools-57335a8a8f27199b135705be1f8dca2e2441c67b.tar.gz
cover: accept inaccurate block endings
When cover is used with cgo packages, the coverage profile is produced from the cgo-generated Go source files, so the profile will reference line and column numbers from that generated source, even though it names the original file. This is okay in general because the cgo-generated Go source files are very similar to the original, with one significant exception: the original source may refer to C identifiers such as C.foo(), but the cgo tool generates source that rewrites these mentions to something like _Cfunc_foo. This means that column numbers in coverage profiles might be higher than they should be, so be lenient when interpreting them. Update golang/go#9479 Change-Id: Ic3abef07471614101ce0c686d35b85e7e5e6a777 Reviewed-on: https://go-review.googlesource.com/2410 Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'cover')
-rw-r--r--cover/profile.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/cover/profile.go b/cover/profile.go
index 83efb0b3c..a53bf4ea2 100644
--- a/cover/profile.go
+++ b/cover/profile.go
@@ -162,7 +162,7 @@ func (p *Profile) Boundaries(src []byte) (boundaries []Boundary) {
if b.StartLine == line && b.StartCol == col {
boundaries = append(boundaries, boundary(si, true, b.Count))
}
- if b.EndLine == line && b.EndCol == col {
+ if b.EndLine == line && b.EndCol == col || line > b.EndLine {
boundaries = append(boundaries, boundary(si, false, 0))
bi++
continue // Don't advance through src; maybe the next block starts here.