[tools] gopls/internal/util/asm: preserve offsets in CRLF files

0 views
Skip to first unread message

Alex Putman (Gerrit)

unread,
3:23 PM (1 hour ago) 3:23 PM
to race quite, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Hongxiang Jiang, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, golang-co...@googlegroups.com

Alex Putman submitted the change

Change information

Commit message:
gopls/internal/util/asm: preserve offsets in CRLF files

bufio.ScanLines removes the carriage return from CRLF line tokens.
The assembly parser previously advanced its source offset using the
length of the stripped token plus one byte for '\n'. As a result,
identifier offsets drifted left by one byte for every preceding CRLF
line.

Range directly over the raw lines returned by bytes.SplitSeq. Advance
the source offset using each raw line's length, and strip a trailing
carriage return only from the text used for parsing.

Add LF and CRLF regression tests that verify identifier offsets and
TEXT function boundaries.

Fixes golang/go#80666
Change-Id: I6834d36a8b7a4ea37b12693654e33e9129355be4
Reviewed-by: Alan Donovan <adon...@google.com>
Auto-Submit: Alan Donovan <adon...@google.com>
Reviewed-by: Alex Putman <apu...@golang.org>
Files:
  • M gopls/internal/util/asm/parse.go
  • M gopls/internal/util/asm/parse_test.go
Change size: M
Delta: 2 files changed, 74 insertions(+), 10 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I6834d36a8b7a4ea37b12693654e33e9129355be4
Gerrit-Change-Number: 808480
Gerrit-PatchSet: 5
Gerrit-Owner: race quite <quit...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alex Putman <apu...@golang.org>
Gerrit-Reviewer: race quite <quit...@gmail.com>
Gerrit-CC: Hongxiang Jiang <hxj...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages