================ @@ -3183,8 +3193,31 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { DiagID = diag::ext_no_newline_eof; } - Diag(BufferEnd, DiagID) - << FixItHint::CreateInsertion(EndLoc, "\n"); + if (LastNewline.empty()) { + Diag(BufferEnd, DiagID) << FixItHint::CreateInsertion(EndLoc, "\n"); + } else { + // While the file physically ends in a newline, the previous + // line might have ended in a splice, so it would be deleted + const char *LastSpliceLocation = LastNewline.data(); + while (LastSpliceLocation != BufferStart && + isHorizontalWhitespace(*--LastSpliceLocation)) + ; + + bool LastIsSplice = *LastSpliceLocation == '\\'; + if (*LastSpliceLocation == '/' && LangOpts.Trigraphs) + // Check for "??/" trigraph for "\" + LastIsSplice = + LastSpliceLocation != BufferStart && *--LastSpliceLocation == '?' && + LastSpliceLocation != BufferStart && *--LastSpliceLocation == '?'; ---------------- Sirraide wrote:
There don’t seem to be any tests for this either (and just for the record, the `*--` here is fine imo). 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