[cfe-commits] r59712 - in /cfe/trunk/lib/Sema: Sema.cpp Sema.h SemaChecking.cpp SemaDecl.cpp SemaDeclCXX.cpp SemaDeclObjC.cpp SemaExpr.cpp SemaExprCXX.cpp SemaNamedCast.cpp SemaStmt.cpp SemaType.cpp

Chris Lattner sabre at nondot.org
Wed Nov 19 22:06:08 PST 2008


Author: lattner
Date: Thu Nov 20 00:06:08 2008
New Revision: 59712

URL: http://llvm.org/viewvc/llvm-project?rev=59712&view=rev
Log:
remove another old-school Diag method.

Modified:
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaNamedCast.cpp
    cfe/trunk/lib/Sema/SemaStmt.cpp
    cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=59712&r1=59711&r2=59712&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Thu Nov 20 00:06:08 2008
@@ -173,12 +173,6 @@
   return true;
 }
 
-bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
-                const SourceRange& Range) {
-  PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << Msg << Range;
-  return true;
-}
-
 const LangOptions &Sema::getLangOptions() const {
   return PP.getLangOptions();
 }

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=59712&r1=59711&r2=59712&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Thu Nov 20 00:06:08 2008
@@ -232,10 +232,6 @@
   bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
             const std::string &Msg2);
 
-  /// More expressive diagnostic helpers for expressions (say that 6 times:-)
-  bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
-            const SourceRange& R1);
-  
   virtual void DeleteExpr(ExprTy *E);
   virtual void DeleteStmt(StmtTy *S);
 

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=59712&r1=59711&r2=59712&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Nov 20 00:06:08 2008
@@ -632,10 +632,10 @@
         SourceLocation Loc = PP.AdvanceToTokenCharacter(FExpr->getLocStart(),
                                                     LastConversionIdx+1);
     
-        Diag(Loc, diag::warn_printf_invalid_conversion, 
-          std::string(Str+LastConversionIdx, 
-          Str+std::min(LastConversionIdx+2, StrLen)),
-          OrigFormatExpr->getSourceRange());
+        Diag(Loc, diag::warn_printf_invalid_conversion)
+          <<  std::string(Str+LastConversionIdx,
+                          Str+std::min(LastConversionIdx+2, StrLen))
+          << OrigFormatExpr->getSourceRange();
       }
       ++numConversions;
       break;
@@ -653,9 +653,9 @@
         SourceLocation Loc = PP.AdvanceToTokenCharacter(FExpr->getLocStart(),
                                                         LastConversionIdx+1);
             
-        Diag(Loc, diag::warn_printf_invalid_conversion, 
-             std::string(Str+LastConversionIdx, Str+StrIdx),
-             OrigFormatExpr->getSourceRange());
+        Diag(Loc, diag::warn_printf_invalid_conversion)
+          << std::string(Str+LastConversionIdx, Str+StrIdx)
+          << OrigFormatExpr->getSourceRange();
              
         // This conversion is broken.  Advance to the next format
         // conversion.
@@ -676,10 +676,10 @@
     SourceLocation Loc = PP.AdvanceToTokenCharacter(FExpr->getLocStart(),
                                                     LastConversionIdx+1);
     
-    Diag(Loc, diag::warn_printf_invalid_conversion,
-         std::string(Str+LastConversionIdx,
-                     Str+std::min(LastConversionIdx+2, StrLen)),
-         OrigFormatExpr->getSourceRange());
+    Diag(Loc, diag::warn_printf_invalid_conversion)
+      << std::string(Str+LastConversionIdx,
+                     Str+std::min(LastConversionIdx+2, StrLen))
+      << OrigFormatExpr->getSourceRange();
     return;
   }
   

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=59712&r1=59711&r2=59712&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Nov 20 00:06:08 2008
@@ -841,16 +841,16 @@
     //
     if (PrevDecl == 0) {
       // No previous declaration in the qualifying scope.
-      Diag(D.getIdentifierLoc(), diag::err_typecheck_no_member,
-           Name.getAsString(), D.getCXXScopeSpec().getRange());
+      Diag(D.getIdentifierLoc(), diag::err_typecheck_no_member)
+        << Name.getAsString() << D.getCXXScopeSpec().getRange();
     } else if (!CurContext->Encloses(DC)) {
       // The qualifying scope doesn't enclose the original declaration.
       // Emit diagnostic based on current scope.
       SourceLocation L = D.getIdentifierLoc();
       SourceRange R = D.getCXXScopeSpec().getRange();
       if (isa<FunctionDecl>(CurContext)) {
-        Diag(L, diag::err_invalid_declarator_in_function, Name.getAsString(), 
-             R);
+        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;
@@ -1808,10 +1808,8 @@
     //   within its class declaration (9.2), and where the extern
     //   specifier is explicitly used.
     if (Type->isReferenceType() && Var->getStorageClass() != VarDecl::Extern) {
-      Diag(Var->getLocation(),
-           diag::err_reference_var_requires_init,
-           Var->getName(), 
-           SourceRange(Var->getLocation(), Var->getLocation()));
+      Diag(Var->getLocation(), diag::err_reference_var_requires_init)
+       << Var->getName() << SourceRange(Var->getLocation(), Var->getLocation());
       Var->setInvalidDecl();
       return;
     }

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=59712&r1=59711&r2=59712&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Nov 20 00:06:08 2008
@@ -576,15 +576,15 @@
 
       } else {
         // not const integral.
-        Diag(Loc, diag::err_member_initialization,
-             Name.getAsString(), Init->getSourceRange());
+        Diag(Loc, diag::err_member_initialization)
+          << Name.getAsString() << Init->getSourceRange();
         InvalidDecl = true;
       }
 
     } else {
       // not static member.
-      Diag(Loc, diag::err_member_initialization,
-           Name.getAsString(), Init->getSourceRange());
+      Diag(Loc, diag::err_member_initialization)
+        << Name.getAsString() << Init->getSourceRange();
       InvalidDecl = true;
     }
   }
@@ -1442,18 +1442,16 @@
     
   case OR_No_Viable_Function:
     if (CandidateSet.empty())
-      Diag(Loc, diag::err_ovl_no_viable_function_in_init, 
-           InitEntity, Range);
+      Diag(Loc, diag::err_ovl_no_viable_function_in_init) << InitEntity, Range;
     else {
-      Diag(Loc, diag::err_ovl_no_viable_function_in_init_with_cands, 
-           InitEntity, Range);
+      Diag(Loc, diag::err_ovl_no_viable_function_in_init_with_cands)
+        << InitEntity << Range;
       PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);
     }
     return 0;
     
   case OR_Ambiguous:
-    Diag(Loc, diag::err_ovl_ambiguous_init, 
-         InitEntity, Range);
+    Diag(Loc, diag::err_ovl_ambiguous_init) << InitEntity << Range;
     PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true);
     return 0;
   }
@@ -1848,8 +1846,8 @@
          Param != FnDecl->param_end(); ++Param) {
       if (Expr *DefArg = (*Param)->getDefaultArg())
         return Diag((*Param)->getLocation(),
-                    diag::err_operator_overload_default_arg,
-                    FnDecl->getName(), DefArg->getSourceRange());
+                    diag::err_operator_overload_default_arg)
+          << FnDecl->getName() << DefArg->getSourceRange();
     }
   }
 

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=59712&r1=59711&r2=59712&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Nov 20 00:06:08 2008
@@ -581,7 +581,7 @@
     Diag(ImpLoc, diag::warn_incomplete_impl);
     IncompleteImpl = true;
   }
-  Diag(ImpLoc, diag::warn_undef_method_impl, method->getSelector().getName());
+  Diag(ImpLoc, diag::warn_undef_method_impl) << method->getSelector().getName();
 }
 
 /// FIXME: Type hierarchies in Objective-C can be deep. We could most
