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/Sema.cpp b/lib/Sema/Sema.cpp
index b8e1c13..d1e4338 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -25,10 +25,10 @@
     return CXXRecordDecl::Create(C, TagDecl::TK_struct, 
                                  C.getTranslationUnitDecl(),
                                  SourceLocation(), &C.Idents.get(Name));
-  else
-    return RecordDecl::Create(C, TagDecl::TK_struct, 
-                              C.getTranslationUnitDecl(),
-                              SourceLocation(), &C.Idents.get(Name));
+
+  return RecordDecl::Create(C, TagDecl::TK_struct, 
+                            C.getTranslationUnitDecl(),
+                            SourceLocation(), &C.Idents.get(Name));
 }
 
 void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
@@ -195,23 +195,6 @@
   return true;
 }
 
-bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
-                const std::string &Msg2, const SourceRange &R) {
-  PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << Msg1 << Msg2 << R;
-  return true;
-}
-bool Sema::Diag(SourceLocation Loc, unsigned DiagID,
-                const SourceRange& R1, const SourceRange& R2) {
-  PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << R1 << R2;
-  return true;
-}
-
-bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
-                const SourceRange& R1, const SourceRange& R2) {
-  PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << Msg << R1 << R2;
-  return true;
-}
-
 const LangOptions &Sema::getLangOptions() const {
   return PP.getLangOptions();
 }
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 6512937..c3df6ba 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -245,14 +245,8 @@
 
   /// More expressive diagnostic helpers for expressions (say that 6 times:-)
   bool Diag(SourceLocation Loc, unsigned DiagID, const SourceRange& R1);
-  bool Diag(SourceLocation Loc, unsigned DiagID, 
-            const SourceRange& R1, const SourceRange& R2);
   bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
             const SourceRange& R1);
-  bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
-            const SourceRange& R1, const SourceRange& R2);
-  bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, 
-            const std::string &Msg2, const SourceRange& R1);
   
   virtual void DeleteExpr(ExprTy *E);
   virtual void DeleteStmt(StmtTy *S);
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 49c153d..741d939 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -121,9 +121,8 @@
   StringLiteral *Literal = dyn_cast<StringLiteral>(Arg);
 
   if (!Literal || Literal->isWide()) {
-    Diag(Arg->getLocStart(),
-         diag::err_cfstring_literal_not_string_constant,
-         Arg->getSourceRange());
+    Diag(Arg->getLocStart(), diag::err_cfstring_literal_not_string_constant)
+      << Arg->getSourceRange();
     return true;
   }
   
@@ -133,15 +132,15 @@
   for (unsigned i = 0; i < Length; ++i) {
     if (!isascii(Data[i])) {
       Diag(PP.AdvanceToTokenCharacter(Arg->getLocStart(), i + 1),
-           diag::warn_cfstring_literal_contains_non_ascii_character,
-           Arg->getSourceRange());
+           diag::warn_cfstring_literal_contains_non_ascii_character)
+        << Arg->getSourceRange();
       break;
     }
     
     if (!Data[i]) {
       Diag(PP.AdvanceToTokenCharacter(Arg->getLocStart(), i + 1),
-           diag::warn_cfstring_literal_contains_nul_character,
-           Arg->getSourceRange());
+           diag::warn_cfstring_literal_contains_nul_character)
+        << Arg->getSourceRange();
       break;
     }
   }
@@ -155,9 +154,10 @@
   Expr *Fn = TheCall->getCallee();
   if (TheCall->getNumArgs() > 2) {
     Diag(TheCall->getArg(2)->getLocStart(), 
-         diag::err_typecheck_call_too_many_args, Fn->getSourceRange(),
-         SourceRange(TheCall->getArg(2)->getLocStart(), 
-                     (*(TheCall->arg_end()-1))->getLocEnd()));
+         diag::err_typecheck_call_too_many_args)
+      << Fn->getSourceRange()
+      << SourceRange(TheCall->getArg(2)->getLocStart(), 
+                     (*(TheCall->arg_end()-1))->getLocEnd());
     return true;
   }
   
@@ -205,9 +205,9 @@
     return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args);
   if (TheCall->getNumArgs() > 2)
     return Diag(TheCall->getArg(2)->getLocStart(), 
-                diag::err_typecheck_call_too_many_args,
-                SourceRange(TheCall->getArg(2)->getLocStart(),
-                            (*(TheCall->arg_end()-1))->getLocEnd()));
+                diag::err_typecheck_call_too_many_args)
+      << SourceRange(TheCall->getArg(2)->getLocStart(),
+                     (*(TheCall->arg_end()-1))->getLocEnd());
   
   Expr *OrigArg0 = TheCall->getArg(0);
   Expr *OrigArg1 = TheCall->getArg(1);
@@ -220,10 +220,9 @@
   // invalid for this operation.
   if (!Res->isRealFloatingType())
     return Diag(OrigArg0->getLocStart(), 
-                diag::err_typecheck_call_invalid_ordered_compare,
-                OrigArg0->getType().getAsString(),
-                OrigArg1->getType().getAsString(),
-                SourceRange(OrigArg0->getLocStart(), OrigArg1->getLocEnd()));
+                diag::err_typecheck_call_invalid_ordered_compare)
+      << OrigArg0->getType().getAsString() << OrigArg1->getType().getAsString()
+      << SourceRange(OrigArg0->getLocStart(), OrigArg1->getLocEnd());
   
   return false;
 }
@@ -233,7 +232,7 @@
   // to check is that the argument is a constant.
   SourceLocation Loc;
   if (!TheCall->getArg(0)->isIntegerConstantExpr(Context, &Loc))
-    return Diag(Loc, diag::err_stack_const_level, TheCall->getSourceRange());
+    return Diag(Loc, diag::err_stack_const_level) << TheCall->getSourceRange();
   
   return false;
 }
@@ -242,47 +241,47 @@
 // This is declared to take (...), so we have to check everything.
 Action::ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
   if (TheCall->getNumArgs() < 3)
-    return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args,
-                TheCall->getSourceRange());
+    return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
+      << TheCall->getSourceRange();
 
   QualType FAType = TheCall->getArg(0)->getType();
   QualType SAType = TheCall->getArg(1)->getType();
 
   if (!FAType->isVectorType() || !SAType->isVectorType()) {
-    Diag(TheCall->getLocStart(), diag::err_shufflevector_non_vector,
-         SourceRange(TheCall->getArg(0)->getLocStart(), 
-                     TheCall->getArg(1)->getLocEnd()));
+    Diag(TheCall->getLocStart(), diag::err_shufflevector_non_vector)
+      << SourceRange(TheCall->getArg(0)->getLocStart(), 
+                     TheCall->getArg(1)->getLocEnd());
     return true;
   }
 
   if (Context.getCanonicalType(FAType).getUnqualifiedType() !=
       Context.getCanonicalType(SAType).getUnqualifiedType()) {
-    Diag(TheCall->getLocStart(), diag::err_shufflevector_incompatible_vector,
-         SourceRange(TheCall->getArg(0)->getLocStart(), 
-                     TheCall->getArg(1)->getLocEnd()));
+    Diag(TheCall->getLocStart(), diag::err_shufflevector_incompatible_vector)
+      << SourceRange(TheCall->getArg(0)->getLocStart(), 
+                     TheCall->getArg(1)->getLocEnd());
     return true;
   }
 
   unsigned numElements = FAType->getAsVectorType()->getNumElements();
   if (TheCall->getNumArgs() != numElements+2) {
     if (TheCall->getNumArgs() < numElements+2)
-      return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args,
-                  TheCall->getSourceRange());
-    return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_many_args,
-                TheCall->getSourceRange());
+      return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
+               << TheCall->getSourceRange();
+    return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_many_args)
+             << TheCall->getSourceRange();
   }
 
   for (unsigned i = 2; i < TheCall->getNumArgs(); i++) {
     llvm::APSInt Result(32);
     if (!TheCall->getArg(i)->isIntegerConstantExpr(Result, Context))
       return Diag(TheCall->getLocStart(),
-                  diag::err_shufflevector_nonconstant_argument,
-                  TheCall->getArg(i)->getSourceRange());
+                  diag::err_shufflevector_nonconstant_argument)
+                << TheCall->getArg(i)->getSourceRange();
     
     if (Result.getActiveBits() > 64 || Result.getZExtValue() >= numElements*2)
       return Diag(TheCall->getLocStart(),
-                  diag::err_shufflevector_argument_too_large,
-                  TheCall->getArg(i)->getSourceRange());
+                  diag::err_shufflevector_argument_too_large)
+               << TheCall->getArg(i)->getSourceRange();
   }
 
   llvm::SmallVector<Expr*, 32> exprs;
@@ -301,48 +300,40 @@
 // This is declared to take (const void*, ...) and can take two
 // optional constant int args.
 bool Sema::SemaBuiltinPrefetch(CallExpr *TheCall) {
-  unsigned numArgs = TheCall->getNumArgs();
-  bool res = false;
+  unsigned NumArgs = TheCall->getNumArgs();
 
-  if (numArgs > 3) {
-    res |= Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_many_args,
-                TheCall->getSourceRange());
-  }
+  if (NumArgs > 3)
+    return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_many_args)
+             << TheCall->getSourceRange();
 
   // Argument 0 is checked for us and the remaining arguments must be
   // constant integers.
-  for (unsigned i=1; i<numArgs; ++i) {
+  for (unsigned i = 1; i != NumArgs; ++i) {
     Expr *Arg = TheCall->getArg(i);
     QualType RWType = Arg->getType();
 
     const BuiltinType *BT = RWType->getAsBuiltinType();
     llvm::APSInt Result;
     if (!BT || BT->getKind() != BuiltinType::Int ||
-        !Arg->isIntegerConstantExpr(Result, Context)) {
-      if (Diag(TheCall->getLocStart(), diag::err_prefetch_invalid_argument,
-               SourceRange(Arg->getLocStart(), Arg->getLocEnd()))) {
-        res = true;
-        continue;
-      }
-    }
+        !Arg->isIntegerConstantExpr(Result, Context))
+      return Diag(TheCall->getLocStart(), diag::err_prefetch_invalid_argument)
+              << SourceRange(Arg->getLocStart(), Arg->getLocEnd());
     
     // FIXME: gcc issues a warning and rewrites these to 0. These
     // seems especially odd for the third argument since the default
     // is 3.
-    if (i==1) {
+    if (i == 1) {
       if (Result.getSExtValue() < 0 || Result.getSExtValue() > 1)
-        res |= Diag(TheCall->getLocStart(), diag::err_argument_invalid_range,
-                    "0", "1", 
-                    SourceRange(Arg->getLocStart(), Arg->getLocEnd()));
+        return Diag(TheCall->getLocStart(), diag::err_argument_invalid_range)
+             << "0" << "1" << SourceRange(Arg->getLocStart(), Arg->getLocEnd());
     } else {
       if (Result.getSExtValue() < 0 || Result.getSExtValue() > 3)
-        res |= Diag(TheCall->getLocStart(), diag::err_argument_invalid_range,
-                    "0", "3", 
-                    SourceRange(Arg->getLocStart(), Arg->getLocEnd()));
+        return Diag(TheCall->getLocStart(), diag::err_argument_invalid_range)
+            << "0" << "3" << SourceRange(Arg->getLocStart(), Arg->getLocEnd());
     }
   }
 
-  return res;
+  return false;
 }
 
 /// SemaBuiltinObjectSize - Handle __builtin_object_size(void *ptr,
@@ -355,14 +346,13 @@
   llvm::APSInt Result(32);
   if (!BT || BT->getKind() != BuiltinType::Int ||
       !Arg->isIntegerConstantExpr(Result, Context)) {
-    return Diag(TheCall->getLocStart(), diag::err_object_size_invalid_argument,
-                SourceRange(Arg->getLocStart(), Arg->getLocEnd()));
+    return Diag(TheCall->getLocStart(), diag::err_object_size_invalid_argument)
+             << SourceRange(Arg->getLocStart(), Arg->getLocEnd());
   }
 
   if (Result.getSExtValue() < 0 || Result.getSExtValue() > 3) {
-    return Diag(TheCall->getLocStart(), diag::err_argument_invalid_range,
-                "0", "3", 
-                SourceRange(Arg->getLocStart(), Arg->getLocEnd()));
+    return Diag(TheCall->getLocStart(), diag::err_argument_invalid_range)
+             << "0" << "3" << SourceRange(Arg->getLocStart(), Arg->getLocEnd());
   }
 
   return false;
@@ -998,6 +988,6 @@
   
   // Emit the diagnostic.
   if (EmitWarning)
-    Diag(loc, diag::warn_floatingpoint_eq,
-         lex->getSourceRange(),rex->getSourceRange());
+    Diag(loc, diag::warn_floatingpoint_eq)
+      << lex->getSourceRange() << rex->getSourceRange();
 }
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 98f4c01..24308f6 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -802,8 +802,8 @@
   if (!Name) {
     if (!D.getInvalidType())  // Reject this if we think it is valid.
       Diag(D.getDeclSpec().getSourceRange().getBegin(),
-           diag::err_declarator_need_ident,
-           D.getDeclSpec().getSourceRange(), D.getSourceRange());
+           diag::err_declarator_need_ident)
+        << D.getDeclSpec().getSourceRange() << D.getSourceRange();
     return 0;
   }
   
@@ -846,8 +846,8 @@
         Diag(L, diag::err_invalid_declarator_in_function, Name.getAsString(), 
              R);
       } else {
-      Diag(L, diag::err_invalid_declarator_scope, Name.getAsString(),
-           cast<NamedDecl>(DC)->getName(), R);
+      Diag(L, diag::err_invalid_declarator_scope)
+          << Name.getAsString() << cast<NamedDecl>(DC)->getName() << R;
       }
     }
   }
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 2b52029..40f70fb 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -145,22 +145,21 @@
   QualType curType = tDecl->getUnderlyingType();
   // check the attribute arguments.
   if (Attr.getNumArgs() != 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "1";
     return;
   }
   Expr *sizeExpr = static_cast<Expr *>(Attr.getArg(0));
   llvm::APSInt vecSize(32);
   if (!sizeExpr->isIntegerConstantExpr(vecSize, S.Context)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int,
-           "ext_vector_type", sizeExpr->getSourceRange());
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int)
+      << "ext_vector_type" << sizeExpr->getSourceRange();
     return;
   }
   // unlike gcc's vector_size attribute, we do not allow vectors to be defined
   // in conjunction with complex types (pointers, arrays, functions, etc.).
   if (!curType->isIntegerType() && !curType->isRealFloatingType()) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type,
-           curType.getAsString());
+    S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type)
+      << curType.getAsString();
     return;
   }
   // unlike gcc's vector_size attribute, the size is specified as the 
@@ -168,8 +167,8 @@
   unsigned vectorSize = static_cast<unsigned>(vecSize.getZExtValue()); 
   
   if (vectorSize == 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_zero_size,
-           sizeExpr->getSourceRange());
+    S.Diag(Attr.getLoc(), diag::err_attribute_zero_size)
+      << sizeExpr->getSourceRange();
     return;
   }
   // Instantiate/Install the vector type, the number of elements is > 0.
@@ -194,23 +193,21 @@
   else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D))
     CurType = TD->getUnderlyingType();
   else {
-    S.Diag(D->getLocation(), diag::err_attr_wrong_decl,
-           std::string("vector_size"),
-           SourceRange(Attr.getLoc(), Attr.getLoc()));
+    S.Diag(D->getLocation(), diag::err_attr_wrong_decl)
+      << "vector_size" << SourceRange(Attr.getLoc(), Attr.getLoc());
     return;
   }
     
   // Check the attribute arugments.
   if (Attr.getNumArgs() != 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "1";
     return;
   }
   Expr *sizeExpr = static_cast<Expr *>(Attr.getArg(0));
   llvm::APSInt vecSize(32);
   if (!sizeExpr->isIntegerConstantExpr(vecSize, S.Context)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int,
-           "vector_size", sizeExpr->getSourceRange());
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int)
+      << "vector_size" << sizeExpr->getSourceRange();
     return;
   }
   // navigate to the base type - we need to provide for vector pointers, 
@@ -232,8 +229,8 @@
   }
   // the base type must be integer or float.
   if (!CurType->isIntegerType() && !CurType->isRealFloatingType()) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type,
-           CurType.getAsString());
+    S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type)
+      << CurType.getAsString();
     return;
   }
   unsigned typeSize = static_cast<unsigned>(S.Context.getTypeSize(CurType));
@@ -242,13 +239,13 @@
   
   // the vector size needs to be an integral multiple of the type size.
   if (vectorSize % typeSize) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_invalid_size,
-           sizeExpr->getSourceRange());
+    S.Diag(Attr.getLoc(), diag::err_attribute_invalid_size)
+      << sizeExpr->getSourceRange();
     return;
   }
   if (vectorSize == 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_zero_size,
-           sizeExpr->getSourceRange());
+    S.Diag(Attr.getLoc(), diag::err_attribute_zero_size)
+      << sizeExpr->getSourceRange();
     return;
   }
   
@@ -265,8 +262,7 @@
 static void HandlePackedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() > 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
@@ -277,21 +273,19 @@
     // has no effect.
     if (!FD->getType()->isIncompleteType() &&
         S.Context.getTypeAlign(FD->getType()) <= 8)
-      S.Diag(Attr.getLoc(), 
-             diag::warn_attribute_ignored_for_field_of_type,
-             Attr.getName()->getName(), FD->getType().getAsString());
+      S.Diag(Attr.getLoc(), diag::warn_attribute_ignored_for_field_of_type)
+        << Attr.getName()->getName() << FD->getType().getAsString();
     else
       FD->addAttr(new PackedAttr(1));
   } else
-    S.Diag(Attr.getLoc(), diag::warn_attribute_ignored,
-           Attr.getName()->getName());
+    S.Diag(Attr.getLoc(), diag::warn_attribute_ignored)
+      << Attr.getName()->getName();
 }
 
 static void HandleIBOutletAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() > 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
@@ -307,8 +301,8 @@
   // GCC ignores the nonnull attribute on K&R style function
   // prototypes, so we ignore it as well
   if (!isFunctionOrMethod(d) || !hasFunctionProto(d)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type,
-           "nonnull", "function");
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << "nonnull" << "function";
     return;
   }
   
@@ -325,16 +319,16 @@
     Expr *Ex = static_cast<Expr *>(Attr.getArg(0));
     llvm::APSInt ArgNum(32);
     if (!Ex->isIntegerConstantExpr(ArgNum, S.Context)) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int,
-             "nonnull", Ex->getSourceRange());
+      S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int)
+        << "nonnull" << Ex->getSourceRange();
       return;
     }
     
     unsigned x = (unsigned) ArgNum.getZExtValue();
         
     if (x < 1 || x > NumArgs) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds,
-             "nonnull", llvm::utostr_32(I.getArgNum()), Ex->getSourceRange());
+      S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
+       << "nonnull" << llvm::utostr_32(I.getArgNum()) << Ex->getSourceRange();
       return;
     }
     
@@ -344,8 +338,8 @@
     QualType T = getFunctionOrMethodArgType(d, x);    
     if (!T->isPointerType() && !T->isBlockPointerType()) {
       // FIXME: Should also highlight argument in decl.
-      S.Diag(Attr.getLoc(), diag::err_nonnull_pointers_only,
-             "nonnull", Ex->getSourceRange());
+      S.Diag(Attr.getLoc(), diag::err_nonnull_pointers_only)
+        << "nonnull" << Ex->getSourceRange();
       continue;
     }
     
