diff options
author | Keith Randall <khr@golang.org> | 2022-02-14 14:57:55 -0800 |
---|---|---|
committer | Heschi Kreinick <heschi@google.com> | 2022-05-09 20:27:15 +0000 |
commit | feec92c42341ce45f00e7f45341e12a7fef78e53 (patch) | |
tree | 3bb200b9e650dbaf8853a1a281ae4ee5377855bf /src/cmd/internal/src/pos.go | |
parent | 04781d14d2d33acbaf70f77e3a58ae0f3c90757c (diff) | |
download | go-feec92c42341ce45f00e7f45341e12a7fef78e53.tar.gz go-feec92c42341ce45f00e7f45341e12a7fef78e53.zip |
[release-branch.go1.17] cmd/compile: drop column info when line number saturates
When line number saturates, we can end up getting non-monotonic
position info, because the start of the next line after line=lineMax,col=2
is line=lineMax,col=1.
Instead, if line==lineMax, make the column always 0 (no column info).
If the line number is wrong, having column info probably isn't that helpful.
Fixes #52095
Change-Id: If3d90472691b1f6163654f3505e2cb98467f2383
Reviewed-on: https://go-review.googlesource.com/c/go/+/385795
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
(cherry picked from commit 1de2344af16125ae2fabed226f2fbb40a150238c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/401315
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/cmd/internal/src/pos.go')
-rw-r--r-- | src/cmd/internal/src/pos.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/cmd/internal/src/pos.go b/src/cmd/internal/src/pos.go index b6816a56e0..373a22a7f2 100644 --- a/src/cmd/internal/src/pos.go +++ b/src/cmd/internal/src/pos.go @@ -389,9 +389,12 @@ func makeBogusLico() lico { } func makeLico(line, col uint) lico { - if line > lineMax { + if line >= lineMax { // cannot represent line, use max. line so we have some information line = lineMax + // Drop column information if line number saturates. + // Ensures line+col is monotonic. See issue 51193. + col = 0 } if col > colMax { // cannot represent column, use max. column so we have some information |