@@ -824,7 +824,7 @@
         issueWarning = true;
   }
   if (issueWarning && (MethList.Method && MethList.Next)) {
-    Diag(R.getBegin(), diag::warn_multiple_method_decl, Sel.getName(), R);
+    Diag(R.getBegin(), diag::warn_multiple_method_decl) << Sel.getName() << R;
     Diag(MethList.Method->getLocStart(), diag::warn_using_decl)
       << MethList.Method->getSourceRange();
     for (ObjCMethodList *Next = MethList.Next; Next; Next = Next->Next)

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=59712&r1=59711&r2=59712&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Nov 20 00:06:08 2008
@@ -416,8 +416,8 @@
       // If this name wasn't predeclared and if this is not a function call,
       // diagnose the problem.
       if (SS && !SS->isEmpty())
-        return Diag(Loc, diag::err_typecheck_no_member,
-                    Name.getAsString(), SS->getRange());
+        return Diag(Loc, diag::err_typecheck_no_member)
+          << Name.getAsString() << SS->getRange();
       else if (Name.getNameKind() == DeclarationName::CXXOperatorName ||
                Name.getNameKind() == DeclarationName::CXXConversionFunctionName)
         return Diag(Loc, diag::err_undeclared_use) << Name.getAsString();
@@ -2598,9 +2598,9 @@
           Loc.isFileID() && UO->getOperatorLoc().isFileID() &&
           // Only if the two operators are exactly adjacent.
           Loc.getFileLocWithOffset(1) == UO->getOperatorLoc())
-        Diag(Loc, diag::warn_not_compound_assign,
-             UO->getOpcode() == UnaryOperator::Plus ? "+" : "-",
-             SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc()));
+        Diag(Loc, diag::warn_not_compound_assign)
+          << (UO->getOpcode() == UnaryOperator::Plus ? "+" : "-")
+          << SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
     }
   } else {
     // Compound assignment "x += y"
@@ -2776,23 +2776,23 @@
     }
   } else if (MemberExpr *MemExpr = dyn_cast<MemberExpr>(op)) { // C99 6.5.3.2p1
     if (MemExpr->getMemberDecl()->isBitField()) {
-      Diag(OpLoc, diag::err_typecheck_address_of, 
-           std::string("bit-field"), op->getSourceRange());
+      Diag(OpLoc, diag::err_typecheck_address_of)
+        << "bit-field" << op->getSourceRange();
       return QualType();
     }
   // Check for Apple extension for accessing vector components.
   } else if (isa<ArraySubscriptExpr>(op) &&
            cast<ArraySubscriptExpr>(op)->getBase()->getType()->isVectorType()) {
-    Diag(OpLoc, diag::err_typecheck_address_of, 
-         std::string("vector"), op->getSourceRange());
+    Diag(OpLoc, diag::err_typecheck_address_of)
+      << "vector" << op->getSourceRange();
     return QualType();
   } else if (dcl) { // C99 6.5.3.2p1
     // We have an lvalue with a decl. Make sure the decl is not declared 
     // with the register storage-class specifier.
     if (const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
       if (vd->getStorageClass() == VarDecl::Register) {
-        Diag(OpLoc, diag::err_typecheck_address_of, 
-             std::string("register variable"), op->getSourceRange());
+        Diag(OpLoc, diag::err_typecheck_address_of)
+          << "register variable" << op->getSourceRange();
         return QualType();
       }
     } else if (isa<OverloadedFunctionDecl>(dcl))
@@ -2817,8 +2817,8 @@
     // and such a warning is unlikely to catch any mistakes.
     return PT->getPointeeType();
   }
-  Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer, 
-       qType.getAsString(), op->getSourceRange());
+  Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
+    << qType.getAsString() << op->getSourceRange();
   return QualType();
 }
 
@@ -3223,27 +3223,27 @@
              resultType->isPointerType())
       break;
 
-    return Diag(OpLoc, diag::err_typecheck_unary_expr, 
-                resultType.getAsString());
+    return Diag(OpLoc, diag::err_typecheck_unary_expr)
+          << resultType.getAsString();
   case UnaryOperator::Not: // bitwise complement
     UsualUnaryConversions(Input);
     resultType = Input->getType();
     // C99 6.5.3.3p1. We allow complex int and float as a GCC extension.
     if (resultType->isComplexType() || resultType->isComplexIntegerType())
       // C99 does not support '~' for complex conjugation.
-      Diag(OpLoc, diag::ext_integer_complement_complex,
-           resultType.getAsString(), Input->getSourceRange());
+      Diag(OpLoc, diag::ext_integer_complement_complex)
+        << resultType.getAsString() << Input->getSourceRange();
     else if (!resultType->isIntegerType())
