[cfe-commits] r59561 - in /cfe/trunk/lib/Sema: Sema.cpp Sema.h SemaDecl.cpp SemaDeclCXX.cpp SemaDeclObjC.cpp SemaExpr.cpp SemaInherit.cpp SemaNamedCast.cpp SemaOverload.cpp

Chris Lattner sabre at nondot.org
Tue Nov 18 14:52:51 PST 2008


Author: lattner
Date: Tue Nov 18 16:52:51 2008
New Revision: 59561

URL: http://llvm.org/viewvc/llvm-project?rev=59561&view=rev
Log:
start converting Sema over to using its canonical Diag method.

Modified:
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/Sema.h
    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/SemaInherit.cpp
    cfe/trunk/lib/Sema/SemaNamedCast.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Nov 18 16:52:51 2008
@@ -200,15 +200,6 @@
   PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << Msg1 << Msg2 << R;
   return true;
 }
-
-bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, 
-                const std::string &Msg2, const std::string &Msg3, 
-                const SourceRange &R1) {
-  PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID)
-    << Msg1 << Msg2 << Msg3 << R1;
-  return true;
-}
-
 bool Sema::Diag(SourceLocation Loc, unsigned DiagID,
                 const SourceRange& R1, const SourceRange& R2) {
   PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << R1 << R2;
@@ -221,14 +212,6 @@
   return true;
 }
 
-bool Sema::Diag(SourceLocation Range, unsigned DiagID, const std::string &Msg1,
-                const std::string &Msg2, const SourceRange& R1,
-                const SourceRange& R2) {
-  PP.getDiagnostics().Report(PP.getFullLoc(Range),DiagID)
-    << Msg1 << Msg2 << R1 << R2;
-  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=59561&r1=59560&r2=59561&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Nov 18 16:52:51 2008
@@ -253,12 +253,6 @@
             const SourceRange& R1, const SourceRange& R2);
   bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, 
             const std::string &Msg2, const SourceRange& R1);
-  bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, 
-            const std::string &Msg2, const std::string &Msg3,
-            const SourceRange& R1);
-  bool Diag(SourceLocation Loc, unsigned DiagID, 
-            const std::string &Msg1, const std::string &Msg2, 
-            const SourceRange& R1, const SourceRange& R2);
   
   virtual void DeleteExpr(ExprTy *E);
   virtual void DeleteStmt(StmtTy *S);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Nov 18 16:52:51 2008
@@ -714,14 +714,12 @@
       //      destination type.
       // FIXME: We're pretending to do copy elision here; return to
       // this when we have ASTs for such things.
-      if (PerformImplicitConversion(Init, DeclType))
-        return Diag(InitLoc,
-                    diag::err_typecheck_convert_incompatible,
-                    DeclType.getAsString(), InitEntity,
-                    "initializing",
-                    Init->getSourceRange());
-      else
+      if (!PerformImplicitConversion(Init, DeclType))
         return false;
+      
+      return Diag(InitLoc, diag::err_typecheck_convert_incompatible)
+        << DeclType.getAsString() << InitEntity << "initializing"
+        << Init->getSourceRange();
     }
 
     // C99 6.7.8p16.

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Nov 18 16:52:51 2008
@@ -1735,10 +1735,10 @@
   if (T1.getCVRQualifiers() != QualType::Const) {
     if (!ICS)
       Diag(Init->getSourceRange().getBegin(),
-           diag::err_not_reference_to_const_init,
-           T1.getAsString(), 
-           InitLvalue != Expr::LV_Valid? "temporary" : "value",
-           T2.getAsString(), Init->getSourceRange());
+           diag::err_not_reference_to_const_init)
+        <<  T1.getAsString()
+        << (InitLvalue != Expr::LV_Valid? "temporary" : "value")
+        <<  T2.getAsString() << Init->getSourceRange();
     return true;
   }
 
@@ -1799,10 +1799,10 @@
     // initialization fails.
     if (!ICS)
       Diag(Init->getSourceRange().getBegin(),
-           diag::err_reference_init_drops_quals,
-           T1.getAsString(), 
-           InitLvalue != Expr::LV_Valid? "temporary" : "value",
-           T2.getAsString(), Init->getSourceRange());
+           diag::err_reference_init_drops_quals)
+        << T1.getAsString()
+        << (InitLvalue != Expr::LV_Valid? "temporary" : "value")
+        << T2.getAsString() << Init->getSourceRange();
     return true;
   }
 

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Nov 18 16:52:51 2008
@@ -256,34 +256,28 @@
                Property->getName(), inheritedName);
   if ((CAttr & ObjCPropertyDecl::OBJC_PR_copy)
       != (SAttr & ObjCPropertyDecl::OBJC_PR_copy))
-    Diag(Property->getLocation(), diag::warn_property_attribute,
-         Property->getName(), "copy", inheritedName, 
-         SourceRange());
+    Diag(Property->getLocation(), diag::warn_property_attribute)
+      << Property->getName() << "copy" << inheritedName;
   else if ((CAttr & ObjCPropertyDecl::OBJC_PR_retain)
            != (SAttr & ObjCPropertyDecl::OBJC_PR_retain))
-    Diag(Property->getLocation(), diag::warn_property_attribute,
-         Property->getName(), "retain", inheritedName, 
-         SourceRange());
+    Diag(Property->getLocation(), diag::warn_property_attribute)
+      << Property->getName() << "retain" << inheritedName;
   
   if ((CAttr & ObjCPropertyDecl::OBJC_PR_nonatomic)
       != (SAttr & ObjCPropertyDecl::OBJC_PR_nonatomic))
-    Diag(Property->getLocation(), diag::warn_property_attribute,
-         Property->getName(), "atomic", inheritedName, 
-         SourceRange());
+    Diag(Property->getLocation(), diag::warn_property_attribute)
+      << Property->getName() << "atomic" << inheritedName;
   if (Property->getSetterName() != SuperProperty->getSetterName())
-    Diag(Property->getLocation(), diag::warn_property_attribute,
-         Property->getName(), "setter", inheritedName, 
-         SourceRange());
+    Diag(Property->getLocation(), diag::warn_property_attribute)
+      << Property->getName() << "setter" << inheritedName; 
   if (Property->getGetterName() != SuperProperty->getGetterName())
-    Diag(Property->getLocation(), diag::warn_property_attribute,
-         Property->getName(), "getter", inheritedName, 
-         SourceRange());
+    Diag(Property->getLocation(), diag::warn_property_attribute)
+      << Property->getName() << "getter" << inheritedName;
   
   if (Context.getCanonicalType(Property->getType()) != 
           Context.getCanonicalType(SuperProperty->getType()))
-    Diag(Property->getLocation(), diag::warn_property_type,
-         Property->getType().getAsString(),  
-         inheritedName);
+    Diag(Property->getLocation(), diag::warn_property_type)
+      << Property->getType().getAsString() << inheritedName;
   
 }
 

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Nov 18 16:52:51 2008
@@ -1521,9 +1521,9 @@
         }
       } else if (!Context.typesAreCompatible(lhptee.getUnqualifiedType(), 
                                              rhptee.getUnqualifiedType())) {
-        Diag(questionLoc, diag::warn_typecheck_cond_incompatible_pointers,
-             lexT.getAsString(), rexT.getAsString(),
-             lex->getSourceRange(), rex->getSourceRange());
+        Diag(questionLoc, diag::warn_typecheck_cond_incompatible_pointers)
+          << lexT.getAsString() << rexT.getAsString()
+          << lex->getSourceRange() << rex->getSourceRange();
         // In this situation, we assume void* type. No especially good
         // reason, but this is what gcc does, and we do have to pick
         // to get a consistent AST.
@@ -1575,9 +1575,9 @@
     return lexT;
 
   // Otherwise, the operands are not compatible.
-  Diag(questionLoc, diag::err_typecheck_cond_incompatible_operands,
-       lexT.getAsString(), rexT.getAsString(),
-       lex->getSourceRange(), rex->getSourceRange());
+  Diag(questionLoc, diag::err_typecheck_cond_incompatible_operands)
+    << lexT.getAsString() << rexT.getAsString()
+    << lex->getSourceRange() << rex->getSourceRange();
   return QualType();
 }
 
