[PR 95149] reimplement raw literal lexing
Nathan Sidwell
nathan@acm.org
Tue May 19 18:41:27 GMT 2020
pr95149 is a false positive static analysis checker. But it encouranged
me to fix raw string lexing, which does contain a complicated macro and
pointers to local variables. The reimplementation does away with that
macro. Part of the complication is we need to undo some of the fresh
line processing -- trigraph notes and escaped line continuations. But
the undone characters need to go through the raw string processing, as
they can legitimately be part of the prefix marker. however, in this
reformulation we only process one line marker at a time[*], so there's a
limited number of undone characters. We can arrange the buffering to
make sure we don't split such an append sequence, and then simply take
the characters from the append buffer.
The prefix scanner had a switch statement, which I discovered was not
optimized as well as an if of a bunch of explicit comparisons (pr 95208
filed).
Finally I adjusted the failure mode. When we get a bad prefix, we lex
up until the next '"', thus often swallowing the whole raw string.
Previously we'd bail and then the lexer would usually generate stupid
tokens, particularly when meeting the ending '"'.
pushed to master
--
Nathan Sidwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr95149.diff
Type: text/x-patch
Size: 26461 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200519/97befc1b/attachment-0001.bin>
More information about the Gcc-patches
mailing list