@@ -376,8 +370,7 @@
 static void HandleAliasAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "1";
     return;
   }
   
@@ -386,8 +379,8 @@
   StringLiteral *Str = dyn_cast<StringLiteral>(Arg);
   
   if (Str == 0 || Str->isWide()) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string,
-           "alias", std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
+      << "alias" << "1";
     return;
   }
   
@@ -403,8 +396,7 @@
                                    Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
@@ -414,14 +406,13 @@
 static void HandleNoReturnAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
 
   if (!isFunctionOrMethod(d)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type,
-           "noreturn", "function");
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << "noreturn" << "function";
     return;
   }
   
@@ -431,14 +422,13 @@
 static void HandleUnusedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
   if (!isa<VarDecl>(d) && !isFunctionOrMethod(d)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type,
-           "unused", "variable and function");
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << "unused" << "variable and function";
     return;
   }
   
@@ -448,7 +438,8 @@
 static void HandleConstructorAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0 && Attr.getNumArgs() != 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments, "0 or 1");
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
+      << "0 or 1";
     return;
   } 
 
@@ -457,8 +448,8 @@
     Expr *E = static_cast<Expr *>(Attr.getArg(0));
     llvm::APSInt Idx(32);
     if (!E->isIntegerConstantExpr(Idx, S.Context)) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int,
-             "constructor", "1", E->getSourceRange());
+      S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int)
+        << "constructor" << "1" << E->getSourceRange();
       return;
     }
     priority = Idx.getZExtValue();
@@ -466,8 +457,8 @@
   
   FunctionDecl *Fn = dyn_cast<FunctionDecl>(d);
   if (!Fn) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type,
-           "constructor", "function");
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << "constructor" << "function";
     return;
   }
 
@@ -477,7 +468,8 @@
 static void HandleDestructorAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0 && Attr.getNumArgs() != 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments, "0 or 1");
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
+       << "0 or 1";
     return;
   } 
 
@@ -486,16 +478,16 @@
     Expr *E = static_cast<Expr *>(Attr.getArg(0));
     llvm::APSInt Idx(32);
     if (!E->isIntegerConstantExpr(Idx, S.Context)) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int,
-             "destructor", "1", E->getSourceRange());
+      S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int)
+        << "destructor" << "1" << E->getSourceRange();
       return;
     }
     priority = Idx.getZExtValue();
   }
   
   if (!isa<FunctionDecl>(d)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type,
-           "destructor", "function");
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << "destructor" << "function";
     return;
   }
 
@@ -505,8 +497,7 @@
 static void HandleDeprecatedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
@@ -516,8 +507,7 @@
 static void HandleVisibilityAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "1";
     return;
   }
   
@@ -526,8 +516,8 @@
   StringLiteral *Str = dyn_cast<StringLiteral>(Arg);
   
   if (Str == 0 || Str->isWide()) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string,
-           "visibility", std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
+      << "visibility" << "1";
     return;
   }
   
@@ -544,8 +534,8 @@
   else if (TypeLen == 9 && !memcmp(TypeStr, "protected", 9))
     type = VisibilityAttr::ProtectedVisibility;
   else {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported,
-           "visibility", TypeStr);
+    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
+      << "visibility" << TypeStr;
     return;
   }
   
@@ -554,14 +544,14 @@
 
 static void HandleObjCGCAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   if (!Attr.getParameterName()) {    
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string,
-           "objc_gc", std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
+      << "objc_gc" << "1";
     return;
   }
   
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
+      << "1";
     return;
   }
   
@@ -575,8 +565,8 @@
   else if (TypeLen == 6 && !memcmp(TypeStr, "strong", 6))
     type = ObjCGCAttr::Strong;
   else {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported,
-           "objc_gc", TypeStr);
+    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
+      << "objc_gc" << TypeStr;
     return;
   }
   
@@ -585,14 +575,14 @@
 
 static void HandleBlocksAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   if (!Attr.getParameterName()) {    
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string,
-           "blocks", std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
+      << "blocks" << "1";
     return;
   }
   
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
+      << "1";
     return;
   }
   const char *TypeStr = Attr.getParameterName()->getName();
@@ -603,8 +593,8 @@
   if (TypeLen == 5 && !memcmp(TypeStr, "byref", 5))
     type = BlocksAttr::ByRef;
   else {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported,
-           "blocks", TypeStr);
+    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
+      << "blocks" << TypeStr;
     return;
   }
   
@@ -614,7 +604,8 @@
 static void HandleSentinelAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() > 2) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments, "0, 1 or 2");
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
+      << "0, 1 or 2";
     return;
   } 
   
@@ -623,15 +614,15 @@
     Expr *E = static_cast<Expr *>(Attr.getArg(0));
     llvm::APSInt Idx(32);
     if (!E->isIntegerConstantExpr(Idx, S.Context)) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int,
-             "sentinel", "1", E->getSourceRange());
+      S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int)
+       << "sentinel" << "1" << E->getSourceRange();
       return;
     }
     sentinel = Idx.getZExtValue();
     
     if (sentinel < 0) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_sentinel_less_than_zero,
-             E->getSourceRange());
+      S.Diag(Attr.getLoc(), diag::err_attribute_sentinel_less_than_zero)
+        << E->getSourceRange();
       return;
     }
   }
@@ -641,8 +632,8 @@
     Expr *E = static_cast<Expr *>(Attr.getArg(1));
     llvm::APSInt Idx(32);
     if (!E->isIntegerConstantExpr(Idx, S.Context)) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int,
-             "sentinel", "2", E->getSourceRange());
+      S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int)
+        << "sentinel" << "2" << E->getSourceRange();
       return;
     }
     nullPos = Idx.getZExtValue();
@@ -650,8 +641,8 @@
     if (nullPos > 1 || nullPos < 0) {
       // FIXME: This error message could be improved, it would be nice
       // to say what the bounds actually are.
-      S.Diag(Attr.getLoc(), diag::err_attribute_sentinel_not_zero_or_one, 
-             E->getSourceRange());
+      S.Diag(Attr.getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
+        << E->getSourceRange();
       return;
     }
   }
@@ -668,8 +659,8 @@
       return;
     }    
   } else {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type,
-           "sentinel", "function or method");
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << "sentinel" << "function or method";
     return;
   }
   
@@ -679,8 +670,7 @@
 static void HandleWeakAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
@@ -690,8 +680,7 @@
 static void HandleDLLImportAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
@@ -701,8 +690,7 @@
 static void HandleDLLExportAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
@@ -712,8 +700,7 @@
 static void HandleStdCallAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
@@ -723,8 +710,7 @@
 static void HandleFastCallAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
@@ -734,8 +720,7 @@
 static void HandleNothrowAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
@@ -745,8 +730,7 @@
 static void HandleConstAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
@@ -756,8 +740,7 @@
 static void HandlePureAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
   
@@ -769,20 +752,19 @@
 static void HandleFormatAttr(Decl *d, const AttributeList &Attr, Sema &S) {
 
   if (!Attr.getParameterName()) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string,
-           "format", std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
+      << "format" << "1";
     return;
   }
 
   if (Attr.getNumArgs() != 2) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("3"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "3";
     return;
   }
 
   if (!isFunctionOrMethod(d) || !hasFunctionProto(d)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type,
-           "format", "function");
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << "format" << "function";
     return;
   }
 
@@ -820,8 +802,8 @@
   }
       
   if (!Supported) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported,
-           "format", Attr.getParameterName()->getName());
+    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
+      << "format" << Attr.getParameterName()->getName();
     return;
   }
 
@@ -829,14 +811,14 @@
   Expr *IdxExpr = static_cast<Expr *>(Attr.getArg(0));
   llvm::APSInt Idx(32);
   if (!IdxExpr->isIntegerConstantExpr(Idx, S.Context)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int,
-           "format", std::string("2"), IdxExpr->getSourceRange());
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int)
+      << "format" << "2" << IdxExpr->getSourceRange();
     return;
   }
 
   if (Idx.getZExtValue() < FirstIdx || Idx.getZExtValue() > NumArgs) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds,
-           "format", std::string("2"), IdxExpr->getSourceRange());
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
+      << "format" << "2" << IdxExpr->getSourceRange();
     return;
   }
 
@@ -848,8 +830,8 @@
 
   if (is_CFString) {
     if (!isCFStringType(Ty, S.Context)) {
-      S.Diag(Attr.getLoc(), diag::err_format_attribute_not,
-             "a CFString", IdxExpr->getSourceRange());
+      S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
+        << "a CFString" << IdxExpr->getSourceRange();
       return;
     }
   } else if (is_NSString) {
@@ -858,16 +840,16 @@
     if (!isNSStringType(Ty, S.Context)) {
       // FIXME: Should highlight the actual expression that has the
       // wrong type.
-      S.Diag(Attr.getLoc(), diag::err_format_attribute_not,
-             "an NSString", IdxExpr->getSourceRange());
+      S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
+        << "an NSString" << IdxExpr->getSourceRange();
       return;
     }    
   } else if (!Ty->isPointerType() ||
              !Ty->getAsPointerType()->getPointeeType()->isCharType()) {
     // FIXME: Should highlight the actual expression that has the
     // wrong type.
-    S.Diag(Attr.getLoc(), diag::err_format_attribute_not,
-           "a string type", IdxExpr->getSourceRange());
+    S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
+      << "a string type" << IdxExpr->getSourceRange();
     return;
   }
 
@@ -875,8 +857,8 @@
   Expr *FirstArgExpr = static_cast<Expr *>(Attr.getArg(1));
   llvm::APSInt FirstArg(32);
   if (!FirstArgExpr->isIntegerConstantExpr(FirstArg, S.Context)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int,
-           "format", std::string("3"), FirstArgExpr->getSourceRange());
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int)
+      << "format" << "3" << FirstArgExpr->getSourceRange();
     return;
   }
 
