[PATCH] D64525: [clang-scan-deps] Dependency directives source minimizer: single quotes are not digit separators after a valid character literal prefix

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 10 12:52:40 PDT 2019


arphaman marked an inline comment as done.
arphaman added inline comments.


================
Comment at: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp:265-272
+  // Make sure that the L, u, U, u8 prefixes don't get marked as a
+  // separator though.
+  char Prev = *(Cur - 1);
+  if (Prev == 'L' || Prev == 'U' || Prev == 'u')
+    return false;
+  if (Prev == '8' && (Cur - 1 != Start) && *(Cur - 2) == 'u')
+    return false;
----------------
dexonsmith wrote:
> I wonder if this would be easier to identify walking forward from `Start` rather than working backwards from `Cur`.
Yes, that's a possible option. We can scan scanning from start, until we reach non-whitespace right before Cur, and then identify the token. 

In such ambiguous cases it might be a good idea to raw lex the line using the Lexer from Start to End. Then we'll match the behavior of Lexer when there's an actual error as well. I'll see if I can setup a fallback like this in a follow-up patch.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64525/new/

https://reviews.llvm.org/D64525





More information about the cfe-commits mailing list