[Format] Fix crash when hitting eof while lexing JS template string
authorSam McCall <sam.mccall@gmail.com>
Thu, 6 Oct 2022 11:10:19 +0000 (13:10 +0200)
committerSam McCall <sam.mccall@gmail.com>
Thu, 6 Oct 2022 15:00:41 +0000 (17:00 +0200)
commit882a05afa17f2a8863978027f562934cd7a7d179
treed458deeb6f5c3c6b77eeb6c4004d965a483368b8
parentd89d45ca9a6e51be388a6ff3893d59e54748b928
[Format] Fix crash when hitting eof while lexing JS template string

Different loop termination conditions resulted in confusion of whether
*Offset was intended to be inside or outside the token.
This ultimately led to constructing an out-of-range SourceLocation.

Fix by making Offset consistently point *after* the token.

Differential Revision: https://reviews.llvm.org/D135356
clang/lib/Format/FormatTokenLexer.cpp
clang/unittests/Format/FormatTestJS.cpp