@@ -894,14 +876,14 @@
   // the input is just the current time + the format string
   if (is_strftime) {
     if (FirstArg != 0) {
-      S.Diag(Attr.getLoc(), diag::err_format_strftime_third_parameter,
-             FirstArgExpr->getSourceRange());
+      S.Diag(Attr.getLoc(), diag::err_format_strftime_third_parameter)
+        << FirstArgExpr->getSourceRange();
       return;
     }
   // if 0 it disables parameter checking (to use with e.g. va_list)
   } else if (FirstArg != 0 && FirstArg != NumArgs) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds,
-           "format", std::string("3"), FirstArgExpr->getSourceRange());
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
+      << "format" << "3" << FirstArgExpr->getSourceRange();
     return;
   }
 
@@ -913,16 +895,15 @@
                                        Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-         std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
 
   // FIXME: This shouldn't be restricted to typedefs
   TypedefDecl *TD = dyn_cast<TypedefDecl>(d);
   if (!TD || !TD->getUnderlyingType()->isUnionType()) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type,
-         "transparent_union", "union");
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << "transparent_union" << "union";
     return;
   }
 
@@ -951,8 +932,7 @@
 static void HandleAnnotateAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "1";
     return;
   }
   Expr *argExpr = static_cast<Expr *>(Attr.getArg(0));
@@ -971,8 +951,7 @@
 static void HandleAlignedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() > 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("1"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "1";
     return;
   }
 
@@ -987,8 +966,8 @@
   Expr *alignmentExpr = static_cast<Expr *>(Attr.getArg(0));
   llvm::APSInt Alignment(32);
   if (!alignmentExpr->isIntegerConstantExpr(Alignment, S.Context)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int,
-           "aligned", alignmentExpr->getSourceRange());
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int)
+      << "aligned" << alignmentExpr->getSourceRange();
     return;
   }
   d->addAttr(new AlignedAttr(Alignment.getZExtValue() * 8));
@@ -1007,8 +986,7 @@
 
   // Check that there aren't any arguments
   if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments,
-           std::string("0"));
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
     return;
   }
 
@@ -1061,8 +1039,8 @@
   else if (ValueDecl *VD = dyn_cast<ValueDecl>(D))
     OldTy = VD->getType();
   else {
-    S.Diag(D->getLocation(), diag::err_attr_wrong_decl, "mode",
-           SourceRange(Attr.getLoc(), Attr.getLoc()));
+    S.Diag(D->getLocation(), diag::err_attr_wrong_decl)
+      << "mode" << SourceRange(Attr.getLoc(), Attr.getLoc());
     return;
   }
   
@@ -1070,10 +1048,10 @@
   QualType NewTy;
   switch (DestWidth) {
   case 0:
-    S.Diag(Attr.getLoc(), diag::err_unknown_machine_mode, Name->getName());
+    S.Diag(Attr.getLoc(), diag::err_unknown_machine_mode) << Name->getName();
     return;
   default:
-    S.Diag(Attr.getLoc(), diag::err_unsupported_machine_mode, Name->getName());
+    S.Diag(Attr.getLoc(), diag::err_unsupported_machine_mode) <<Name->getName();
     return;
   case 8:
     assert(IntegerMode);
@@ -1170,8 +1148,8 @@
   default:
 #if 0
     // TODO: when we have the full set of attributes, warn about unknown ones.
-    S.Diag(Attr->getLoc(), diag::warn_attribute_ignored,
-           Attr->getName()->getName());
+    S.Diag(Attr->getLoc(), diag::warn_attribute_ignored)
+        <<  Attr->getName()->getName();
 #endif
     break;
   }
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index b3e0ca8..f2de5b2 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -75,16 +75,16 @@
       //   argument expression are in scope and can hide namespace and
       //   class member names.
       return S->Diag(DRE->getSourceRange().getBegin(), 
-                     diag::err_param_default_argument_references_param,
-                     Param->getName(), DefaultArg->getSourceRange());
+                     diag::err_param_default_argument_references_param)
+         << Param->getName() << DefaultArg->getSourceRange();
     } else if (VarDecl *VDecl = dyn_cast<VarDecl>(Decl)) {
       // C++ [dcl.fct.default]p7
       //   Local variables shall not be used in default argument
       //   expressions.
       if (VDecl->isBlockVarDecl())
         return S->Diag(DRE->getSourceRange().getBegin(), 
-                       diag::err_param_default_argument_references_local,
-                       VDecl->getName(), DefaultArg->getSourceRange());
+                       diag::err_param_default_argument_references_local)
+          << VDecl->getName() << DefaultArg->getSourceRange();
     }
 
     return false;
@@ -96,8 +96,8 @@
     //   The keyword this shall not be used in a default argument of a
     //   member function.
     return S->Diag(ThisE->getSourceRange().getBegin(),
-                   diag::err_param_default_argument_references_this,
-                   ThisE->getSourceRange());
+                   diag::err_param_default_argument_references_this)
+               << ThisE->getSourceRange();
   }
 }
 
@@ -113,8 +113,8 @@
 
   // Default arguments are only permitted in C++
   if (!getLangOptions().CPlusPlus) {
-    Diag(EqualLoc, diag::err_param_default_argument, 
-         DefaultArg->getSourceRange());
+    Diag(EqualLoc, diag::err_param_default_argument)
+      << DefaultArg->getSourceRange();
     return;
   }
 
@@ -163,8 +163,8 @@
       for (unsigned argIdx = 0; argIdx < chunk.Fun.NumArgs; ++argIdx) {
         ParmVarDecl *Param = (ParmVarDecl *)chunk.Fun.ArgInfo[argIdx].Param;
         if (Param->getDefaultArg()) {
-          Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc,
-               Param->getDefaultArg()->getSourceRange());
+          Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
+            << Param->getDefaultArg()->getSourceRange();
           Param->setDefaultArg(0);
         }
       }
@@ -196,8 +196,8 @@
 
     if(OldParam->getDefaultArg() && NewParam->getDefaultArg()) {
       Diag(NewParam->getLocation(), 
-           diag::err_param_default_argument_redefinition,
-           NewParam->getDefaultArg()->getSourceRange());
+           diag::err_param_default_argument_redefinition)
+        << NewParam->getDefaultArg()->getSourceRange();
       Diag(OldParam->getLocation(), diag::err_previous_definition);
     } else if (OldParam->getDefaultArg()) {
       // Merge the old default argument into the new parameter
@@ -234,8 +234,8 @@
     if (!Param->getDefaultArg()) {
       if (Param->getIdentifier())
         Diag(Param->getLocation(), 
-             diag::err_param_default_argument_missing_name,
-             Param->getIdentifier()->getName());
+             diag::err_param_default_argument_missing_name)
+          << Param->getIdentifier()->getName();
       else
         Diag(Param->getLocation(), 
              diag::err_param_default_argument_missing);
@@ -291,42 +291,33 @@
   QualType BaseType = Context.getTypeDeclType((TypeDecl*)basetype);
 
   // Base specifiers must be record types.
-  if (!BaseType->isRecordType()) {
-    Diag(BaseLoc, diag::err_base_must_be_class, SpecifierRange);
-    return true;
-  }
+  if (!BaseType->isRecordType())
+    return Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
 
   // C++ [class.union]p1:
   //   A union shall not be used as a base class.
-  if (BaseType->isUnionType()) {
-    Diag(BaseLoc, diag::err_union_as_base_class, SpecifierRange);
-    return true;
-  }
+  if (BaseType->isUnionType())
+    return Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
 
   // C++ [class.union]p1:
   //   A union shall not have base classes.
-  if (Decl->isUnion()) {
-    Diag(Decl->getLocation(), diag::err_base_clause_on_union,
-         SpecifierRange);
-    return true;
-  }
+  if (Decl->isUnion())
+    return Diag(Decl->getLocation(), diag::err_base_clause_on_union)
+              << SpecifierRange;
 
   // C++ [class.derived]p2:
   //   The class-name in a base-specifier shall not be an incompletely
   //   defined class.
-  if (BaseType->isIncompleteType()) {
-    Diag(BaseLoc, diag::err_incomplete_base_class, SpecifierRange);
-    return true;
-  }
+  if (BaseType->isIncompleteType())
+    return Diag(BaseLoc, diag::err_incomplete_base_class) << SpecifierRange;
 
   // If the base class is polymorphic, the new one is, too.
   RecordDecl *BaseDecl = BaseType->getAsRecordType()->getDecl();
   assert(BaseDecl && "Record type has no declaration");
   BaseDecl = BaseDecl->getDefinition(Context);
   assert(BaseDecl && "Base type is not incomplete, but has no definition");
-  if (cast<CXXRecordDecl>(BaseDecl)->isPolymorphic()) {
+  if (cast<CXXRecordDecl>(BaseDecl)->isPolymorphic())
     cast<CXXRecordDecl>(Decl)->setPolymorphic(true);
-  }
 
   // Create the base specifier.
   return new CXXBaseSpecifier(SpecifierRange, Virtual, 
@@ -360,9 +351,9 @@
       //   A class shall not be specified as a direct base class of a
       //   derived class more than once.
       Diag(BaseSpecs[idx]->getSourceRange().getBegin(),
-           diag::err_duplicate_base_class, 
-           KnownBaseTypes[NewBaseType]->getType().getAsString(),
-           BaseSpecs[idx]->getSourceRange());
+           diag::err_duplicate_base_class)
+        << KnownBaseTypes[NewBaseType]->getType().getAsString()
+        << BaseSpecs[idx]->getSourceRange();
 
       // Delete the duplicate base class specifier; we're going to
       // overwrite its pointer later.
@@ -442,11 +433,10 @@
     case DeclSpec::SCS_mutable:
       if (isFunc) {
         if (DS.getStorageClassSpecLoc().isValid())
-          Diag(DS.getStorageClassSpecLoc(),
-               diag::err_mutable_function);
+          Diag(DS.getStorageClassSpecLoc(), diag::err_mutable_function);
         else
-          Diag(DS.getThreadSpecLoc(),
-               diag::err_mutable_function);
+          Diag(DS.getThreadSpecLoc(), diag::err_mutable_function);
+        
         // FIXME: It would be nicer if the keyword was ignored only for this
         // declarator. Otherwise we could get follow-up errors.
         D.getMutableDeclSpec().ClearStorageClassSpecs();
@@ -535,29 +525,29 @@
     if (D.isFunctionDeclarator()) {
       // FIXME: Emit diagnostic about only constructors taking base initializers
       // or something similar, when constructor support is in place.
-      Diag(Loc, diag::err_not_bitfield_type,
-           Name.getAsString(), BitWidth->getSourceRange());
+      Diag(Loc, diag::err_not_bitfield_type)
+        << Name.getAsString() << BitWidth->getSourceRange();
       InvalidDecl = true;
 
     } else if (isInstField) {
       // C++ 9.6p3: A bit-field shall have integral or enumeration type.
       if (!cast<FieldDecl>(Member)->getType()->isIntegralType()) {
-        Diag(Loc, diag::err_not_integral_type_bitfield,
-             Name.getAsString(), BitWidth->getSourceRange());
+        Diag(Loc, diag::err_not_integral_type_bitfield)
+          << Name.getAsString() << BitWidth->getSourceRange();
         InvalidDecl = true;
       }
 
     } else if (isa<FunctionDecl>(Member)) {
       // A function typedef ("typedef int f(); f a;").
       // C++ 9.6p3: A bit-field shall have integral or enumeration type.
-      Diag(Loc, diag::err_not_integral_type_bitfield,
-           Name.getAsString(), BitWidth->getSourceRange());
+      Diag(Loc, diag::err_not_integral_type_bitfield)
+        << Name.getAsString() << BitWidth->getSourceRange();
       InvalidDecl = true;
 
     } else if (isa<TypedefDecl>(Member)) {
       // "cannot declare 'A' to be a bit-field type"
-      Diag(Loc, diag::err_not_bitfield_type, Name.getAsString(), 
-           BitWidth->getSourceRange());
+      Diag(Loc, diag::err_not_bitfield_type)
+        << Name.getAsString() << BitWidth->getSourceRange();
       InvalidDecl = true;
 
     } else {
@@ -565,8 +555,8 @@
              "Didn't we cover all member kinds?");
       // C++ 9.6p3: A bit-field shall not be a static member.
       // "static member 'A' cannot be a bit-field"
-      Diag(Loc, diag::err_static_not_bitfield, Name.getAsString(), 
-           BitWidth->getSourceRange());
+      Diag(Loc, diag::err_static_not_bitfield)
+        << Name.getAsString() << BitWidth->getSourceRange();
       InvalidDecl = true;
     }
   }
