Change a couple of the Parser::Diag methods to return DiagnosticInfo
and let the clients push whatever they want into the DiagnosticInfo
instead of hard coding a few forms.  Also switch various clients to
use Diag(Tok, ...) instead of Diag(Tok.getLocation(), ...) as the
canonical form to simplify the code a bit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59509 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index a9ce22d..d0d1871 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -41,10 +41,12 @@
 Action::~Action() {}
 
 
-bool Parser::Diag(SourceLocation Loc, unsigned DiagID,
-                  const std::string &Msg) {
-  Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID) << Msg;
-  return true;
+DiagnosticInfo Parser::Diag(SourceLocation Loc, unsigned DiagID) {
+  return Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID);
+}
+
+DiagnosticInfo Parser::Diag(const Token &Tok, unsigned DiagID) {
+  return Diag(Tok.getLocation(), DiagID);
 }
 
 bool Parser::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
@@ -81,7 +83,7 @@
   case tok::greater:  LHSName = "<"; DID = diag::err_expected_greater; break;
   }
   Diag(Tok, DID);
-  Diag(LHSLoc, diag::err_matching, LHSName);
+  Diag(LHSLoc, diag::err_matching) << LHSName;
   SkipUntil(RHSTok);
   return R;
 }
@@ -99,7 +101,7 @@
     return false;
   }
 
-  Diag(Tok, DiagID, Msg);
+  Diag(Tok, DiagID) << Msg;
   if (SkipToTok != tok::unknown)
     SkipUntil(SkipToTok);
   return true;
@@ -405,7 +407,7 @@
     }
     const char *PrevSpec = 0;
     if (DS.SetTypeSpecType(DeclSpec::TST_unspecified, AtLoc, PrevSpec))
-      Diag(AtLoc, diag::err_invalid_decl_spec_combination, PrevSpec);
+      Diag(AtLoc, diag::err_invalid_decl_spec_combination) << PrevSpec;
     if (Tok.isObjCAtKeyword(tok::objc_protocol))
       return ParseObjCAtProtocolDeclaration(AtLoc, DS.getAttributes());
     return ParseObjCAtInterfaceDeclaration(AtLoc, DS.getAttributes());
@@ -609,8 +611,8 @@
           // C99 6.9.1p6: those declarators shall declare only identifiers from
           // the identifier list.
           if (i == FTI.NumArgs) {
-            Diag(ParmDeclarator.getIdentifierLoc(), diag::err_no_matching_param,
-                 ParmDeclarator.getIdentifier()->getName());
+            Diag(ParmDeclarator.getIdentifierLoc(), diag::err_no_matching_param)
+              << ParmDeclarator.getIdentifier()->getName();
             break;
           }
 
@@ -618,8 +620,8 @@
             // Reject redefinitions of parameters.
             if (FTI.ArgInfo[i].Param) {
               Diag(ParmDeclarator.getIdentifierLoc(),
-                   diag::err_param_redefinition,
-                   ParmDeclarator.getIdentifier()->getName());
+                   diag::err_param_redefinition)
+                 << ParmDeclarator.getIdentifier()->getName();
             } else {
               FTI.ArgInfo[i].Param = Param;
             }
@@ -689,7 +691,7 @@
   SourceLocation Loc = ConsumeToken();
 
   if (Tok.isNot(tok::l_paren)) {
-    Diag(Tok, diag::err_expected_lparen_after, "asm");
+    Diag(Tok, diag::err_expected_lparen_after) << "asm";
     return true;
   }