-      return Diag(OpLoc, diag::err_typecheck_unary_expr,
-                  resultType.getAsString(), Input->getSourceRange());
+      return Diag(OpLoc, diag::err_typecheck_unary_expr)
+        << resultType.getAsString() << Input->getSourceRange();
     break;
   case UnaryOperator::LNot: // logical negation
     // Unlike +/-/~, integer promotions aren't done here (C99 6.5.3.3p5).
     DefaultFunctionArrayConversion(Input);
     resultType = Input->getType();
     if (!resultType->isScalarType()) // C99 6.5.3.3p1
-      return Diag(OpLoc, diag::err_typecheck_unary_expr,
-                  resultType.getAsString());
+      return Diag(OpLoc, diag::err_typecheck_unary_expr)
+        << resultType.getAsString();
     // LNot always has type int. C99 6.5.3.3p5.
     resultType = Context.IntTy;
     break;
@@ -3320,7 +3320,7 @@
   // one is known to be a field designator.  Verify that the ArgTy represents
   // a struct/union/class.
   if (!ArgTy->isRecordType())
-    return Diag(TypeLoc, diag::err_offsetof_record_type,ArgTy.getAsString());
+    return Diag(TypeLoc, diag::err_offsetof_record_type) << ArgTy.getAsString();
   
   // Otherwise, create a compound literal expression as the base, and
   // iteratively process the offsetof designators.
@@ -3339,8 +3339,8 @@
       const ArrayType *AT = Context.getAsArrayType(Res->getType());
       if (!AT) {
         delete Res;
-        return Diag(OC.LocEnd, diag::err_offsetof_array_type,
-                    Res->getType().getAsString());
+        return Diag(OC.LocEnd, diag::err_offsetof_array_type)
+          << Res->getType().getAsString();
       }
       
       // FIXME: C++: Verify that operator[] isn't overloaded.
@@ -3358,8 +3358,8 @@
     const RecordType *RC = Res->getType()->getAsRecordType();
     if (!RC) {
       delete Res;
-      return Diag(OC.LocEnd, diag::err_offsetof_record_type,
-                  Res->getType().getAsString());
+      return Diag(OC.LocEnd, diag::err_offsetof_record_type)
+        << Res->getType().getAsString();
     }
       
     // Get the decl corresponding to this.
@@ -3604,8 +3604,8 @@
     typeNames += Args[i+1]->getType().getAsString();
   }
 
-  return Diag(BuiltinLoc, diag::err_overload_no_match, typeNames,
-              SourceRange(BuiltinLoc, RParenLoc));
+  return Diag(BuiltinLoc, diag::err_overload_no_match)
+    << typeNames << SourceRange(BuiltinLoc, RParenLoc);
 }
 
 Sema::ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
@@ -3628,9 +3628,8 @@
 
   if (CheckAssignmentConstraints(VaListType, E->getType()) != Compatible)
     return Diag(E->getLocStart(),
-                diag::err_first_argument_to_va_arg_not_of_type_va_list,
-                E->getType().getAsString(),
-                E->getSourceRange());
+                diag::err_first_argument_to_va_arg_not_of_type_va_list)
+      << E->getType().getAsString() << E->getSourceRange();
   
   // FIXME: Warn if a non-POD type is passed in.
   

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=59712&r1=59711&r2=59712&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Nov 20 00:06:08 2008
@@ -125,8 +125,8 @@
     // be complete.
     //
     if (!RT->getDecl()->isDefinition())
-      return Diag(TyBeginLoc, diag::err_invalid_incomplete_type_use,
-                  Ty.getAsString(), FullRange);
+      return Diag(TyBeginLoc, diag::err_invalid_incomplete_type_use)
+        << Ty.getAsString() << FullRange;
 
     unsigned DiagID = PP.getDiagnostics().getCustomDiagID(Diagnostic::Error,
                                     "class constructors are not supported yet");
@@ -233,8 +233,8 @@
   AssignConvertType
     ConvTy = CheckSingleAssignmentConstraints(Context.BoolTy, CondExpr);
   if (ConvTy == Incompatible)