@@ -879,19 +869,15 @@
   //   volatile object. A constructor shall not be declared const,
   //   volatile, or const volatile (9.3.2).
   if (isVirtual) {
-    Diag(D.getIdentifierLoc(),
-         diag::err_constructor_cannot_be,
-         "virtual",
-         SourceRange(D.getDeclSpec().getVirtualSpecLoc()),
-         SourceRange(D.getIdentifierLoc()));
+    Diag(D.getIdentifierLoc(), diag::err_constructor_cannot_be)
+      << "virtual" << SourceRange(D.getDeclSpec().getVirtualSpecLoc())
+      << SourceRange(D.getIdentifierLoc());
     isInvalid = true;
   }
   if (SC == FunctionDecl::Static) {
-    Diag(D.getIdentifierLoc(),
-         diag::err_constructor_cannot_be,
-         "static",
-         SourceRange(D.getDeclSpec().getStorageClassSpecLoc()),
-         SourceRange(D.getIdentifierLoc()));
+    Diag(D.getIdentifierLoc(), diag::err_constructor_cannot_be)
+      << "static" << SourceRange(D.getDeclSpec().getStorageClassSpecLoc())
+      << SourceRange(D.getIdentifierLoc());
     isInvalid = true;
     SC = FunctionDecl::None;
   }
@@ -904,28 +890,21 @@
     //   };
     //
     // The return type will be eliminated later.
-    Diag(D.getIdentifierLoc(),
-         diag::err_constructor_return_type,
-         SourceRange(D.getDeclSpec().getTypeSpecTypeLoc()),
-         SourceRange(D.getIdentifierLoc()));
+    Diag(D.getIdentifierLoc(), diag::err_constructor_return_type)
+      << SourceRange(D.getDeclSpec().getTypeSpecTypeLoc())
+      << SourceRange(D.getIdentifierLoc());
   } 
   if (R->getAsFunctionTypeProto()->getTypeQuals() != 0) {
     DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
     if (FTI.TypeQuals & QualType::Const)
-      Diag(D.getIdentifierLoc(),
-           diag::err_invalid_qualified_constructor,
-           "const",
-           SourceRange(D.getIdentifierLoc()));
+      Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
+        << "const" << SourceRange(D.getIdentifierLoc());
     if (FTI.TypeQuals & QualType::Volatile)
-      Diag(D.getIdentifierLoc(),
-           diag::err_invalid_qualified_constructor,
-           "volatile",
-           SourceRange(D.getIdentifierLoc()));
+      Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
+        << "volatile" << SourceRange(D.getIdentifierLoc());
     if (FTI.TypeQuals & QualType::Restrict)
-      Diag(D.getIdentifierLoc(),
-           diag::err_invalid_qualified_constructor,
-           "restrict",
-           SourceRange(D.getIdentifierLoc()));
+      Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
+        << "restrict" << SourceRange(D.getIdentifierLoc());
   }
       
   // Rebuild the function type "R" without any type qualifiers (in
@@ -959,9 +938,8 @@
   //   declaration.
   TypeDecl *DeclaratorTypeD = (TypeDecl *)D.getDeclaratorIdType();
   if (const TypedefDecl *TypedefD = dyn_cast<TypedefDecl>(DeclaratorTypeD)) {
-    Diag(D.getIdentifierLoc(), 
-         diag::err_destructor_typedef_name,
-         TypedefD->getName());
+    Diag(D.getIdentifierLoc(),  diag::err_destructor_typedef_name)
+      << TypedefD->getName();
     isInvalid = true;
   }
 
@@ -974,11 +952,9 @@
   //   volatile object. A destructor shall not be declared const,
   //   volatile or const volatile (9.3.2).
   if (SC == FunctionDecl::Static) {
-    Diag(D.getIdentifierLoc(),
-         diag::err_destructor_cannot_be,
-         "static",
-         SourceRange(D.getDeclSpec().getStorageClassSpecLoc()),
-         SourceRange(D.getIdentifierLoc()));
+    Diag(D.getIdentifierLoc(), diag::err_destructor_cannot_be)
+      << "static" << SourceRange(D.getDeclSpec().getStorageClassSpecLoc())
+      << SourceRange(D.getIdentifierLoc());
     isInvalid = true;
     SC = FunctionDecl::None;
   }
@@ -991,28 +967,21 @@
     //   };
     //
     // The return type will be eliminated later.
-    Diag(D.getIdentifierLoc(),
-         diag::err_destructor_return_type,
-         SourceRange(D.getDeclSpec().getTypeSpecTypeLoc()),
-         SourceRange(D.getIdentifierLoc()));
+    Diag(D.getIdentifierLoc(), diag::err_destructor_return_type)
+      << SourceRange(D.getDeclSpec().getTypeSpecTypeLoc())
+      << SourceRange(D.getIdentifierLoc());
   }
   if (R->getAsFunctionTypeProto()->getTypeQuals() != 0) {
     DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
     if (FTI.TypeQuals & QualType::Const)
-      Diag(D.getIdentifierLoc(),
-           diag::err_invalid_qualified_destructor,
-           "const",
-           SourceRange(D.getIdentifierLoc()));
+      Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_destructor)
+        << "const" << SourceRange(D.getIdentifierLoc());
     if (FTI.TypeQuals & QualType::Volatile)
-      Diag(D.getIdentifierLoc(),
-           diag::err_invalid_qualified_destructor,
-           "volatile",
-           SourceRange(D.getIdentifierLoc()));
+      Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_destructor)
+        << "volatile" << SourceRange(D.getIdentifierLoc());
     if (FTI.TypeQuals & QualType::Restrict)
-      Diag(D.getIdentifierLoc(),
-           diag::err_invalid_qualified_destructor,
-           "restrict",
-           SourceRange(D.getIdentifierLoc()));
+      Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_destructor)
+        << "restrict" << SourceRange(D.getIdentifierLoc());
   }
 
   // Make sure we don't have any parameters.
@@ -1057,11 +1026,9 @@
   //   type of a conversion function (8.3.5) is “function taking no
   //   parameter returning conversion-type-id.” 
   if (SC == FunctionDecl::Static) {
-    Diag(D.getIdentifierLoc(),
-         diag::err_conv_function_not_member,
-         "static",
-         SourceRange(D.getDeclSpec().getStorageClassSpecLoc()),
-         SourceRange(D.getIdentifierLoc()));
+    Diag(D.getIdentifierLoc(), diag::err_conv_function_not_member)
+      << "static" << SourceRange(D.getDeclSpec().getStorageClassSpecLoc())
+      << SourceRange(D.getIdentifierLoc());
     isInvalid = true;
     SC = FunctionDecl::None;
   }
@@ -1074,10 +1041,9 @@
     //   };
     //
     // The return type will be changed later anyway.
-    Diag(D.getIdentifierLoc(),
-         diag::err_conv_function_return_type,
-         SourceRange(D.getDeclSpec().getTypeSpecTypeLoc()),
-         SourceRange(D.getIdentifierLoc()));
+    Diag(D.getIdentifierLoc(), diag::err_conv_function_return_type)
+      << SourceRange(D.getDeclSpec().getTypeSpecTypeLoc())
+      << SourceRange(D.getIdentifierLoc());
   }
 
   // Make sure we don't have any parameters.