@@ -1892,9 +1892,9 @@
 }
 
 QualType Sema::InvalidOperands(SourceLocation Loc, Expr *&lex, Expr *&rex) {
-  Diag(Loc, diag::err_typecheck_invalid_operands, 
-       lex->getType().getAsString(), rex->getType().getAsString(),
-       lex->getSourceRange(), rex->getSourceRange());
+  Diag(Loc, diag::err_typecheck_invalid_operands)
+    << lex->getType().getAsString() << rex->getType().getAsString()
+    << lex->getSourceRange() << rex->getSourceRange();
   return QualType();
 }
 
@@ -1947,9 +1947,9 @@
   }
 
   // You cannot convert between vector values of different size.
-  Diag(Loc, diag::err_typecheck_vector_not_convertable, 
-       lex->getType().getAsString(), rex->getType().getAsString(),
-       lex->getSourceRange(), rex->getSourceRange());
+  Diag(Loc, diag::err_typecheck_vector_not_convertable)
+    << lex->getType().getAsString() << rex->getType().getAsString()
+    << lex->getSourceRange() << rex->getSourceRange();
   return QualType();
 }    
 
@@ -2074,9 +2074,9 @@
       if (!Context.typesAreCompatible(
               Context.getCanonicalType(lpointee).getUnqualifiedType(), 
               Context.getCanonicalType(rpointee).getUnqualifiedType())) {
-        Diag(Loc, diag::err_typecheck_sub_ptr_compatible,
-             lex->getType().getAsString(), rex->getType().getAsString(),
-             lex->getSourceRange(), rex->getSourceRange());
+        Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
+          << lex->getType().getAsString() << rex->getType().getAsString()
+          << lex->getSourceRange() << rex->getSourceRange();
         return QualType();
       }
       
@@ -2176,9 +2176,9 @@
         !Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
                                     RCanPointeeTy.getUnqualifiedType()) &&
         !areComparableObjCInterfaces(LCanPointeeTy, RCanPointeeTy, Context)) {
-      Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers,
-           lType.getAsString(), rType.getAsString(),
-           lex->getSourceRange(), rex->getSourceRange());
+      Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers)
+        << lType.getAsString() << rType.getAsString()
+        << lex->getSourceRange() << rex->getSourceRange();
     }
     ImpCastExprToType(rex, lType); // promote the pointer to pointer
     return Context.IntTy;
@@ -2190,9 +2190,9 @@
     
     if (!LHSIsNull && !RHSIsNull &&
         !Context.typesAreBlockCompatible(lpointee, rpointee)) {
-      Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks,
-           lType.getAsString(), rType.getAsString(),
-           lex->getSourceRange(), rex->getSourceRange());
+      Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
+        << lType.getAsString() << rType.getAsString()
+        << lex->getSourceRange() << rex->getSourceRange();
     }
     ImpCastExprToType(rex, lType); // promote the pointer to pointer
     return Context.IntTy;
@@ -2201,9 +2201,9 @@
   if ((lType->isBlockPointerType() && rType->isPointerType()) ||
       (lType->isPointerType() && rType->isBlockPointerType())) {
     if (!LHSIsNull && !RHSIsNull) {
-      Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks,
-           lType.getAsString(), rType.getAsString(),
-           lex->getSourceRange(), rex->getSourceRange());
+      Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
+        << lType.getAsString() << rType.getAsString()
+        << lex->getSourceRange() << rex->getSourceRange();
     }
     ImpCastExprToType(rex, lType); // promote the pointer to pointer
     return Context.IntTy;
@@ -2220,9 +2220,9 @@
         
       if (!LPtrToVoid && !RPtrToVoid &&
           !Context.typesAreCompatible(lType, rType)) {
-        Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers,
-             lType.getAsString(), rType.getAsString(),
-             lex->getSourceRange(), rex->getSourceRange());
+        Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers)
+          << lType.getAsString() << rType.getAsString()
+          << lex->getSourceRange() << rex->getSourceRange();
         ImpCastExprToType(rex, lType);
         return Context.IntTy;
       }