-    return Diag(CondExpr->getLocStart(), diag::err_typecheck_bool_condition,
-                Ty.getAsString(), CondExpr->getSourceRange());
+    return Diag(CondExpr->getLocStart(), diag::err_typecheck_bool_condition)
+      << Ty.getAsString() << CondExpr->getSourceRange();
   return false;
 }
 

Modified: cfe/trunk/lib/Sema/SemaNamedCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaNamedCast.cpp?rev=59712&r1=59711&r2=59712&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaNamedCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaNamedCast.cpp Thu Nov 20 00:06:08 2008
@@ -730,9 +730,9 @@
       return;
     }
   } else {
-    Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class,
-      SrcPointee.getUnqualifiedType().getAsString(),
-      SrcExpr->getSourceRange());
+    Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class)
+      << SrcPointee.getUnqualifiedType().getAsString()
+      << SrcExpr->getSourceRange();
     return;
   }
 
@@ -769,8 +769,9 @@
   const RecordDecl *SrcDecl = SrcRecord->getDecl()->getDefinition(Self.Context);
   assert(SrcDecl && "Definition missing");
   if (!cast<CXXRecordDecl>(SrcDecl)->isPolymorphic()) {
-    Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_polymorphic,
-      SrcPointee.getUnqualifiedType().getAsString(), SrcExpr->getSourceRange());
+    Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_polymorphic)
+      << SrcPointee.getUnqualifiedType().getAsString()
+      << SrcExpr->getSourceRange();
   }
 
   // Done. Everything else is run-time checks.

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=59712&r1=59711&r2=59712&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Nov 20 00:06:08 2008
@@ -210,8 +210,8 @@
     if (CheckCXXBooleanCondition(condExpr)) // C++ 6.4p4
       return true;
   } else if (!condType->isScalarType()) // C99 6.8.4.1p1
-    return Diag(IfLoc, diag::err_typecheck_statement_requires_scalar,
-             condType.getAsString(), condExpr->getSourceRange());
+    return Diag(IfLoc, diag::err_typecheck_statement_requires_scalar)
+      << condType.getAsString() << condExpr->getSourceRange();
 
   // Warn if the if block has a null body without an else value.
   // this helps prevent bugs due to typos, such as
@@ -275,7 +275,7 @@
     // If the input was signed and negative and the output is unsigned,
     // warn.
     if (!NewSign && OldVal.isSigned() && OldVal.isNegative())
-      Diag(Loc, DiagID, OldVal.toString(10), Val.toString(10));
+      Diag(Loc, DiagID) << OldVal.toString(10) << Val.toString(10);
     
     Val.setIsSigned(NewSign);
   } else if (NewWidth < Val.getBitWidth()) {
@@ -286,7 +286,7 @@
     ConvVal.extend(Val.getBitWidth());
     ConvVal.setIsSigned(Val.isSigned());
     if (ConvVal != Val)
-      Diag(Loc, DiagID, Val.toString(10), ConvVal.toString(10));
+      Diag(Loc, DiagID) << Val.toString(10) << ConvVal.toString(10);
     
     // Regardless of whether a diagnostic was emitted, really do the
     // truncation.
@@ -299,7 +299,7 @@
     Val.setIsSigned(NewSign);
     
     if (Val.isNegative())  // Sign bit changes meaning.
-      Diag(Loc, DiagID, OldVal.toString(10), Val.toString(10));
+      Diag(Loc, DiagID) << OldVal.toString(10) << Val.toString(10);
   }
 }
 
@@ -349,8 +349,8 @@
   QualType CondType = CondExpr->getType();
   
   if (!CondType->isIntegerType()) { // C99 6.8.4.2p1
-    Diag(SwitchLoc, diag::err_typecheck_statement_requires_integer,
-         CondType.getAsString(), CondExpr->getSourceRange());
+    Diag(SwitchLoc, diag::err_typecheck_statement_requires_integer)
+      << CondType.getAsString() << CondExpr->getSourceRange();
     return true;
   }
   
@@ -422,7 +422,7 @@
       if (CaseVals[i].first == CaseVals[i+1].first) {
         // If we have a duplicate, report it.
         Diag(CaseVals[i+1].second->getLHS()->getLocStart(),
-             diag::err_duplicate_case, CaseVals[i].first.toString(10));
+             diag::err_duplicate_case) << CaseVals[i].first.toString(10);
         Diag(CaseVals[i].second->getLHS()->getLocStart(), 
              diag::err_duplicate_case_prev);
         // FIXME: We really want to remove the bogus case stmt from the substmt,
