================
@@ -3165,7 +3165,17 @@ bool Lexer::LexEndOfFile(Token &Result, const char 
*CurPtr) {
 
   // C99 5.1.1.2p2: If the file is non-empty and didn't end in a newline, issue
   // a pedwarn.
-  if (CurPtr != BufferStart && (CurPtr[-1] != '\n' && CurPtr[-1] != '\r')) {
+  if (CurPtr != BufferStart) {
+    StringRef LastNewline;
+    if (CurPtr[-1] == '\r' || CurPtr[-1] == '\n') {
+      LastNewline = StringRef(CurPtr - 1, 1);
+      if (CurPtr - 1 != BufferStart && CurPtr[-2] != CurPtr[-1] &&
+          (CurPtr[-2] == '\r' || CurPtr[-2] == '\n')) {
+        // \r\n or \n\r is one newline
----------------
AaronBallman wrote:

Why is `\n\r` one newline as opposed to a mixed set of two newlines? `/r/n` 
makes sense to me as that's the Windows line ending.

https://github.com/llvm/llvm-project/pull/97585
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to