[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-11 Thread via cfe-commits
@@ -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 !=

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-11 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. LGTM! 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

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-11 Thread Aaron Ballman via cfe-commits
@@ -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 !=

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-11 Thread Mital Ashok via cfe-commits
@@ -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 !=

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-11 Thread Aaron Ballman via cfe-commits
@@ -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 !=

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread Mital Ashok via cfe-commits
https://github.com/MitalAshok updated https://github.com/llvm/llvm-project/pull/97585 >From 8af656659b79d76c971b01f1f4c14dc7315565b8 Mon Sep 17 00:00:00 2001 From: Mital Ashok Date: Fri, 21 Jun 2024 18:55:38 +0100 Subject: [PATCH 1/9] [Clang] Warn on backslash-newline-EOF --- clang/docs/Relea

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread via cfe-commits
@@ -3183,8 +3193,35 @@ 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)

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread Mital Ashok via cfe-commits
@@ -3183,8 +3193,35 @@ 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)

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread via cfe-commits
https://github.com/Sirraide edited 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

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread via cfe-commits
@@ -3183,8 +3193,35 @@ 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)

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread via cfe-commits
https://github.com/Sirraide edited 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

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread via cfe-commits
@@ -3183,8 +3193,35 @@ 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)

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread Mital Ashok via cfe-commits
https://github.com/MitalAshok updated https://github.com/llvm/llvm-project/pull/97585 >From 8af656659b79d76c971b01f1f4c14dc7315565b8 Mon Sep 17 00:00:00 2001 From: Mital Ashok Date: Fri, 21 Jun 2024 18:55:38 +0100 Subject: [PATCH 1/8] [Clang] Warn on backslash-newline-EOF --- clang/docs/Relea

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread Mital Ashok via cfe-commits
@@ -647,6 +647,8 @@ Improvements to Clang's diagnostics - Clang now shows implicit deduction guides when diagnosing overload resolution failure. #GH92393. +- Clang now emits ``-Wnewline-eof`` when the last newline is deleted by a preceding backslash. #GH41571. -

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread Mital Ashok via cfe-commits
@@ -3183,8 +3193,35 @@ 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)

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread via cfe-commits
@@ -3183,8 +3193,35 @@ 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)

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread via cfe-commits
@@ -647,6 +647,8 @@ Improvements to Clang's diagnostics - Clang now shows implicit deduction guides when diagnosing overload resolution failure. #GH92393. +- Clang now emits ``-Wnewline-eof`` when the last newline is deleted by a preceding backslash. #GH41571. -

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread via cfe-commits
https://github.com/cor3ntin edited 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

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread via cfe-commits
https://github.com/cor3ntin approved this pull request. LGTM. 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

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread Vlad Serebrennikov via cfe-commits
https://github.com/Endilll commented: DR tests look good 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

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread Mital Ashok via cfe-commits
@@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected %s -E | FileCheck %s --strict-whitespace --allow-empty MitalAshok wrote: Fixed now, thanks https://github.com/llvm/llvm-project/pull/97585

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-05 Thread Mital Ashok via cfe-commits
https://github.com/MitalAshok updated https://github.com/llvm/llvm-project/pull/97585 >From 8af656659b79d76c971b01f1f4c14dc7315565b8 Mon Sep 17 00:00:00 2001 From: Mital Ashok Date: Fri, 21 Jun 2024 18:55:38 +0100 Subject: [PATCH 1/6] [Clang] Warn on backslash-newline-EOF --- clang/docs/Relea

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-04 Thread Vlad Serebrennikov via cfe-commits
https://github.com/Endilll edited 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

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-04 Thread Vlad Serebrennikov via cfe-commits
@@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected %s -E | FileCheck %s --strict-whitespace --allow-empty Endilll wrote: You forgot C++14. https://github.com/llvm/llvm-project/pull/97585 ___

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-04 Thread Mital Ashok via cfe-commits
https://github.com/MitalAshok updated https://github.com/llvm/llvm-project/pull/97585 >From 8af656659b79d76c971b01f1f4c14dc7315565b8 Mon Sep 17 00:00:00 2001 From: Mital Ashok Date: Fri, 21 Jun 2024 18:55:38 +0100 Subject: [PATCH 1/5] [Clang] Warn on backslash-newline-EOF --- clang/docs/Relea

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-04 Thread Vlad Serebrennikov via cfe-commits
@@ -536,3 +536,12 @@ namespace cwg1696 { // cwg1696: 7 }; #endif } + +// cwg1698: yes Endilll wrote: ```suggestion // cwg1698: 2.7 ``` https://github.com/llvm/llvm-project/pull/97585 ___ cfe-commits mailing list c

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-04 Thread Vlad Serebrennikov via cfe-commits
@@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected %s -E | FileCheck %s --strict-whitespace --allow-empty Endilll wrote: We run DR tests in complete range of C++ versions. https://github.com/llvm/llvm-project/pull/97585 __

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-04 Thread Mital Ashok via cfe-commits
https://github.com/MitalAshok edited 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

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-04 Thread Mital Ashok via cfe-commits
https://github.com/MitalAshok updated https://github.com/llvm/llvm-project/pull/97585 >From 8af656659b79d76c971b01f1f4c14dc7315565b8 Mon Sep 17 00:00:00 2001 From: Mital Ashok Date: Fri, 21 Jun 2024 18:55:38 +0100 Subject: [PATCH 1/4] [Clang] Warn on backslash-newline-EOF --- clang/docs/Relea

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-04 Thread via cfe-commits
https://github.com/Sirraide edited 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

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-04 Thread via cfe-commits
https://github.com/Sirraide approved this pull request. Thanks, I personally at least find it much easier to tell now at a glance that this makes sense. I’d wait a bit before merging this to see if someone more familiar with either C or the lexer has any more comments on this,. https://github.

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-04 Thread Mital Ashok via cfe-commits
https://github.com/MitalAshok updated https://github.com/llvm/llvm-project/pull/97585 >From 8af656659b79d76c971b01f1f4c14dc7315565b8 Mon Sep 17 00:00:00 2001 From: Mital Ashok Date: Fri, 21 Jun 2024 18:55:38 +0100 Subject: [PATCH 1/3] [Clang] Warn on backslash-newline-EOF --- clang/docs/Relea

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-04 Thread Mital Ashok via cfe-commits
https://github.com/MitalAshok updated https://github.com/llvm/llvm-project/pull/97585 >From 8af656659b79d76c971b01f1f4c14dc7315565b8 Mon Sep 17 00:00:00 2001 From: Mital Ashok Date: Fri, 21 Jun 2024 18:55:38 +0100 Subject: [PATCH 1/2] [Clang] Warn on backslash-newline-EOF --- clang/docs/Relea

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-03 Thread via cfe-commits
@@ -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)

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-03 Thread via cfe-commits
https://github.com/Sirraide commented: The approach overall seems fine, but a few more tests would be nice. https://github.com/llvm/llvm-project/pull/97585 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/l

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-03 Thread via cfe-commits
@@ -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)

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-03 Thread via cfe-commits
@@ -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)

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-03 Thread via cfe-commits
https://github.com/Sirraide edited 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

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-03 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Mital Ashok (MitalAshok) Changes C99 §5.1.1.2p2, C23 §5.1.1.2p2 > A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character before any such splicing takes place.

[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)

2024-07-03 Thread Mital Ashok via cfe-commits
https://github.com/MitalAshok created https://github.com/llvm/llvm-project/pull/97585 C99 §5.1.1.2p2, C23 §5.1.1.2p2 > A source file that is not empty shall end in a new-line character, which > shall not be immediately preceded by a backslash character before any such > splicing takes place.