@@ -1145,12 +1111,10 @@
   // constructors.
   OverloadedFunctionDecl::function_iterator MatchedDecl;
   if (!IsOverload(ConDecl, ClassDecl->getConstructors(), MatchedDecl)) {
-    Diag(ConDecl->getLocation(),
-         diag::err_constructor_redeclared,
-         SourceRange(ConDecl->getLocation()));
-    Diag((*MatchedDecl)->getLocation(),
-         diag::err_previous_declaration,
-         SourceRange((*MatchedDecl)->getLocation()));
+    Diag(ConDecl->getLocation(), diag::err_constructor_redeclared)
+      << SourceRange(ConDecl->getLocation());
+    Diag((*MatchedDecl)->getLocation(), diag::err_previous_declaration)
+      << SourceRange((*MatchedDecl)->getLocation());
     ConDecl->setInvalidDecl();
     return ConDecl;
   }
@@ -1168,9 +1132,8 @@
     QualType ClassTy = Context.getTagDeclType(
                          const_cast<CXXRecordDecl*>(ConDecl->getParent()));
     if (Context.getCanonicalType(ParamType).getUnqualifiedType() == ClassTy) {
-      Diag(ConDecl->getLocation(),
-           diag::err_constructor_byvalue_arg,
-           SourceRange(ConDecl->getParamDecl(0)->getLocation()));
+      Diag(ConDecl->getLocation(), diag::err_constructor_byvalue_arg)
+        << SourceRange(ConDecl->getParamDecl(0)->getLocation());
       ConDecl->setInvalidDecl();
       return ConDecl;
     }
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;
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 0e62e26..d4307c1 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -282,9 +282,9 @@
 
   // Verify that pascal strings aren't too large.
   if (Literal.Pascal && Literal.GetStringLength() > 256)
-    return Diag(StringToks[0].getLocation(), diag::err_pascal_string_too_long,
-                SourceRange(StringToks[0].getLocation(),
-                            StringToks[NumStringToks-1].getLocation()));
+    return Diag(StringToks[0].getLocation(), diag::err_pascal_string_too_long)
+      << SourceRange(StringToks[0].getLocation(),
+                     StringToks[NumStringToks-1].getLocation());
   
   QualType StrTy = Context.CharTy;
   if (Literal.AnyWide) StrTy = Context.getWCharType();
@@ -420,9 +420,9 @@
                     Name.getAsString(), SS->getRange());
       else if (Name.getNameKind() == DeclarationName::CXXOperatorName ||
                Name.getNameKind() == DeclarationName::CXXConversionFunctionName)
-        return Diag(Loc, diag::err_undeclared_use, Name.getAsString());
+        return Diag(Loc, diag::err_undeclared_use) << Name.getAsString();
       else
-        return Diag(Loc, diag::err_undeclared_var_use, Name.getAsString());
+        return Diag(Loc, diag::err_undeclared_var_use) << Name.getAsString();
     }
   }
   
@@ -430,12 +430,12 @@
     if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext)) {
       if (MD->isStatic())
         // "invalid use of member 'x' in static member function"
-        return Diag(Loc, diag::err_invalid_member_use_in_static_method,
-                    FD->getName());
+        return Diag(Loc, diag::err_invalid_member_use_in_static_method)
+           << FD->getName();
       if (cast<CXXRecordDecl>(MD->getParent()) != FD->getParent())
         // "invalid use of nonstatic data member 'x'"
-        return Diag(Loc, diag::err_invalid_non_static_member_use,
-                    FD->getName());
+        return Diag(Loc, diag::err_invalid_non_static_member_use)
+          << FD->getName();
 
       if (FD->isInvalidDecl())
         return true;
@@ -445,14 +445,14 @@
         FD->getType().getWithAdditionalQualifiers(MD->getTypeQualifiers()),Loc);
     }
 
-    return Diag(Loc, diag::err_invalid_non_static_member_use, FD->getName());
+    return Diag(Loc, diag::err_invalid_non_static_member_use) << FD->getName();
   }
   if (isa<TypedefDecl>(D))
-    return Diag(Loc, diag::err_unexpected_typedef, Name.getAsString());
+    return Diag(Loc, diag::err_unexpected_typedef) << Name.getAsString();
   if (isa<ObjCInterfaceDecl>(D))
-    return Diag(Loc, diag::err_unexpected_interface, Name.getAsString());
+    return Diag(Loc, diag::err_unexpected_interface) << Name.getAsString();
   if (isa<NamespaceDecl>(D))
-    return Diag(Loc, diag::err_unexpected_namespace, Name.getAsString());
+    return Diag(Loc, diag::err_unexpected_namespace) << Name.getAsString();
 
   // Make the DeclRefExpr or BlockDeclRefExpr for the decl.
   if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D))
@@ -462,7 +462,7 @@
   
   // check if referencing an identifier with __attribute__((deprecated)).
   if (VD->getAttr<DeprecatedAttr>())
-    Diag(Loc, diag::warn_deprecated, VD->getName());
+    Diag(Loc, diag::warn_deprecated) << VD->getName();
 
   // Only create DeclRefExpr's for valid Decl's.
   if (VD->isInvalidDecl())
@@ -692,16 +692,14 @@
   // C99 6.5.3.4p1:
   if (isa<FunctionType>(exprType) && isSizeof)
     // alignof(function) is allowed.
-    Diag(OpLoc, diag::ext_sizeof_function_type, ExprRange);
+    Diag(OpLoc, diag::ext_sizeof_function_type) << ExprRange;
   else if (exprType->isVoidType())
-    Diag(OpLoc, diag::ext_sizeof_void_type, isSizeof ? "sizeof" : "__alignof",
-         ExprRange);
-  else if (exprType->isIncompleteType()) {
-    Diag(OpLoc, isSizeof ? diag::err_sizeof_incomplete_type : 
-                           diag::err_alignof_incomplete_type,
-         exprType.getAsString(), ExprRange);
-    return true; // error
-  }
+    Diag(OpLoc, diag::ext_sizeof_void_type)
+      << (isSizeof ? "sizeof" : "__alignof") << ExprRange;
+  else if (exprType->isIncompleteType())
+    return Diag(OpLoc, isSizeof ? diag::err_sizeof_incomplete_type : 
+                                  diag::err_alignof_incomplete_type)
+      << exprType.getAsString() << ExprRange;
 
   return false;
 }
@@ -748,7 +746,7 @@
     return V->getType();
   
   // Reject anything else.
-  Diag(Loc, diag::err_realimag_invalid_type, V->getType().getAsString());
+  Diag(Loc, diag::err_realimag_invalid_type) << V->getType().getAsString();
   return QualType();
 }
 
@@ -804,18 +802,18 @@
     // Component access limited to variables (reject vec4.rg[1]).
     if (!isa<DeclRefExpr>(BaseExpr) && !isa<ArraySubscriptExpr>(BaseExpr) &&
         !isa<ExtVectorElementExpr>(BaseExpr))
-      return Diag(LLoc, diag::err_ext_vector_component_access, 
-                  SourceRange(LLoc, RLoc));
+      return Diag(LLoc, diag::err_ext_vector_component_access)
+        << SourceRange(LLoc, RLoc);
     // FIXME: need to deal with const...
     ResultType = VTy->getElementType();
   } else {
-    return Diag(LHSExp->getLocStart(), diag::err_typecheck_subscript_value, 
-                RHSExp->getSourceRange());
+    return Diag(LHSExp->getLocStart(), diag::err_typecheck_subscript_value)
+      << RHSExp->getSourceRange();
   }              
   // C99 6.5.2.1p1
   if (!IndexExpr->getType()->isIntegerType())
-    return Diag(IndexExpr->getLocStart(), diag::err_typecheck_subscript,
-                IndexExpr->getSourceRange());
+    return Diag(IndexExpr->getLocStart(), diag::err_typecheck_subscript)
+      << IndexExpr->getSourceRange();
 
   // C99 6.5.2.1p1: "shall have type "pointer to *object* type".  In practice,
   // the following check catches trying to index a pointer to a function (e.g.
@@ -823,8 +821,8 @@
   // objects in C99.
   if (!ResultType->isObjectType())
     return Diag(BaseExpr->getLocStart(), 
-                diag::err_typecheck_subscript_not_object,
-                BaseExpr->getType().getAsString(), BaseExpr->getSourceRange());
+                diag::err_typecheck_subscript_not_object)
+      << BaseExpr->getType().getAsString() << BaseExpr->getSourceRange();
 
   return new ArraySubscriptExpr(LHSExp, RHSExp, ResultType, RLoc);
 }
@@ -841,8 +839,8 @@
   // The vector accessor can't exceed the number of elements.
   const char *compStr = CompName.getName();
   if (strlen(compStr) > vecType->getNumElements()) {
-    Diag(OpLoc, diag::err_ext_vector_component_exceeds_length, 
-                baseType.getAsString(), SourceRange(CompLoc));
+    Diag(OpLoc, diag::err_ext_vector_component_exceeds_length)
+      << baseType.getAsString() << SourceRange(CompLoc);
     return QualType();
   }
 
@@ -868,8 +866,8 @@
   if (!SpecialComponent && *compStr) { 
     // We didn't get to the end of the string. This means the component names
     // didn't come from the same set *or* we encountered an illegal name.
-    Diag(OpLoc, diag::err_ext_vector_component_name_illegal, 
-         std::string(compStr,compStr+1), SourceRange(CompLoc));
+    Diag(OpLoc, diag::err_ext_vector_component_name_illegal)
+      << std::string(compStr,compStr+1) << SourceRange(CompLoc);
     return QualType();
   }
   // Each component accessor can't exceed the vector type.