@@ -2234,9 +2234,9 @@
       return Context.IntTy;
     } else {
       if ((lType->isObjCQualifiedIdType() && rType->isObjCQualifiedIdType())) {
-        Diag(Loc, diag::warn_incompatible_qualified_id_operands, 
-             lType.getAsString(), rType.getAsString(),
-             lex->getSourceRange(), rex->getSourceRange());
+        Diag(Loc, diag::warn_incompatible_qualified_id_operands)
+          << lType.getAsString() << rType.getAsString()
+          << lex->getSourceRange() << rex->getSourceRange();
         ImpCastExprToType(rex, lType);
         return Context.IntTy;
       }
@@ -2245,35 +2245,35 @@
   if ((lType->isPointerType() || lType->isObjCQualifiedIdType()) && 
        rType->isIntegerType()) {
     if (!RHSIsNull)
-      Diag(Loc, diag::ext_typecheck_comparison_of_pointer_integer,
-           lType.getAsString(), rType.getAsString(),
-           lex->getSourceRange(), rex->getSourceRange());
+      Diag(Loc, diag::ext_typecheck_comparison_of_pointer_integer)
+        << lType.getAsString() << rType.getAsString()
+        << lex->getSourceRange() << rex->getSourceRange();
     ImpCastExprToType(rex, lType); // promote the integer to pointer
     return Context.IntTy;
   }
   if (lType->isIntegerType() && 
       (rType->isPointerType() || rType->isObjCQualifiedIdType())) {
     if (!LHSIsNull)
-      Diag(Loc, diag::ext_typecheck_comparison_of_pointer_integer,
-           lType.getAsString(), rType.getAsString(),
-           lex->getSourceRange(), rex->getSourceRange());
+      Diag(Loc, diag::ext_typecheck_comparison_of_pointer_integer)
+        << lType.getAsString() << rType.getAsString()
+        << lex->getSourceRange() << rex->getSourceRange();
     ImpCastExprToType(lex, rType); // promote the integer to pointer
     return Context.IntTy;
   }
   // Handle block pointers.
   if (lType->isBlockPointerType() && rType->isIntegerType()) {
     if (!RHSIsNull)
-      Diag(Loc, diag::ext_typecheck_comparison_of_pointer_integer,
-           lType.getAsString(), rType.getAsString(),
-           lex->getSourceRange(), rex->getSourceRange());
+      Diag(Loc, diag::ext_typecheck_comparison_of_pointer_integer)
+        << lType.getAsString() << rType.getAsString()
+        << lex->getSourceRange() << rex->getSourceRange();
     ImpCastExprToType(rex, lType); // promote the integer to pointer
     return Context.IntTy;
   }
   if (lType->isIntegerType() && rType->isBlockPointerType()) {
     if (!LHSIsNull)
-      Diag(Loc, diag::ext_typecheck_comparison_of_pointer_integer,
-           lType.getAsString(), rType.getAsString(),
-           lex->getSourceRange(), rex->getSourceRange());
+      Diag(Loc, diag::ext_typecheck_comparison_of_pointer_integer)
+        << lType.getAsString() << rType.getAsString()
+        << lex->getSourceRange() << rex->getSourceRange();
     ImpCastExprToType(lex, rType); // promote the integer to pointer
     return Context.IntTy;
   }
@@ -3445,7 +3445,7 @@
     break;
   }
   
-  Diag(Loc, DiagKind, DstType.getAsString(), SrcType.getAsString(), Flavor,
-       SrcExpr->getSourceRange());
+  Diag(Loc, DiagKind) << DstType.getAsString() << SrcType.getAsString()
+    << Flavor << SrcExpr->getSourceRange();
   return isInvalid;
 }

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaInherit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInherit.cpp Tue Nov 18 16:52:51 2008
@@ -204,8 +204,8 @@
     }
   }
   
