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/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index f6d77cf..45ce3e1 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -412,7 +412,7 @@
         return;
       
       if (Tok.isNot(tok::identifier)) {
-        Diag(Tok.getLocation(), diag::err_expected_ident);
+        Diag(Tok, diag::err_expected_ident);
         SkipUntil(tok::r_paren);
         return;
       }
@@ -431,7 +431,7 @@
         ConsumeToken();  // consume method name
       }
     } else {
-      Diag(AttrName, diag::err_objc_expected_property_attr, II->getName());
+      Diag(AttrName, diag::err_objc_expected_property_attr) << II->getName();
       SkipUntil(tok::r_paren);
       return;
     }
@@ -625,7 +625,7 @@
     ConsumeParen();
   else if (Tok.getLocation() == TypeStartLoc) {
     // If we didn't eat any tokens, then this isn't a type.
-    Diag(Tok.getLocation(), diag::err_expected_type);
+    Diag(Tok, diag::err_expected_type);
     SkipUntil(tok::r_paren);
   } else {
     // Otherwise, we found *something*, but didn't get a ')' in the right
@@ -678,8 +678,8 @@
   IdentifierInfo *SelIdent = ParseObjCSelector(selLoc);
 
   if (!SelIdent) { // missing selector name.
-    Diag(Tok.getLocation(), diag::err_expected_selector_for_method,
-         SourceRange(mLoc, Tok.getLocation()));
+    Diag(Tok, diag::err_expected_selector_for_method)
+      << SourceRange(mLoc, Tok.getLocation());
     // Skip until we get a ; or {}.
     SkipUntil(tok::r_brace);
     return 0;
@@ -1089,7 +1089,7 @@
   IdentifierInfo *classId = Tok.getIdentifierInfo();
   SourceLocation classLoc = ConsumeToken(); // consume class-name;
   if (Tok.isNot(tok::semi)) {
-    Diag(Tok, diag::err_expected_semi_after, "@compatibility_alias");
+    Diag(Tok, diag::err_expected_semi_after) << "@compatibility_alias";
     return 0;
   }
   DeclTy *ClsType = Actions.ActOnCompatiblityAlias(atLoc, 
@@ -1138,7 +1138,7 @@
     ConsumeToken(); // consume ','
   }
   if (Tok.isNot(tok::semi))
-    Diag(Tok, diag::err_expected_semi_after, "@synthesize");
+    Diag(Tok, diag::err_expected_semi_after) << "@synthesize";
   return 0;
 }
 
@@ -1168,7 +1168,7 @@
     ConsumeToken(); // consume ','
   }
   if (Tok.isNot(tok::semi))
-    Diag(Tok, diag::err_expected_semi_after, "@dynamic");
+    Diag(Tok, diag::err_expected_semi_after) << "@dynamic";
   return 0;
 }
  
@@ -1195,7 +1195,7 @@
 Parser::StmtResult Parser::ParseObjCSynchronizedStmt(SourceLocation atLoc) {
   ConsumeToken(); // consume synchronized
   if (Tok.isNot(tok::l_paren)) {
-    Diag (Tok, diag::err_expected_lparen_after, "@synchronized");
+    Diag(Tok, diag::err_expected_lparen_after) << "@synchronized";
     return true;
   }
   ConsumeParen();  // '('
@@ -1205,12 +1205,12 @@
     return true;
   }
   if (Tok.isNot(tok::r_paren)) {
-    Diag (Tok, diag::err_expected_lbrace);
+    Diag(Tok, diag::err_expected_lbrace);
     return true;
   }
   ConsumeParen();  // ')'
   if (Tok.isNot(tok::l_brace)) {
-    Diag (Tok, diag::err_expected_lbrace);
+    Diag(Tok, diag::err_expected_lbrace);
     return true;
   }
   // Enter a scope to hold everything within the compound stmt.  Compound
@@ -1241,7 +1241,7 @@
   
   ConsumeToken(); // consume try
   if (Tok.isNot(tok::l_brace)) {
-    Diag (Tok, diag::err_expected_lbrace);
+    Diag(Tok, diag::err_expected_lbrace);
     return true;
   }
   StmtResult CatchStmts;
@@ -1299,8 +1299,8 @@
           FirstPart, CatchBody.Val, CatchStmts.Val);
         ExitScope();
       } else {
-        Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after, 
-             "@catch clause");
+        Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after)
+          << "@catch clause";
         return true;
       }
       catch_or_finally_seen = true;
@@ -1411,7 +1411,7 @@
     case tok::objc_selector:
       return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression(AtLoc));
     default:
-      return Diag(AtLoc, diag::err_unexpected_at);
+        return Diag(AtLoc, diag::err_unexpected_at);
     }
   }
 }
@@ -1604,7 +1604,7 @@
   SourceLocation EncLoc = ConsumeToken();
   
   if (Tok.isNot(tok::l_paren))
-    return Diag(Tok, diag::err_expected_lparen_after, "@encode");
+    return Diag(Tok, diag::err_expected_lparen_after) << "@encode";
    
   SourceLocation LParenLoc = ConsumeParen();
   
@@ -1619,12 +1619,11 @@
 ///     objc-protocol-expression
 ///       @protocol ( protocol-name )
 
-Parser::ExprResult Parser::ParseObjCProtocolExpression(SourceLocation AtLoc)
-{
+Parser::ExprResult Parser::ParseObjCProtocolExpression(SourceLocation AtLoc) {
   SourceLocation ProtoLoc = ConsumeToken();
   
   if (Tok.isNot(tok::l_paren))
-    return Diag(Tok, diag::err_expected_lparen_after, "@protocol");
+    return Diag(Tok, diag::err_expected_lparen_after) << "@protocol";
   
   SourceLocation LParenLoc = ConsumeParen();
   
@@ -1642,12 +1641,11 @@
 
 ///     objc-selector-expression
 ///       @selector '(' objc-keyword-selector ')'
-Parser::ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc)
-{
+Parser::ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) {
   SourceLocation SelectorLoc = ConsumeToken();
   
   if (Tok.isNot(tok::l_paren))
-    return Diag(Tok, diag::err_expected_lparen_after, "@selector");
+    return Diag(Tok, diag::err_expected_lparen_after) << "@selector";
   
   llvm::SmallVector<IdentifierInfo *, 12> KeyIdents;
   SourceLocation LParenLoc = ConsumeParen();