Simplify raw mode lexing by treating an unterminate /**/ comment the
same we we do an unterminated string or character literal.  This makes
it so we can guarantee that the lexer never calls into the 
preprocessor (which would be suicide for a raw lexer).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57395 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index 4e4a42f..691f83e 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -32,7 +32,7 @@
      "null character(s) preserved in character literal")
 DIAG(null_in_file  , WARNING,
      "null character ignored")
-DIAG(nested_block_comment, WARNING,
+DIAG(warn_nested_block_comment, WARNING,
      "\"/*\" within block comment")
 DIAG(escaped_newline_block_comment_end, WARNING,
      "escaped newline between */ characters at block comment end")
diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h
index 9b17377..a3668df 100644
--- a/include/clang/Lex/Lexer.h
+++ b/include/clang/Lex/Lexer.h
@@ -60,9 +60,8 @@
   ///     effect of this, implicit macro expansion is naturally disabled.
   ///  3. "#" tokens at the start of a line are treated as normal tokens, not
   ///     implicitly transformed by the lexer.
-  ///  4. All diagnostic messages are disabled, except for unterminated /*.
-  ///  5. The only callback made into the preprocessor is to report a hard error
-  ///     on an unterminated '/*' comment.
+  ///  4. All diagnostic messages are disabled.
+  ///  5. No callbacks are made into the preprocessor.
   ///
   /// Note that in raw mode that the PP pointer may be null.
   bool LexingRawMode;
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index 63bf58a..44a32db 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -931,7 +931,8 @@
   unsigned char C = getCharAndSize(CurPtr, CharSize);
   CurPtr += CharSize;
   if (C == 0 && CurPtr == BufferEnd+1) {
-    Diag(BufferPtr, diag::err_unterminated_block_comment);
+    if (!LexingRawMode)
+      Diag(BufferPtr, diag::err_unterminated_block_comment);
     BufferPtr = CurPtr-1;
     return true;
   }
@@ -1000,10 +1001,10 @@
         // If this is a /* inside of the comment, emit a warning.  Don't do this
         // if this is a /*/, which will end the comment.  This misses cases with
         // embedded escaped newlines, but oh well.
-        Diag(CurPtr-1, diag::nested_block_comment);
+        Diag(CurPtr-1, diag::warn_nested_block_comment);
       }
     } else if (C == 0 && CurPtr == BufferEnd+1) {
-      Diag(BufferPtr, diag::err_unterminated_block_comment);
+      if (!LexingRawMode) Diag(BufferPtr, diag::err_unterminated_block_comment);
       // Note: the user probably forgot a */.  We could continue immediately
       // after the /*, but this would involve lexing a lot of what really is the
       // comment, which surely would confuse the parser.
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp
index d3acaea..82b2b4d 100644
--- a/lib/Lex/TokenLexer.cpp
+++ b/lib/Lex/TokenLexer.cpp
@@ -377,11 +377,7 @@
     // Lex the resultant pasted token into Result.
     Token Result;
     
-    // Avoid testing /*, as the lexer would think it is the start of a comment
-    // and emit an error that it is unterminated.
-    if (Tok.is(tok::slash) && RHS.is(tok::star)) {
-      isInvalid = true;
-    } else if (Tok.is(tok::identifier) && RHS.is(tok::identifier)) {
+    if (Tok.is(tok::identifier) && RHS.is(tok::identifier)) {
       // Common paste case: identifier+identifier = identifier.  Avoid creating
       // a lexer and other overhead.
       PP.IncrementPasteCounter(true);