Made the "expected string literal" diagnostic more expressive

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168267 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index 9f962b0..6baa593 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -1290,7 +1290,8 @@
       LexUnexpandedToken(Tok);
       std::string WarningName;
       SourceLocation StrStartLoc = Tok.getLocation();
-      if (!FinishLexStringLiteral(Tok, WarningName, /*MacroExpansion=*/false)) {
+      if (!FinishLexStringLiteral(Tok, WarningName, "'__has_warning'",
+                                  /*MacroExpansion=*/false)) {
         // Eat tokens until ')'.
         while (Tok.isNot(tok::r_paren)
                  && Tok.isNot(tok::eod)
diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp
index 0c1c9db..783588e 100644
--- a/lib/Lex/Pragma.cpp
+++ b/lib/Lex/Pragma.cpp
@@ -503,6 +503,7 @@
   Lex(Tok);
   std::string ArgumentString;
   if (Tok.is(tok::comma) && !LexStringLiteral(Tok, ArgumentString,
+                                              "pragma comment",
                                               /*MacroExpansion=*/true))
     return;
 
@@ -559,7 +560,8 @@
   }
 
   std::string MessageString;
-  if (!FinishLexStringLiteral(Tok, MessageString, /*MacroExpansion=*/true))
+  if (!FinishLexStringLiteral(Tok, MessageString, "pragma message",
+                              /*MacroExpansion=*/true))
     return;
 
   if (ExpectClosingParen) {
@@ -1039,7 +1041,8 @@
     SourceLocation StringLoc = Tok.getLocation();
 
     std::string WarningName;
-    if (!PP.FinishLexStringLiteral(Tok, WarningName, /*MacroExpansion=*/false))
+    if (!PP.FinishLexStringLiteral(Tok, WarningName, "pragma diagnostic",
+                                   /*MacroExpansion=*/false))
       return;
 
     if (Tok.isNot(tok::eod)) {
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 52d6bb6..9488584 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -691,10 +691,12 @@
 }
 
 bool Preprocessor::FinishLexStringLiteral(Token &Result, std::string &String,
+                                          const char *DiagnosticTag,
                                           bool AllowMacroExpansion) {
   // We need at least one string literal.
   if (Result.isNot(tok::string_literal)) {
-    Diag(Result, diag::err_expected_string_literal);
+    Diag(Result, diag::err_expected_string_literal)
+      << /*Source='in...'*/0 << DiagnosticTag;
     return false;
   }
 
@@ -720,7 +722,8 @@
     return false;
 
   if (Literal.Pascal) {
-    Diag(StrToks[0].getLocation(), diag::err_expected_string_literal);
+    Diag(StrToks[0].getLocation(), diag::err_expected_string_literal)
+      << /*Source='in...'*/0 << DiagnosticTag;
     return false;
   }
 
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index d898447..7c5b153 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -735,7 +735,8 @@
     ConsumeToken();
     if (Keyword == Ident_message) {
       if (!isTokenStringLiteral()) {
-        Diag(Tok, diag::err_expected_string_literal);
+        Diag(Tok, diag::err_expected_string_literal)
+          << /*Source='availability attribute'*/2;
         SkipUntil(tok::r_paren);
         return;
       }
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index 0d785af..b8ebd9b 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -637,7 +637,8 @@
     return 0;
 
   if (!isTokenStringLiteral()) {
-    Diag(Tok, diag::err_expected_string_literal);
+    Diag(Tok, diag::err_expected_string_literal)
+      << /*Source='static_assert'*/1;
     SkipMalformedDecl();
     return 0;
   }
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index f4cdd61..dfffe81 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -1263,7 +1263,8 @@
       return ExprError();
     }
     default:
-      Diag(Tok, diag::err_expected_string_literal);
+      Diag(Tok, diag::err_expected_string_literal)
+        << /*Source='in...'*/0 << "'asm'";
       return ExprError();
   }