-  Diag(Loc, diag::err_ambiguous_derived_to_base_conv,
-       Derived.getAsString(), Base.getAsString(), PathDisplayStr, Range);
+  Diag(Loc, diag::err_ambiguous_derived_to_base_conv)
+    << Derived.getAsString() << Base.getAsString() << PathDisplayStr << Range;
   return true;
 }
 

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaNamedCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaNamedCast.cpp Tue Nov 18 16:52:51 2008
@@ -108,8 +108,9 @@
   if (const ReferenceType *DestTypeTmp = DestType->getAsReferenceType()) {
     if (SrcExpr->isLvalue(Self.Context) != Expr::LV_Valid) {
       // Cannot cast non-lvalue to reference type.
-      Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue,
-        "const_cast", OrigDestType.getAsString(), SrcExpr->getSourceRange());
+      Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue)
+        << "const_cast" << OrigDestType.getAsString()
+        << SrcExpr->getSourceRange();
       return;
     }
 
@@ -129,16 +130,16 @@
     // Cannot cast to non-pointer, non-reference type. Note that, if DestType
     // was a reference type, we converted it to a pointer above.
     // C++ 5.2.11p3: For two pointer types [...]
-    Self.Diag(OpRange.getBegin(), diag::err_bad_const_cast_dest,
-      OrigDestType.getAsString(), DestRange);
+    Self.Diag(OpRange.getBegin(), diag::err_bad_const_cast_dest)
+      << OrigDestType.getAsString() << DestRange;
     return;
   }
   if (DestType->isFunctionPointerType()) {
     // Cannot cast direct function pointers.
     // C++ 5.2.11p2: [...] where T is any object type or the void type [...]
     // T is the ultimate pointee of source and target type.
-    Self.Diag(OpRange.getBegin(), diag::err_bad_const_cast_dest,
-      OrigDestType.getAsString(), DestRange);
+    Self.Diag(OpRange.getBegin(), diag::err_bad_const_cast_dest)
+      << OrigDestType.getAsString() << DestRange;
     return;
   }
   SrcType = Self.Context.getCanonicalType(SrcType);
@@ -169,9 +170,9 @@
   {
     if (SrcTypeArr->getSize() != DestTypeArr->getSize()) {
       // Different array sizes.
-      Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic,
-        "const_cast", OrigDestType.getAsString(), OrigSrcType.getAsString(),
-        OpRange);
+      Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic)
+        << "const_cast" << OrigDestType.getAsString()
+        << OrigSrcType.getAsString() << OpRange;
       return;
     }
     SrcType = SrcTypeArr->getElementType().getUnqualifiedType();
@@ -182,8 +183,9 @@
   // Since we're dealing in canonical types, the remainder must be the same.
   if (SrcType != DestType) {
     // Cast between unrelated types.
-    Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic, "const_cast",
-      OrigDestType.getAsString(), OrigSrcType.getAsString(), OpRange);
+    Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic)
+      << "const_cast" << OrigDestType.getAsString()
+      << OrigSrcType.getAsString() << OpRange;
     return;
   }
 }
@@ -204,9 +206,9 @@
   if (const ReferenceType *DestTypeTmp = DestType->getAsReferenceType()) {
     if (SrcExpr->isLvalue(Self.Context) != Expr::LV_Valid) {
       // Cannot cast non-lvalue to reference type.
-      Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue,
-        "reinterpret_cast", OrigDestType.getAsString(),
-        SrcExpr->getSourceRange());
+      Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue)
+        << "reinterpret_cast" << OrigDestType.getAsString()
+        << SrcExpr->getSourceRange();
       return;
     }
 
@@ -233,9 +235,9 @@
     // Except for std::nullptr_t->integer, which is not supported yet, and
     // lvalue->reference, which is handled above, at least one of the two
     // arguments must be a pointer.
-    Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic,
-      "reinterpret_cast", OrigDestType.getAsString(), OrigSrcType.getAsString(),
-      OpRange);
+    Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic)
+      << "reinterpret_cast" << OrigDestType.getAsString()
+      << OrigSrcType.getAsString() << OpRange;
     return;
   }
 