@@ -505,8 +505,8 @@
       
       if (OverlapStmt) {
         // If we have a duplicate, report it.
-        Diag(CR->getLHS()->getLocStart(),
-             diag::err_duplicate_case, OverlapVal.toString(10));
+        Diag(CR->getLHS()->getLocStart(), diag::err_duplicate_case)
+          << OverlapVal.toString(10);
         Diag(OverlapStmt->getLHS()->getLocStart(), 
              diag::err_duplicate_case_prev);
         // FIXME: We really want to remove the bogus case stmt from the substmt,
@@ -536,8 +536,8 @@
     if (CheckCXXBooleanCondition(condExpr)) // C++ 6.4p4
       return true;
   } else if (!condType->isScalarType()) // C99 6.8.5p2
-    return Diag(WhileLoc, diag::err_typecheck_statement_requires_scalar,
-             condType.getAsString(), condExpr->getSourceRange());
+    return Diag(WhileLoc, diag::err_typecheck_statement_requires_scalar)
+      << condType.getAsString() << condExpr->getSourceRange();
 
   return new WhileStmt(condExpr, (Stmt*)Body, WhileLoc);
 }
@@ -555,8 +555,8 @@
     if (CheckCXXBooleanCondition(condExpr)) // C++ 6.4p4
       return true;
   } else if (!condType->isScalarType()) // C99 6.8.5p2
-    return Diag(DoLoc, diag::err_typecheck_statement_requires_scalar,
-             condType.getAsString(), condExpr->getSourceRange());
+    return Diag(DoLoc, diag::err_typecheck_statement_requires_scalar)
+      << condType.getAsString() << condExpr->getSourceRange();
 
   return new DoStmt((Stmt*)Body, condExpr, DoLoc);
 }
@@ -593,8 +593,8 @@
       if (CheckCXXBooleanCondition(Second)) // C++ 6.4p4
         return true;
     } else if (!SecondType->isScalarType()) // C99 6.8.5p2
-      return Diag(ForLoc, diag::err_typecheck_statement_requires_scalar,
-                  SecondType.getAsString(), Second->getSourceRange());
+      return Diag(ForLoc, diag::err_typecheck_statement_requires_scalar)
+        << SecondType.getAsString() << Second->getSourceRange();
   }
   return new ForStmt(First, Second, Third, Body, ForLoc);
 }

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=59712&r1=59711&r2=59712&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 20 00:06:08 2008
@@ -203,14 +203,14 @@
         // incomplete type.
         if (!EltTy->isIncompleteOrObjectType()) {
           Diag(DS.getRestrictSpecLoc(),
-               diag::err_typecheck_invalid_restrict_invalid_pointee,
-               EltTy.getAsString(), DS.getSourceRange());
+               diag::err_typecheck_invalid_restrict_invalid_pointee)
+            << EltTy.getAsString() << DS.getSourceRange();
           TypeQuals &= ~QualType::Restrict; // Remove the restrict qualifier.
         }
       } else {
         Diag(DS.getRestrictSpecLoc(),
-             diag::err_typecheck_invalid_restrict_not_pointer,
-             Result.getAsString(), DS.getSourceRange());
+             diag::err_typecheck_invalid_restrict_not_pointer)
+          << Result.getAsString() << DS.getSourceRange();
         TypeQuals &= ~QualType::Restrict; // Remove the restrict qualifier.
       }
     }
@@ -228,8 +228,8 @@
                "Has CV quals but not C or V?");
         Loc = DS.getVolatileSpecLoc();
       }
-      Diag(Loc, diag::warn_typecheck_function_qualifiers,
-           Result.getAsString(), DS.getSourceRange());
+      Diag(Loc, diag::warn_typecheck_function_qualifiers)
+        << Result.getAsString() << DS.getSourceRange();
     }
     
     // C++ [dcl.ref]p1:
