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

Alexander Kornienko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 4 18:30:57 PDT 2017


alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with one nit.

Do you need someone to commit the patch for you after you address the comment?



================
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.
----------------
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;
  }


https://reviews.llvm.org/D30748





More information about the cfe-commits mailing list