@@ -883,8 +881,8 @@
   if (!SpecialComponent && *compStr) { 
     // We didn't get to the end of the string. This means a component accessor
     // exceeds the number of elements in the vector.
-    Diag(OpLoc, diag::err_ext_vector_component_exceeds_length, 
-                baseType.getAsString(), SourceRange(CompLoc));
+    Diag(OpLoc, diag::err_ext_vector_component_exceeds_length)
+      << baseType.getAsString() << SourceRange(CompLoc);
     return QualType();
   }
 
@@ -892,8 +890,8 @@
   // is an even number, since all special component names return exactly half
   // the elements.
   if (SpecialComponent && (vecType->getNumElements() & 1U)) {
-    Diag(OpLoc, diag::err_ext_vector_component_requires_even, 
-         baseType.getAsString(), SourceRange(CompLoc));
+    Diag(OpLoc, diag::err_ext_vector_component_requires_even)
+      << baseType.getAsString() << SourceRange(CompLoc);
     return QualType();
   }
   
@@ -954,8 +952,8 @@
     if (const PointerType *PT = BaseType->getAsPointerType())
       BaseType = PT->getPointeeType();
     else
-      return Diag(MemberLoc, diag::err_typecheck_member_reference_arrow,
-                  BaseType.getAsString(), BaseExpr->getSourceRange());
+      return Diag(MemberLoc, diag::err_typecheck_member_reference_arrow)
+        << BaseType.getAsString() << BaseExpr->getSourceRange();
   }
   
   // Handle field access to simple records.  This also handles access to fields
@@ -963,13 +961,13 @@
   if (const RecordType *RTy = BaseType->getAsRecordType()) {
     RecordDecl *RDecl = RTy->getDecl();
     if (RTy->isIncompleteType())
-      return Diag(OpLoc, diag::err_typecheck_incomplete_tag, RDecl->getName(),
-                  BaseExpr->getSourceRange());
+      return Diag(OpLoc, diag::err_typecheck_incomplete_tag)
+               << RDecl->getName() << BaseExpr->getSourceRange();
     // The record definition is complete, now make sure the member is valid.
     FieldDecl *MemberDecl = RDecl->getMember(&Member);
     if (!MemberDecl)
-      return Diag(MemberLoc, diag::err_typecheck_no_member, Member.getName(),
-                  BaseExpr->getSourceRange());
+      return Diag(MemberLoc, diag::err_typecheck_no_member)
+               << Member.getName() << BaseExpr->getSourceRange();
 
     // Figure out the type of the member; see C99 6.5.2.3p3
     // FIXME: Handle address space modifiers
@@ -992,9 +990,9 @@
     if (ObjCIvarDecl *IV = IFTy->getDecl()->lookupInstanceVariable(&Member))
       return new ObjCIvarRefExpr(IV, IV->getType(), MemberLoc, BaseExpr, 
                                  OpKind == tok::arrow);
-    return Diag(MemberLoc, diag::err_typecheck_member_reference_ivar,
-                IFTy->getDecl()->getName(), Member.getName(),
-                BaseExpr->getSourceRange());
+    return Diag(MemberLoc, diag::err_typecheck_member_reference_ivar)
+             << IFTy->getDecl()->getName() << Member.getName()
+             << BaseExpr->getSourceRange();
   }
   
   // Handle Objective-C property access, which is "Obj.property" where Obj is a
@@ -1078,16 +1076,16 @@
     // Component access limited to variables (reject vec4.rg.g).
     if (!isa<DeclRefExpr>(BaseExpr) && !isa<ArraySubscriptExpr>(BaseExpr) &&
         !isa<ExtVectorElementExpr>(BaseExpr))
-      return Diag(MemberLoc, diag::err_ext_vector_component_access, 
-                  BaseExpr->getSourceRange());
+      return Diag(MemberLoc, diag::err_ext_vector_component_access)
+               << BaseExpr->getSourceRange();
     QualType ret = CheckExtVectorComponent(BaseType, OpLoc, Member, MemberLoc);
     if (ret.isNull())
       return true;
     return new ExtVectorElementExpr(ret, BaseExpr, Member, MemberLoc);
   }
   
-  return Diag(MemberLoc, diag::err_typecheck_member_reference_struct_union,
-              BaseType.getAsString(), BaseExpr->getSourceRange());
+  return Diag(MemberLoc, diag::err_typecheck_member_reference_struct_union)
+          << BaseType.getAsString() << BaseExpr->getSourceRange();
 }
 
 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
@@ -1140,20 +1138,19 @@
     case OR_No_Viable_Function:
       if (CandidateSet.empty())
         Diag(Fn->getSourceRange().getBegin(), 
-             diag::err_ovl_no_viable_function_in_call, Ovl->getName(),
-             Fn->getSourceRange());
+             diag::err_ovl_no_viable_function_in_call)
+          << Ovl->getName() << Fn->getSourceRange();
       else {
         Diag(Fn->getSourceRange().getBegin(), 
-             diag::err_ovl_no_viable_function_in_call_with_cands, 
-             Ovl->getName(), Fn->getSourceRange());
+             diag::err_ovl_no_viable_function_in_call_with_cands)
+          << Ovl->getName() << Fn->getSourceRange();
         PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);
       }
       return true;
 
     case OR_Ambiguous:
-      Diag(Fn->getSourceRange().getBegin(), 
-           diag::err_ovl_ambiguous_call, Ovl->getName(), 
-           Fn->getSourceRange());
+      Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_ambiguous_call)
+        << Ovl->getName() << Fn->getSourceRange();
       PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true);
       return true;
     }
@@ -1172,16 +1169,16 @@
     // have type pointer to function".
     const PointerType *PT = Fn->getType()->getAsPointerType();
     if (PT == 0)
-      return Diag(LParenLoc, diag::err_typecheck_call_not_function,
-                  Fn->getSourceRange());
+      return Diag(LParenLoc, diag::err_typecheck_call_not_function)
+        << Fn->getSourceRange();
     FuncT = PT->getPointeeType()->getAsFunctionType();
   } else { // This is a block call.
     FuncT = Fn->getType()->getAsBlockPointerType()->getPointeeType()->
                 getAsFunctionType();
   }
   if (FuncT == 0)
-    return Diag(LParenLoc, diag::err_typecheck_call_not_function,
-                Fn->getSourceRange());
+    return Diag(LParenLoc, diag::err_typecheck_call_not_function)
+      << Fn->getSourceRange();
   
   // We know the result type of the call, set it.
   TheCall->setType(FuncT->getResultType().getNonReferenceType());
@@ -1203,8 +1200,8 @@
         return Diag(RParenLoc, 
                     !Fn->getType()->isBlockPointerType()
                       ? diag::err_typecheck_call_too_few_args
-                      : diag::err_typecheck_block_too_few_args,
-                    Fn->getSourceRange());
+                      : diag::err_typecheck_block_too_few_args)
+          << Fn->getSourceRange();
     }
 
     // If too many are passed and not variadic, error on the extras and drop
@@ -1214,10 +1211,10 @@
         Diag(Args[NumArgsInProto]->getLocStart(), 
                !Fn->getType()->isBlockPointerType()
                  ? diag::err_typecheck_call_too_many_args
-                 : diag::err_typecheck_block_too_many_args, 
-             Fn->getSourceRange(),
-             SourceRange(Args[NumArgsInProto]->getLocStart(),
-                         Args[NumArgs-1]->getLocEnd()));
+                 : diag::err_typecheck_block_too_many_args)
+          << Fn->getSourceRange()
+          << SourceRange(Args[NumArgsInProto]->getLocStart(),
+                         Args[NumArgs-1]->getLocEnd());
         // This deletes the extra arguments.
         TheCall->setNumArgs(NumArgsInProto);
       }
@@ -1280,16 +1277,12 @@
 
   if (literalType->isArrayType()) {
     if (literalType->isVariableArrayType())
-      return Diag(LParenLoc,
-                  diag::err_variable_object_no_init,
-                  SourceRange(LParenLoc,
-                              literalExpr->getSourceRange().getEnd()));
+      return Diag(LParenLoc, diag::err_variable_object_no_init)
+        << SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd());
   } else if (literalType->isIncompleteType()) {
-    return Diag(LParenLoc,
-                diag::err_typecheck_decl_incomplete_type,
-                literalType.getAsString(),
-                SourceRange(LParenLoc,
-                            literalExpr->getSourceRange().getEnd()));
+    return Diag(LParenLoc, diag::err_typecheck_decl_incomplete_type)
+      << literalType.getAsString()
+      << SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd());
   }
 
   if (CheckInitializerTypes(literalExpr, literalType, LParenLoc, 
@@ -1334,18 +1327,18 @@
         Context.getCanonicalType(castExpr->getType()) ||
         (!castType->isStructureType() && !castType->isUnionType())) {
       // Reject any other conversions to non-scalar types.
-      return Diag(TyR.getBegin(), diag::err_typecheck_cond_expect_scalar, 
-                  castType.getAsString(), castExpr->getSourceRange());
+      return Diag(TyR.getBegin(), diag::err_typecheck_cond_expect_scalar)
+        << castType.getAsString() << castExpr->getSourceRange();
     }
       
     // accept this, but emit an ext-warn.
-    Diag(TyR.getBegin(), diag::ext_typecheck_cast_nonscalar, 
-         castType.getAsString(), castExpr->getSourceRange());
+    Diag(TyR.getBegin(), diag::ext_typecheck_cast_nonscalar)
+      << castType.getAsString() << castExpr->getSourceRange();
   } else if (!castExpr->getType()->isScalarType() && 
              !castExpr->getType()->isVectorType()) {
-    return Diag(castExpr->getLocStart(), 
-                diag::err_typecheck_expect_scalar_operand, 
-                castExpr->getType().getAsString(),castExpr->getSourceRange());
+    return Diag(castExpr->getLocStart(),
+                diag::err_typecheck_expect_scalar_operand)
+      << castExpr->getType().getAsString() << castExpr->getSourceRange();
   } else if (castExpr->getType()->isVectorType()) {
     if (CheckVectorCast(TyR, castExpr->getType(), castType))
       return true;
@@ -1364,14 +1357,12 @@
       return Diag(R.getBegin(),
                   Ty->isVectorType() ? 
                   diag::err_invalid_conversion_between_vectors :
-                  diag::err_invalid_conversion_between_vector_and_integer,
-                  VectorTy.getAsString().c_str(),
-                  Ty.getAsString().c_str(), R);
+                  diag::err_invalid_conversion_between_vector_and_integer)
+        << VectorTy.getAsString() << Ty.getAsString() << R;
   } else
     return Diag(R.getBegin(),
-                diag::err_invalid_conversion_between_vector_and_scalar,
-                VectorTy.getAsString().c_str(),
-                Ty.getAsString().c_str(), R);
+                diag::err_invalid_conversion_between_vector_and_scalar)
+      << VectorTy.getAsString() << Ty.getAsString() << R;
   
   return false;
 }