@@ -275,8 +275,8 @@
     case DeclaratorChunk::Pointer:
       if (T->isReferenceType()) {
         // C++ 8.3.2p4: There shall be no ... pointers to references ...
-        Diag(DeclType.Loc, diag::err_illegal_decl_pointer_to_reference,
-             D.getIdentifier() ? D.getIdentifier()->getName() : "type name");
+        Diag(DeclType.Loc, diag::err_illegal_decl_pointer_to_reference)
+         << (D.getIdentifier() ? D.getIdentifier()->getName() : "type name");
         D.setInvalidType(true);
         T = Context.IntTy;
       }
@@ -285,9 +285,8 @@
       // object or incomplete types shall not be restrict-qualified."
       if ((DeclType.Ptr.TypeQuals & QualType::Restrict) &&
           !T->isIncompleteOrObjectType()) {
-        Diag(DeclType.Loc,
-             diag::err_typecheck_invalid_restrict_invalid_pointee,
-             T.getAsString());
+        Diag(DeclType.Loc, diag::err_typecheck_invalid_restrict_invalid_pointee)
+          << T.getAsString();
         DeclType.Ptr.TypeQuals &= QualType::Restrict;
       }        
         
@@ -327,9 +326,8 @@
       // object or incomplete types shall not be restrict-qualified."
       if (DeclType.Ref.HasRestrict &&
           !T->isIncompleteOrObjectType()) {
-        Diag(DeclType.Loc,
-             diag::err_typecheck_invalid_restrict_invalid_pointee,
-             T.getAsString());
+        Diag(DeclType.Loc, diag::err_typecheck_invalid_restrict_invalid_pointee)
+          << T.getAsString();
         DeclType.Ref.HasRestrict = false;
       }        
 
@@ -355,39 +353,39 @@
       // C99 6.7.5.2p1: If the element type is an incomplete or function type, 
       // reject it (e.g. void ary[7], struct foo ary[7], void ary[7]())
       if (T->isIncompleteType()) { 
-        Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_incomplete_type,
-             T.getAsString());
+        Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_incomplete_type)
+          << T.getAsString();
         T = Context.IntTy;
         D.setInvalidType(true);
       } else if (T->isFunctionType()) {
-        Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_functions,
-             D.getIdentifier() ? D.getIdentifier()->getName() : "type name");
+        Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_functions)
+          << (D.getIdentifier() ? D.getIdentifier()->getName() : "type name");
         T = Context.getPointerType(T);
         D.setInvalidType(true);
       } else if (const ReferenceType *RT = T->getAsReferenceType()) {
         // C++ 8.3.2p4: There shall be no ... arrays of references ...
-        Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_references,
-             D.getIdentifier() ? D.getIdentifier()->getName() : "type name");
+        Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_references)
+          << (D.getIdentifier() ? D.getIdentifier()->getName() : "type name");
         T = RT->getPointeeType();
         D.setInvalidType(true);
       } else if (const RecordType *EltTy = T->getAsRecordType()) {
         // If the element type is a struct or union that contains a variadic
         // array, reject it: C99 6.7.2.1p2.
         if (EltTy->getDecl()->hasFlexibleArrayMember()) {
-          Diag(DeclType.Loc, diag::err_flexible_array_in_array,
-               T.getAsString());
+          Diag(DeclType.Loc, diag::err_flexible_array_in_array)
+            << T.getAsString();
           T = Context.IntTy;
           D.setInvalidType(true);
         }
       } else if (T->isObjCInterfaceType()) {
-        Diag(DeclType.Loc, diag::warn_objc_array_of_interfaces,
-             T.getAsString());
+        Diag(DeclType.Loc, diag::warn_objc_array_of_interfaces)
+        << T.getAsString();
       }
       
       // C99 6.7.5.2p1: The size expression shall have integer type.
       if (ArraySize && !ArraySize->getType()->isIntegerType()) {
-        Diag(ArraySize->getLocStart(), diag::err_array_size_non_int, 
-             ArraySize->getType().getAsString(), ArraySize->getSourceRange());
+        Diag(ArraySize->getLocStart(), diag::err_array_size_non_int)
+          << ArraySize->getType().getAsString() << ArraySize->getSourceRange();
         D.setInvalidType(true);
         delete ArraySize;
         ATI.NumElts = ArraySize = 0;





More information about the cfe-commits mailing list