[PATCH] D30748: [Lexer] Finding beginning of token with escaped new line

Paweł Żukowski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 7 10:57:58 PDT 2017


idlecode added a comment.

I don't have commit rights yet so I would be grateful for help in this matter :)



================
Comment at: lib/Lex/Lexer.cpp:469-477
+    if (!isVerticalWhitespace(LexStart[0]))
+      continue;
 
-  const char *LexStart = StrData;
-  while (LexStart != BufStart) {
-    if (LexStart[0] == '\n' || LexStart[0] == '\r') {
-      ++LexStart;
-      break;
-    }
+    if (Lexer::isNewLineEscaped(BufStart, LexStart))
+      continue;
 
+    // LexStart should point at first character of logical line.
----------------
alexfh wrote:
> The logic is hard to get here. I'd use a single `if` and reverse the condition to get rid of the `continue`s:
> 
>   if (isVerticalWhitespace(*LexStart) && !Lexer::isNewLineEscaped(BufStart, LexStart)) {
>     ++LexStart;
>     break;
>   }
Yes, I know - I thought that more vertical code composition would help


https://reviews.llvm.org/D30748





More information about the cfe-commits mailing list