[PATCH] D36642: [Lexer] Report more precise skipped regions (PR34166)
Vedant Kumar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 17 18:20:59 PDT 2017
vsk added inline comments.
================
Comment at: lib/Lex/PPDirectives.cpp:570
+ // We'll warn about reaching the end of file later.
+ if (C == '\0' || C == '\r' || C == '\n')
+ break;
----------------
efriedma wrote:
> This doesn't really handle backslash-escaped newlines correctly. (Not likely to matter, I guess, but better to get it right while we're messing with it.)
>
> Could we use CurPPLexer->getSourceLocation() or something like that, instead of trying to scan the line ourselves?
Thanks again for the catch! CurPPLexer->getSourceLocation() does the job. I couldn't find an efficient solution which places the end of the skipped range at the end of the line containing the #endif. With getSourceLocation(), we always set the end location to the first column of the line after the #endif. I think this is OK (at least, it shouldn't affect coverage rendering).
https://reviews.llvm.org/D36642
More information about the cfe-commits
mailing list