@@ -2002,11 +1993,11 @@
       // Check for arithmetic on pointers to incomplete types
       if (!PTy->getPointeeType()->isObjectType()) {
         if (PTy->getPointeeType()->isVoidType()) {
-          Diag(Loc, diag::ext_gnu_void_ptr, 
-               lex->getSourceRange(), rex->getSourceRange());
+          Diag(Loc, diag::ext_gnu_void_ptr)
+            << lex->getSourceRange() << rex->getSourceRange();
         } else {
-          Diag(Loc, diag::err_typecheck_arithmetic_incomplete_type,
-               lex->getType().getAsString(), lex->getSourceRange());
+          Diag(Loc, diag::err_typecheck_arithmetic_incomplete_type)
+            << lex->getType().getAsString() << lex->getSourceRange();
           return QualType();
         }
       }
@@ -2039,11 +2030,11 @@
     if (!lpointee->isObjectType()) {
       // Handle the GNU void* extension.
       if (lpointee->isVoidType()) {
-        Diag(Loc, diag::ext_gnu_void_ptr, 
-             lex->getSourceRange(), rex->getSourceRange());
+        Diag(Loc, diag::ext_gnu_void_ptr)
+          << lex->getSourceRange() << rex->getSourceRange();
       } else {
-        Diag(Loc, diag::err_typecheck_sub_ptr_object,
-             lex->getType().getAsString(), lex->getSourceRange());
+        Diag(Loc, diag::err_typecheck_sub_ptr_object)
+          << lex->getType().getAsString() << lex->getSourceRange();
         return QualType();
       }
     }
@@ -2061,11 +2052,11 @@
         // Handle the GNU void* extension.
         if (rpointee->isVoidType()) {
           if (!lpointee->isVoidType())
-            Diag(Loc, diag::ext_gnu_void_ptr, 
-                 lex->getSourceRange(), rex->getSourceRange());
+            Diag(Loc, diag::ext_gnu_void_ptr)
+              << lex->getSourceRange() << rex->getSourceRange();
         } else {
-          Diag(Loc, diag::err_typecheck_sub_ptr_object,
-               rex->getType().getAsString(), rex->getSourceRange());
+          Diag(Loc, diag::err_typecheck_sub_ptr_object)
+            << rex->getType().getAsString() << rex->getSourceRange();
           return QualType();
         }
       }
@@ -2929,10 +2920,9 @@
       break;
 
     case OR_Ambiguous:
-      Diag(TokLoc, 
-           diag::err_ovl_ambiguous_oper, 
-           BinaryOperator::getOpcodeStr(Opc), 
-           lhs->getSourceRange(), rhs->getSourceRange());
+      Diag(TokLoc,  diag::err_ovl_ambiguous_oper)
+          << BinaryOperator::getOpcodeStr(Opc)
+          << lhs->getSourceRange() << rhs->getSourceRange();
       PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true);
       return true;
     }
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index f6f3202..fff5ae4 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -96,7 +96,7 @@
                                                    SourceLocation RParenLoc) {
   ObjCProtocolDecl* PDecl = ObjCProtocols[ProtocolId];
   if (!PDecl) {
-    Diag(ProtoLoc, diag::err_undeclared_protocol, ProtocolId->getName());
+    Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId->getName();
     return true;
   }
   
@@ -117,8 +117,8 @@
     for (unsigned i = 0; i != NumArgs; i++)
       DefaultArgumentPromotion(Args[i]);
 
-    Diag(lbrac, diag::warn_method_not_found, std::string(PrefixStr),
-         Sel.getName(), SourceRange(lbrac, rbrac));
+    Diag(lbrac, diag::warn_method_not_found)
+      << PrefixStr << Sel.getName() << SourceRange(lbrac, rbrac);
     ReturnType = Context.getObjCIdType();
     return false;
   } else {
@@ -160,10 +160,10 @@
     // Check for extra arguments to non-variadic methods.
     if (NumArgs != NumNamedArgs) {
       Diag(Args[NumNamedArgs]->getLocStart(), 
-           diag::err_typecheck_call_too_many_args,
-           Method->getSourceRange(),
-           SourceRange(Args[NumNamedArgs]->getLocStart(),
-                       Args[NumArgs-1]->getLocEnd()));
+           diag::err_typecheck_call_too_many_args)
+        << Method->getSourceRange()
+        << SourceRange(Args[NumNamedArgs]->getLocStart(),
+                       Args[NumArgs-1]->getLocEnd());
     }
   }
 
@@ -188,8 +188,8 @@
     isSuper = true;
     ClassDecl = getCurMethodDecl()->getClassInterface()->getSuperClass();
     if (!ClassDecl)
-      return Diag(lbrac, diag::error_no_super_class,
-                  getCurMethodDecl()->getClassInterface()->getName());
+      return Diag(lbrac, diag::error_no_super_class)
+        << getCurMethodDecl()->getClassInterface()->getName();
     if (getCurMethodDecl()->isInstance()) {
       QualType superTy = Context.getObjCInterfaceType(ClassDecl);
       superTy = Context.getPointerType(superTy);
@@ -344,9 +344,8 @@
         break;
     }
     if (!Method)
-      Diag(lbrac, diag::warn_method_not_found_in_protocol, 
-           std::string("-"), Sel.getName(),
-           RExpr->getSourceRange());
+      Diag(lbrac, diag::warn_method_not_found_in_protocol)
+        << "-" << Sel.getName() << RExpr->getSourceRange();
   } else if (const ObjCInterfaceType *OCIReceiver = 
                 ReceiverCType->getAsPointerToObjCInterfaceType()) {
     // We allow sending a message to a pointer to an interface (an object).
@@ -367,12 +366,11 @@
     }
     
     if (!Method && !OCIReceiver->qual_empty())
-      Diag(lbrac, diag::warn_method_not_found_in_protocol, 
-           std::string("-"), Sel.getName(),
-           SourceRange(lbrac, rbrac));
+      Diag(lbrac, diag::warn_method_not_found_in_protocol)
+        << "-" << Sel.getName() << SourceRange(lbrac, rbrac);
   } else {
-    Diag(lbrac, diag::error_bad_receiver_type,
-         RExpr->getType().getAsString(), RExpr->getSourceRange());
+    Diag(lbrac, diag::error_bad_receiver_type)
+      << RExpr->getType().getAsString() << RExpr->getSourceRange();
     return true;
   }
   
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 98a32ef..dbd2126 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -1479,9 +1479,9 @@
     = TryObjectArgumentInitialization(From, Method);
   if (ICS.ConversionKind == ImplicitConversionSequence::BadConversion)
     return Diag(From->getSourceRange().getBegin(),
-                diag::err_implicit_object_parameter_init,
-                ImplicitParamType.getAsString(), From->getType().getAsString(),
-                From->getSourceRange());
+                diag::err_implicit_object_parameter_init)
+       << ImplicitParamType.getAsString() << From->getType().getAsString()
+       << From->getSourceRange();
 
   if (ICS.Standard.Second == ICK_Derived_To_Base &&
       CheckDerivedToBaseConversion(From->getType(), ImplicitParamType,
@@ -2597,8 +2597,8 @@
                                     Cand->Conversions.size(),
                                     false, 0);
 
-        Diag(SourceLocation(), diag::err_ovl_builtin_candidate,
-             FnType.getAsString());
+        Diag(SourceLocation(), diag::err_ovl_builtin_candidate)
+          << FnType.getAsString();
       }
     }
   }
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index e7ccdda..70231ec 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -105,13 +105,13 @@
     /// a context where the result is unused.  Emit a diagnostic to warn about
     /// this.
     if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E))
-      Diag(BO->getOperatorLoc(), diag::warn_unused_expr,
-           BO->getLHS()->getSourceRange(), BO->getRHS()->getSourceRange());
+      Diag(BO->getOperatorLoc(), diag::warn_unused_expr)
+        << BO->getLHS()->getSourceRange() << BO->getRHS()->getSourceRange();
     else if (const UnaryOperator *UO = dyn_cast<UnaryOperator>(E))
-      Diag(UO->getOperatorLoc(), diag::warn_unused_expr,
-           UO->getSubExpr()->getSourceRange());
+      Diag(UO->getOperatorLoc(), diag::warn_unused_expr)
+        << UO->getSubExpr()->getSourceRange();
     else 
-      Diag(E->getExprLoc(), diag::warn_unused_expr, E->getSourceRange());
+      Diag(E->getExprLoc(), diag::warn_unused_expr) << E->getSourceRange();
   }
   
   return new CompoundStmt(Elts, NumElts, L, R);
@@ -869,9 +869,9 @@
       
       // FIXME: We currently leak memory here.
       return Diag(InputExpr->getSubExpr()->getLocStart(),
-                  diag::err_asm_invalid_type_in_input,
-                  InputExpr->getType().getAsString(), InputConstraint,
-                  InputExpr->getSubExpr()->getSourceRange());
+                  diag::err_asm_invalid_type_in_input)
+        << InputExpr->getType().getAsString() << InputConstraint
+        << InputExpr->getSubExpr()->getSourceRange();
     }
   }