summaryrefslogtreecommitdiffstats
path: root/clang/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-06-09 06:07:22 +0000
committerChris Lattner <sabre@nondot.org>2007-06-09 06:07:22 +0000
commitff591e24ebe788b7511d68516b47e864f4ae4ae5 (patch)
treebcd9744ab4c841e072f6605fd13f17634e67006a /clang/Lex/Lexer.cpp
parent736ed5dfb8142251e023558b5fb6f4dc4bc7dc48 (diff)
downloadbcm5719-llvm-ff591e24ebe788b7511d68516b47e864f4ae4ae5.tar.gz
bcm5719-llvm-ff591e24ebe788b7511d68516b47e864f4ae4ae5.zip
Don't warn about escaped newlines in // comments if the next line is also
a // comment, this reduces noise in the llvm testsuite. llvm-svn: 39636
Diffstat (limited to 'clang/Lex/Lexer.cpp')
-rw-r--r--clang/Lex/Lexer.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp
index ab537455fee..9c95af1475a 100644
--- a/clang/Lex/Lexer.cpp
+++ b/clang/Lex/Lexer.cpp
@@ -643,10 +643,21 @@ bool Lexer::SkipBCPLComment(LexerToken &Result, const char *CurPtr) {
C = getAndAdvanceChar(CurPtr, Result);
// If we read multiple characters, and one of those characters was a \r or
- // \n, then we had an escaped newline within the comment. Emit diagnostic.
- if (CurPtr != OldPtr+1) {
+ // \n, then we had an escaped newline within the comment. Emit diagnostic
+ // unless the next line is also a // comment.
+ if (CurPtr != OldPtr+1 && C != '/' && CurPtr[0] != '/') {
for (; OldPtr != CurPtr; ++OldPtr)
if (OldPtr[0] == '\n' || OldPtr[0] == '\r') {
+ // Okay, we found a // comment that ends in a newline, if the next
+ // line is also a // comment, but has spaces, don't emit a diagnostic.
+ if (isspace(C)) {
+ const char *ForwardPtr = CurPtr;
+ while (isspace(*ForwardPtr)) // Skip whitespace.
+ ++ForwardPtr;
+ if (ForwardPtr[0] == '/' && ForwardPtr[1] == '/')
+ break;
+ }
+
Diag(OldPtr-1, diag::ext_multi_line_bcpl_comment);
break;
}
OpenPOWER on IntegriCloud