@@ -257,8 +259,8 @@
     //   type large enough to hold it.
     if (Self.Context.getTypeSize(SrcType) >
         Self.Context.getTypeSize(DestType)) {
-      Self.Diag(OpRange.getBegin(), diag::err_bad_reinterpret_cast_small_int,
-        OrigDestType.getAsString(), DestRange);
+      Self.Diag(OpRange.getBegin(), diag::err_bad_reinterpret_cast_small_int)
+        << OrigDestType.getAsString() << DestRange;
     }
     return;
   }
@@ -273,17 +275,17 @@
   if (!destIsPtr || !srcIsPtr) {
     // With the valid non-pointer conversions out of the way, we can be even
     // more stringent.
-    Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic,
-      "reinterpret_cast", OrigDestType.getAsString(), OrigSrcType.getAsString(),
-      OpRange);
+    Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic)
+      << "reinterpret_cast" << OrigDestType.getAsString()
+      << OrigSrcType.getAsString() << OpRange;
     return;
   }
 
   // C++ 5.2.10p2: The reinterpret_cast operator shall not cast away constness.
   if (CastsAwayConstness(Self, SrcType, DestType)) {
-    Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_const_away,
-      "reinterpret_cast", OrigDestType.getAsString(), OrigSrcType.getAsString(),
-      OpRange);
+    Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_const_away)
+      << "reinterpret_cast" << OrigDestType.getAsString()
+      << OrigSrcType.getAsString() << OpRange;
     return;
   }
 
@@ -306,7 +308,8 @@
     // FIXME: Conditionally-supported behavior should be configurable in the
     // TargetInfo or similar.
     if (!Self.getLangOptions().CPlusPlus0x) {
-      Self.Diag(OpRange.getBegin(), diag::ext_reinterpret_cast_fn_obj, OpRange);
+      Self.Diag(OpRange.getBegin(), diag::ext_reinterpret_cast_fn_obj)
+        << OpRange;
     }
     return;
   }
@@ -316,7 +319,8 @@
   if (DestType->isFunctionPointerType()) {
     // See above.
     if (!Self.getLangOptions().CPlusPlus0x) {
-      Self.Diag(OpRange.getBegin(), diag::ext_reinterpret_cast_fn_obj, OpRange);
+      Self.Diag(OpRange.getBegin(), diag::ext_reinterpret_cast_fn_obj)
+        << OpRange;
     }
     return;
   }
@@ -462,9 +466,9 @@
           // This is definitely the intended conversion, but it might fail due
           // to a const violation.
           if (!DestPointee.isAtLeastAsQualifiedAs(SrcPointee)) {
-            Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_const_away,
-              "static_cast", DestType.getAsString(),
-              OrigSrcType.getAsString(), OpRange);
+            Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_const_away)
+              << "static_cast" << DestType.getAsString()
+              << OrigSrcType.getAsString() << OpRange;
           }
           return;
         }
@@ -476,8 +480,9 @@
   // FIXME: Error reporting could be a lot better. Should store the reason
   // why every substep failed and, at the end, select the most specific and
   // report that.
-  Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic, "static_cast",
-    DestType.getAsString(), OrigSrcType.getAsString(), OpRange);
+  Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic)
+    << "static_cast" << DestType.getAsString() << OrigSrcType.getAsString()
+    << OpRange;
 }
 
 /// Tests whether a conversion according to C++ 5.2.9p5 is valid.
@@ -575,9 +580,9 @@
 
   // Must preserve cv, as always.
   if (!DestType.isAtLeastAsQualifiedAs(SrcType)) {
-    Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_const_away,
-      "static_cast", OrigDestType.getAsString(), OrigSrcType.getAsString(),
-      OpRange);
+    Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_const_away)
+      << "static_cast" << OrigDestType.getAsString()
+      << OrigSrcType.getAsString() << OpRange;
     return TSC_Failed;
   }
 
@@ -604,18 +609,18 @@
       }
     }
 
