Switch several more Sema Diag methods over.  This simplifies the
__builtin_prefetch code to only emit one diagnostic per builtin_prefetch.
While this has nothing to do with the rest of the patch, the code seemed
like overkill when I was updating it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59588 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 7f3bce5..cae6fe6 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -67,8 +67,8 @@
   // Check for another declaration kind with the same name.
   Decl *PrevDecl = LookupDecl(ClassName, Decl::IDNS_Ordinary, TUScope);
   if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
-    Diag(ClassLoc, diag::err_redefinition_different_kind,
-         ClassName->getName());
+    Diag(ClassLoc, diag::err_redefinition_different_kind)
+      << ClassName->getName();
     Diag(PrevDecl->getLocation(), diag::err_previous_definition);
   }
   
@@ -76,7 +76,7 @@
   if (IDecl) {
     // Class already seen. Is it a forward declaration?
     if (!IDecl->isForwardDecl()) {
-      Diag(AtInterfaceLoc, diag::err_duplicate_class_def, IDecl->getName());
+      Diag(AtInterfaceLoc, diag::err_duplicate_class_def) << IDecl->getName();
       // Return the previous class interface.
       // FIXME: don't leak the objects passed in!
       return IDecl;
@@ -100,8 +100,8 @@
     // Check if a different kind of symbol declared in this scope.
     PrevDecl = LookupDecl(SuperName, Decl::IDNS_Ordinary, TUScope);
     if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
-      Diag(SuperLoc, diag::err_redefinition_different_kind,
-           SuperName->getName());
+      Diag(SuperLoc, diag::err_redefinition_different_kind)
+        << SuperName->getName();
       Diag(PrevDecl->getLocation(), diag::err_previous_definition);
     }
     else {
@@ -109,10 +109,10 @@
       SuperClassEntry = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl); 
                               
       if (!SuperClassEntry || SuperClassEntry->isForwardDecl()) {
-        Diag(SuperLoc, diag::err_undef_superclass, 
-             SuperClassEntry ? SuperClassEntry->getName() 
-                             : SuperName->getName(),
-             ClassName->getName(), SourceRange(AtInterfaceLoc, ClassLoc));
+        Diag(SuperLoc, diag::err_undef_superclass)
+          << (SuperClassEntry ? SuperClassEntry->getName() 
+                              : SuperName->getName())
+          << ClassName->getName() << SourceRange(AtInterfaceLoc, ClassLoc);
       }
     }
     IDecl->setSuperClass(SuperClassEntry);
@@ -147,8 +147,8 @@
       Diag(ADecl->getLocation(), diag::warn_previous_declaration);
     }
     else {
-      Diag(AliasLocation, diag::err_conflicting_aliasing_type,
-           AliasName->getName());
+      Diag(AliasLocation, diag::err_conflicting_aliasing_type)
+        << AliasName->getName();
       Diag(ADecl->getLocation(), diag::err_previous_declaration);
     }
     return 0;
