================ @@ -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:
Thank you for the investigation! I think it's fine to leave the behavior as-is for this patch. CC @cor3ntin on whether we should make a correctness change in the future or not (if we think one should be made, let's file an issue now to track it even if we're not working on a fix right now). 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