-    Self.Diag(OpRange.getBegin(), diag::err_ambiguous_base_to_derived_cast,
-      SrcType.getUnqualifiedType().getAsString(),
-      DestType.getUnqualifiedType().getAsString(),
-      PathDisplayStr, OpRange);
+    Self.Diag(OpRange.getBegin(), diag::err_ambiguous_base_to_derived_cast)
+      << SrcType.getUnqualifiedType().getAsString()
+      << DestType.getUnqualifiedType().getAsString()
+      << PathDisplayStr << OpRange;
     return TSC_Failed;
   }
 
   if (Paths.getDetectedVirtual() != 0) {
     QualType VirtualBase(Paths.getDetectedVirtual(), 0);
-    Self.Diag(OpRange.getBegin(), diag::err_static_downcast_via_virtual,
-      OrigSrcType.getAsString(), OrigDestType.getAsString(),
-      VirtualBase.getAsString(), OpRange);
+    Self.Diag(OpRange.getBegin(), diag::err_static_downcast_via_virtual)
+      << OrigSrcType.getAsString() << OrigDestType.getAsString()
+      << VirtualBase.getAsString() << OpRange;
     return TSC_Failed;
   }
 
@@ -674,8 +679,8 @@
   } else if (DestReference) {
     DestPointee = DestReference->getPointeeType();
   } else {
-    Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_ref_or_ptr,
-      OrigDestType.getAsString(), DestRange);
+    Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_ref_or_ptr)
+      << OrigDestType.getAsString() << DestRange;
     return;
   }
 
@@ -684,13 +689,13 @@
     assert(DestPointer && "Reference to void is not possible");
   } else if (DestRecord) {
     if (!DestRecord->getDecl()->isDefinition()) {
-      Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_incomplete,
-        DestPointee.getUnqualifiedType().getAsString(), DestRange);
+      Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_incomplete)
+        << DestPointee.getUnqualifiedType().getAsString() << DestRange;
       return;
     }
   } else {
-    Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class,
-      DestPointee.getUnqualifiedType().getAsString(), DestRange);
+    Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class)
+      << DestPointee.getUnqualifiedType().getAsString() << DestRange;
     return;
   }
 
@@ -704,14 +709,14 @@
     if (const PointerType *SrcPointer = SrcType->getAsPointerType()) {
       SrcPointee = SrcPointer->getPointeeType();
     } else {
-      Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_ptr,
-        OrigSrcType.getAsString(), SrcExpr->getSourceRange());
+      Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_ptr)
+        << OrigSrcType.getAsString() << SrcExpr->getSourceRange();
       return;
     }
   } else {
     if (SrcExpr->isLvalue(Self.Context) != Expr::LV_Valid) {
-      Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue,
-        "dynamic_cast", OrigDestType.getAsString(), OpRange);
+      Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue)
+        << "dynamic_cast" << OrigDestType.getAsString() << OpRange;
     }
     SrcPointee = SrcType;
   }
@@ -719,9 +724,9 @@
   const RecordType *SrcRecord = SrcPointee->getAsRecordType();
   if (SrcRecord) {
     if (!SrcRecord->getDecl()->isDefinition()) {
-      Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_incomplete,
-        SrcPointee.getUnqualifiedType().getAsString(),
-        SrcExpr->getSourceRange());
+      Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_incomplete)
+        << SrcPointee.getUnqualifiedType().getAsString()
+        << SrcExpr->getSourceRange();
       return;
     }
   } else {
@@ -739,9 +744,9 @@
 
   // C++ 5.2.7p1: The dynamic_cast operator shall not cast away constness.
   if (!DestPointee.isAtLeastAsQualifiedAs(SrcPointee)) {
-    Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_const_away,
-      "dynamic_cast", OrigDestType.getAsString(), OrigSrcType.getAsString(),
-      OpRange);
+    Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_const_away)
+      << "dynamic_cast" << OrigDestType.getAsString()
+      << OrigSrcType.getAsString() << OpRange;
     return;
   }
 

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Nov 18 16:52:51 2008
@@ -1405,10 +1405,9 @@
   } else {
     if (PerformImplicitConversion(From, ToType))
       return Diag(From->getSourceRange().getBegin(),
-                  diag::err_typecheck_convert_incompatible,
-                  ToType.getAsString(), From->getType().getAsString(),
-                  Flavor,
-                  From->getSourceRange());
+                  diag::err_typecheck_convert_incompatible)
+        << ToType.getAsString() << From->getType().getAsString()
+        << Flavor << From->getSourceRange();
     else
       return false;
   }





More information about the cfe-commits mailing list