@@ -157,7 +157,7 @@
   Decl *CDeclU = LookupDecl(ClassName, Decl::IDNS_Ordinary, TUScope);
   ObjCInterfaceDecl *CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(CDeclU);
   if (CDecl == 0) {
-    Diag(ClassLocation, diag::warn_undef_interface, ClassName->getName());
+    Diag(ClassLocation, diag::warn_undef_interface) << ClassName->getName();
     if (CDeclU)
       Diag(CDeclU->getLocation(), diag::warn_previous_declaration);
     return 0;
@@ -189,8 +189,8 @@
   if (PDecl) {
     // Protocol already seen. Better be a forward protocol declaration
     if (!PDecl->isForwardDecl()) {
-      Diag(ProtocolLoc, diag::err_duplicate_protocol_def, 
-           ProtocolName->getName());
+      Diag(ProtocolLoc, diag::err_duplicate_protocol_def)
+        << ProtocolName->getName();
       // Just return the protocol we already had.
       // FIXME: don't leak the objects passed in!
       return PDecl;
@@ -225,16 +225,16 @@
   for (unsigned i = 0; i != NumProtocols; ++i) {
     ObjCProtocolDecl *PDecl = ObjCProtocols[ProtocolId[i].first];
     if (!PDecl) {
-      Diag(ProtocolId[i].second, diag::err_undeclared_protocol, 
-           ProtocolId[i].first->getName());
+      Diag(ProtocolId[i].second, diag::err_undeclared_protocol)
+        << ProtocolId[i].first->getName();
       continue;
     }
 
     // If this is a forward declaration and we are supposed to warn in this
     // case, do it.
     if (WarnOnDeclarations && PDecl->isForwardDecl())
-      Diag(ProtocolId[i].second, diag::warn_undef_protocolref,
-           ProtocolId[i].first->getName());
+      Diag(ProtocolId[i].second, diag::warn_undef_protocolref)
+        << ProtocolId[i].first->getName();
     Protocols.push_back(PDecl); 
   }
 }
@@ -252,8 +252,8 @@
   SuperProperty->getPropertyAttributes();
   if ((CAttr & ObjCPropertyDecl::OBJC_PR_readonly)
       && (SAttr & ObjCPropertyDecl::OBJC_PR_readwrite))
-    Diag(Property->getLocation(), diag::warn_readonly_property, 
-               Property->getName(), inheritedName);
+    Diag(Property->getLocation(), diag::warn_readonly_property)
+      << Property->getName() << inheritedName;
   if ((CAttr & ObjCPropertyDecl::OBJC_PR_copy)
       != (SAttr & ObjCPropertyDecl::OBJC_PR_copy))
     Diag(Property->getLocation(), diag::warn_property_attribute)
@@ -400,15 +400,15 @@
   
   /// Check that class of this category is already completely declared.
   if (!IDecl || IDecl->isForwardDecl())
-    Diag(ClassLoc, diag::err_undef_interface, ClassName->getName());
+    Diag(ClassLoc, diag::err_undef_interface) << ClassName->getName();
   else {
     /// Check for duplicate interface declaration for this category
     ObjCCategoryDecl *CDeclChain;
     for (CDeclChain = IDecl->getCategoryList(); CDeclChain;
          CDeclChain = CDeclChain->getNextClassCategory()) {
       if (CategoryName && CDeclChain->getIdentifier() == CategoryName) {
-        Diag(CategoryLoc, diag::warn_dup_category_def, ClassName->getName(),
-             CategoryName->getName());
+        Diag(CategoryLoc, diag::warn_dup_category_def)
+          << ClassName->getName() << CategoryName->getName();
         break;
       }
     }
@@ -437,7 +437,7 @@
     ObjCCategoryImplDecl::Create(Context, AtCatImplLoc, CatName, IDecl);
   /// Check that class of this category is already completely declared.
   if (!IDecl || IDecl->isForwardDecl())
-    Diag(ClassLoc, diag::err_undef_interface, ClassName->getName());
+    Diag(ClassLoc, diag::err_undef_interface) << ClassName->getName();
 
   /// TODO: Check that CatName, category name, is not used in another
   // implementation.
@@ -464,7 +464,7 @@
     // Is there an interface declaration of this class; if not, warn!
     IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl); 
     if (!IDecl)
-      Diag(ClassLoc, diag::warn_undef_interface, ClassName->getName());
+      Diag(ClassLoc, diag::warn_undef_interface) << ClassName->getName();
   }
   
   // Check that super class name is valid class name
@@ -557,18 +557,18 @@
     assert (ClsIvar && "missing class ivar");
     if (Context.getCanonicalType(ImplIvar->getType()) !=
         Context.getCanonicalType(ClsIvar->getType())) {
-      Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_type,
-           ImplIvar->getIdentifier()->getName());
-      Diag(ClsIvar->getLocation(), diag::err_previous_definition,
-           ClsIvar->getIdentifier()->getName());
+      Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_type)
+        << ImplIvar->getIdentifier()->getName();
+      Diag(ClsIvar->getLocation(), diag::err_previous_definition)
+        << ClsIvar->getIdentifier()->getName();
     }
     // TODO: Two mismatched (unequal width) Ivar bitfields should be diagnosed 
     // as error.
     else if (ImplIvar->getIdentifier() != ClsIvar->getIdentifier()) {
-      Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_name,
-           ImplIvar->getIdentifier()->getName());
-      Diag(ClsIvar->getLocation(), diag::err_previous_definition,
-           ClsIvar->getIdentifier()->getName());
+      Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_name)
+        << ImplIvar->getIdentifier()->getName();
+      Diag(ClsIvar->getLocation(), diag::err_previous_definition)
+        << ClsIvar->getIdentifier()->getName();
       return;
     }
     --numIvars;