[cfe-commits] r91503 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/Sema.h lib/Sema/SemaCXXCast.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaExprObjC.cpp lib/Sema/SemaInit.cpp lib/Sema/SemaOverload.cpp lib/Sema/SemaStmt.cpp

Douglas Gregor dgregor at apple.com
Tue Dec 15 19:45:30 PST 2009


Author: dgregor
Date: Tue Dec 15 21:45:30 2009
New Revision: 91503

URL: http://llvm.org/viewvc/llvm-project?rev=91503&view=rev
Log:
Fix semantic diagnostics that embed English works, from Nicola Gigante!


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaCXXCast.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaExprObjC.cpp
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=91503&r1=91502&r2=91503&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec 15 21:45:30 2009
@@ -1922,9 +1922,11 @@
   "%0 is always %select{zero|false|NULL}1 in this context">;
 
 // assignment related diagnostics (also for argument passing, returning, etc).
-// FIXME: %2 is an english string here.
+// In most of these diagnostics the %2 is a value from the
+// Sema::AssignmentAction enumeration
 def err_typecheck_convert_incompatible : Error<
-  "incompatible type %2 %1, expected %0">;
+  "incompatible type %select{assigning|passing|returning|converting|initializing|sending|casting}2"
+  " %1, expected %0">;
 def err_typecheck_convert_ambiguous : Error<
   "ambiguity in initializing value of type %0 with initializer of type %1">;
 def err_cannot_initialize_decl_noname : Error<
@@ -1933,31 +1935,43 @@
 def err_cannot_initialize_decl : Error<
   "cannot initialize %0 with an %select{rvalue|lvalue}1 of type %2">;
 def warn_incompatible_qualified_id : Warning<
-  "incompatible type %2 %1, expected %0">;
+  "incompatible type %select{assigning|passing|returning|converting|initializing|sending|casting}2"
+  " %1, expected %0">;
 def ext_typecheck_convert_pointer_int : ExtWarn<
-  "incompatible pointer to integer conversion %2 %1, expected %0">;
+  "incompatible pointer to integer conversion "
+  "%select{assigning|passing|returning|converting|initializing|sending|casting}2 %1, expected %0">;
 def ext_typecheck_convert_int_pointer : ExtWarn<
-  "incompatible integer to pointer conversion %2 %1, expected %0">;
+  "incompatible integer to pointer conversion "
+  "%select{assigning|passing|returning|converting|initializing|sending|casting}2 %1, expected %0">;
 def ext_typecheck_convert_pointer_void_func : Extension<
-  "%2 %1 converts between void* and function pointer, expected %0">;
+  "%select{assigning|passing|returning|converting|initializing|sending|casting}2"
+  " %1 converts between void* and function pointer, expected %0">;
 def ext_typecheck_convert_incompatible_pointer_sign : ExtWarn<
- "pointer types point to integer types with different sign %2 %1, expected %0">,
+ "pointer types point to integer types with different sign "
+ "%select{assigning|passing|returning|converting|initializing|sending|casting}2 %1, expected %0">,
   InGroup<DiagGroup<"pointer-sign">>;
 def ext_typecheck_convert_incompatible_pointer : ExtWarn<
-  "incompatible pointer types %2 %1, expected %0">;
+  "incompatible pointer types "
+  "%select{assigning|passing|returning|converting|initializing|sending|casting}2 %1, expected %0">;
 def ext_typecheck_convert_discards_qualifiers : ExtWarn<
-  "%2 %1 discards qualifiers, expected %0">;
+  "%select{assigning|passing|returning|converting|initializing|sending|casting}2"
+  " %1 discards qualifiers, expected %0">;
 def ext_nested_pointer_qualifier_mismatch : ExtWarn<
-  "%2, %0 and %1 have different qualifiers in nested pointer types">;
+  "%select{assigning|passing|returning|converting|initializing|sending|casting}2,"
+  " %0 and %1 have different qualifiers in nested pointer types">;
 def warn_incompatible_vectors : Warning<
-  "incompatible vector types %2 %1, expected %0">,
+  "incompatible vector types %select{assigning|passing|returning|converting|initializing|sending|casting}2"
+  " %1, expected %0">,
   InGroup<VectorConversions>, DefaultIgnore;
 def err_int_to_block_pointer : Error<
-  "invalid conversion %2 integer %1, expected block pointer %0">;
+  "invalid conversion "
+  "%select{assigning|passing|returning|converting|initializing|sending|casting}2"
+  " integer %1, expected block pointer %0">;
 def err_typecheck_comparison_of_distinct_blocks : Error<
   "comparison of distinct block types (%0 and %1)">;
 def err_typecheck_convert_incompatible_block_pointer : Error<
-  "incompatible block pointer types %2 %1, expected %0">;
+  "incompatible block pointer types "
+  "%select{assigning|passing|returning|converting|initializing|sending|casting}2 %1, expected %0">;
 
 def err_typecheck_array_not_modifiable_lvalue : Error<
   "array type %0 is not assignable">;

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Dec 15 21:45:30 2009
@@ -842,6 +842,18 @@
   void MergeVarDecl(VarDecl *New, LookupResult &OldDecls);
   bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old);
 
+  // AssignmentAction - This is used by all the assignment diagnostic functions
+  // to represent what is actually causing the operation
+  enum AssignmentAction {
+    AA_Assigning,
+    AA_Passing,
+    AA_Returning,
+    AA_Converting,
+    AA_Initializing,
+    AA_Sending,
+    AA_Casting
+  };
+  
   /// C++ Overloading.
   enum OverloadKind {
     /// This is a legitimate overload: the existing declarations are
@@ -918,8 +930,9 @@
   TryCopyInitialization(Expr* From, QualType ToType,
                         bool SuppressUserConversions, bool ForceRValue,
                         bool InOverloadResolution);
+  
   bool PerformCopyInitialization(Expr *&From, QualType ToType,
-                                 const char *Flavor, bool Elidable = false);
+                                 AssignmentAction Action, bool Elidable = false);
 
   ImplicitConversionSequence
   TryObjectArgumentInitialization(QualType FromType, CXXMethodDecl *Method,
@@ -3557,14 +3570,14 @@
     /// represent it in the AST.
     Incompatible
   };
-
+  
   /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
   /// assignment conversion type specified by ConvTy.  This returns true if the
   /// conversion was invalid or false if the conversion was accepted.
   bool DiagnoseAssignmentResult(AssignConvertType ConvTy,
                                 SourceLocation Loc,
                                 QualType DstType, QualType SrcType,
-                                Expr *SrcExpr, const char *Flavor);
+                                Expr *SrcExpr, AssignmentAction Action);
 
   /// CheckAssignmentConstraints - Perform type checking for assignment,
   /// argument passing, variable initialization, and function return values.
@@ -3599,25 +3612,24 @@
   bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
 
   bool PerformImplicitConversion(Expr *&From, QualType ToType,
-                                 const char *Flavor,
+                                 AssignmentAction Action,
                                  bool AllowExplicit = false,
                                  bool Elidable = false);
   bool PerformImplicitConversion(Expr *&From, QualType ToType,
-                                 const char *Flavor,
+                                 AssignmentAction Action,
                                  bool AllowExplicit,
                                  bool Elidable,
                                  ImplicitConversionSequence& ICS);
   bool PerformImplicitConversion(Expr *&From, QualType ToType,
                                  const ImplicitConversionSequence& ICS,
-                                 const char *Flavor,
+                                 AssignmentAction Action,
                                  bool IgnoreBaseAccess = false);
   bool PerformImplicitConversion(Expr *&From, QualType ToType,
                                  const StandardConversionSequence& SCS,
-                                 const char *Flavor, bool IgnoreBaseAccess);
+                                 AssignmentAction Action, bool IgnoreBaseAccess);
   
   bool BuildCXXDerivedToBaseExpr(Expr *&From, CastExpr::CastKind CastKind,
-                                 const ImplicitConversionSequence& ICS,
-                                 const char *Flavor);
+                                 const ImplicitConversionSequence& ICS);
 
   /// the following "Check" methods will return a valid/converted QualType
   /// or a null QualType (indicating an error diagnostic was issued).

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Tue Dec 15 21:45:30 2009
@@ -899,7 +899,7 @@
   // The conversion is possible, so commit to it.
   Kind = CastExpr::CK_NoOp;
   msg = 0;
-  return Self.PerformImplicitConversion(SrcExpr, DestType, ICS, "casting",
+  return Self.PerformImplicitConversion(SrcExpr, DestType, ICS, Sema::AA_Casting,
                                         /*IgnoreBaseAccess*/CStyle) ?
       TC_Failed : TC_Success;
 }

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Dec 15 21:45:30 2009
@@ -1139,7 +1139,7 @@
     }
     else
       NewExp = (Expr*)Args[0];
-    if (PerformCopyInitialization(NewExp, FieldType, "passing"))
+    if (PerformCopyInitialization(NewExp, FieldType, AA_Passing))
       return true;
     Args[0] = NewExp;
   }
@@ -4566,7 +4566,7 @@
       (T1->isRecordType() || T2->isRecordType())) {
     if (!ICS)
       Diag(DeclLoc, diag::err_typecheck_convert_incompatible)
-        << DeclType << Init->getType() << "initializing" << Init->getSourceRange();
+        << DeclType << Init->getType() << AA_Initializing << Init->getSourceRange();
     return true;
   }
 
@@ -4600,7 +4600,7 @@
     return ICS->ConversionKind == ImplicitConversionSequence::BadConversion;
   } else {
     ImplicitConversionSequence Conversions;
-    bool badConversion = PerformImplicitConversion(Init, T1, "initializing", 
+    bool badConversion = PerformImplicitConversion(Init, T1, AA_Initializing, 
                                                    false, false, 
                                                    Conversions);
     if (badConversion) {

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Dec 15 21:45:30 2009
@@ -3155,7 +3155,7 @@
         return true;
       
       // Pass the argument.
-      if (PerformCopyInitialization(Arg, ProtoArgType, "passing"))
+      if (PerformCopyInitialization(Arg, ProtoArgType, AA_Passing))
         return true;
       
       if (!ProtoArgType->isReferenceType())
@@ -4629,7 +4629,7 @@
       // expression is implicitly converted (C++ 4) to the
       // cv-unqualified type of the left operand.
       if (PerformImplicitConversion(rExpr, lhsType.getUnqualifiedType(),
-                                    "assigning"))
+                                    AA_Assigning))
         return Incompatible;
       return Compatible;
     }
@@ -5500,7 +5500,7 @@
     return InvalidOperands(Loc, lex, rex);
 
   if (PerformImplicitConversion(lex, Context.BoolTy, LHS,
-                                "passing", /*IgnoreBaseAccess=*/false))
+                                AA_Passing, /*IgnoreBaseAccess=*/false))
     return InvalidOperands(Loc, lex, rex);
   
   StandardConversionSequence RHS;
@@ -5509,7 +5509,7 @@
     return InvalidOperands(Loc, lex, rex);
   
   if (PerformImplicitConversion(rex, Context.BoolTy, RHS,
-                                "passing", /*IgnoreBaseAccess=*/false))
+                                AA_Passing, /*IgnoreBaseAccess=*/false))
     return InvalidOperands(Loc, lex, rex);
   
   // C++ [expr.log.and]p2
@@ -5651,7 +5651,7 @@
   }
 
   if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
-                               RHS, "assigning"))
+                               RHS, AA_Assigning))
     return QualType();
 
   // C99 6.5.16p3: The type of an assignment expression is the type of the
@@ -6847,7 +6847,7 @@
 bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
                                     SourceLocation Loc,
                                     QualType DstType, QualType SrcType,
-                                    Expr *SrcExpr, const char *Flavor) {
+                                    Expr *SrcExpr, AssignmentAction Action) {
   // Decode the result (notice that AST's are still created for extensions).
   bool isInvalid = false;
   unsigned DiagKind;
@@ -6910,7 +6910,7 @@
     break;
   }
 
-  Diag(Loc, DiagKind) << DstType << SrcType << Flavor
+  Diag(Loc, DiagKind) << DstType << SrcType << Action
     << SrcExpr->getSourceRange() << Hint;
   return isInvalid;
 }

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Dec 15 21:45:30 2009
@@ -627,10 +627,9 @@
     // Whatch out for variadic allocator function.
     unsigned NumArgsInFnDecl = FnDecl->getNumParams();
     for (unsigned i = 0; (i < NumArgs && i < NumArgsInFnDecl); ++i) {
-      // FIXME: Passing word to diagnostic.
       if (PerformCopyInitialization(Args[i],
                                     FnDecl->getParamDecl(i)->getType(),
-                                    "passing"))
+                                    AA_Passing))
         return true;
     }
     Operator = FnDecl;
@@ -872,7 +871,7 @@
         Operand.release();
         if (!PerformImplicitConversion(Ex, 
                             ObjectPtrConversions.front()->getConversionType(), 
-                                      "converting")) {
+                                      AA_Converting)) {
           Operand = Owned(Ex);
           Type = Ex->getType();
         }
@@ -1023,16 +1022,16 @@
 /// resolution works differently in that case.
 bool
 Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
-                                const char *Flavor, bool AllowExplicit,
+                                AssignmentAction Action, bool AllowExplicit,
                                 bool Elidable) {
   ImplicitConversionSequence ICS;
-  return PerformImplicitConversion(From, ToType, Flavor, AllowExplicit, 
+  return PerformImplicitConversion(From, ToType, Action, AllowExplicit, 
                                    Elidable, ICS);
 }
 
 bool
 Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
-                                const char *Flavor, bool AllowExplicit,
+                                AssignmentAction Action, bool AllowExplicit,
                                 bool Elidable,
                                 ImplicitConversionSequence& ICS) {
   ICS.ConversionKind = ImplicitConversionSequence::BadConversion;
@@ -1050,7 +1049,7 @@
                                 /*ForceRValue=*/false,
                                 /*InOverloadResolution=*/false);
   }
-  return PerformImplicitConversion(From, ToType, ICS, Flavor);
+  return PerformImplicitConversion(From, ToType, ICS, Action);
 }
 
 /// BuildCXXDerivedToBaseExpr - This routine generates the suitable AST
@@ -1058,8 +1057,7 @@
 /// necessary information is passed in ICS.
 bool 
 Sema::BuildCXXDerivedToBaseExpr(Expr *&From, CastExpr::CastKind CastKind,
-                                     const ImplicitConversionSequence& ICS,
-                                     const char *Flavor) {
+                                     const ImplicitConversionSequence& ICS) {
   QualType  BaseType = 
     QualType::getFromOpaquePtr(ICS.UserDefined.After.ToTypePtr);
   // Must do additional defined to base conversion.
@@ -1091,15 +1089,15 @@
 /// expression From to the type ToType using the pre-computed implicit
 /// conversion sequence ICS. Returns true if there was an error, false
 /// otherwise. The expression From is replaced with the converted
-/// expression. Flavor is the kind of conversion we're performing,
+/// expression. Action is the kind of conversion we're performing,
 /// used in the error message.
 bool
 Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
                                 const ImplicitConversionSequence &ICS,
-                                const char* Flavor, bool IgnoreBaseAccess) {
+                                AssignmentAction Action, bool IgnoreBaseAccess) {
   switch (ICS.ConversionKind) {
   case ImplicitConversionSequence::StandardConversion:
-    if (PerformImplicitConversion(From, ToType, ICS.Standard, Flavor,
+    if (PerformImplicitConversion(From, ToType, ICS.Standard, Action,
                                   IgnoreBaseAccess))
       return true;
     break;
@@ -1132,7 +1130,7 @@
       // Whatch out for elipsis conversion.
       if (!ICS.UserDefined.EllipsisConversion) {
         if (PerformImplicitConversion(From, BeforeToType, 
-                                      ICS.UserDefined.Before, "converting",
+                                      ICS.UserDefined.Before, AA_Converting,
                                       IgnoreBaseAccess))
           return true;
       }
@@ -1152,7 +1150,7 @@
       // there's some nasty stuff involving MaybeBindToTemporary going on here.
       if (ICS.UserDefined.After.Second == ICK_Derived_To_Base &&
           ICS.UserDefined.After.CopyConstructor) {
-        return BuildCXXDerivedToBaseExpr(From, CastKind, ICS, Flavor);
+        return BuildCXXDerivedToBaseExpr(From, CastKind, ICS);
       }
 
       if (ICS.UserDefined.After.CopyConstructor) {
@@ -1163,7 +1161,7 @@
       }
 
       return PerformImplicitConversion(From, ToType, ICS.UserDefined.After,
-                                       "converting", IgnoreBaseAccess);
+                                       AA_Converting, IgnoreBaseAccess);
   }
       
   case ImplicitConversionSequence::EllipsisConversion:
@@ -1187,7 +1185,7 @@
 bool
 Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
                                 const StandardConversionSequence& SCS,
-                                const char *Flavor, bool IgnoreBaseAccess) {
+                                AssignmentAction Action, bool IgnoreBaseAccess) {
   // Overall FIXME: we are recomputing too many types here and doing far too
   // much extra work. What this means is that we need to keep track of more
   // information that is computed when we try the implicit conversion initially,
@@ -1319,7 +1317,7 @@
       // Diagnose incompatible Objective-C conversions
       Diag(From->getSourceRange().getBegin(),
            diag::ext_typecheck_convert_incompatible_pointer)
-        << From->getType() << ToType << Flavor
+        << From->getType() << ToType << Action
         << From->getSourceRange();
     }
 
@@ -1591,9 +1589,9 @@
     case OR_Success:
       // We found a match. Perform the conversions on the arguments and move on.
       if (Self.PerformImplicitConversion(LHS, Best->BuiltinTypes.ParamTypes[0],
-                                         Best->Conversions[0], "converting") ||
+                                         Best->Conversions[0], Sema::AA_Converting) ||
           Self.PerformImplicitConversion(RHS, Best->BuiltinTypes.ParamTypes[1],
-                                         Best->Conversions[1], "converting"))
+                                         Best->Conversions[1], Sema::AA_Converting))
         break;
       return false;
 
@@ -1651,7 +1649,7 @@
                                    /*AllowExplicit=*/false,
                                    /*ForceRValue=*/false);
   }
-  if (Self.PerformImplicitConversion(E, TargetType(ICS), ICS, "converting"))
+  if (Self.PerformImplicitConversion(E, TargetType(ICS), ICS, Sema::AA_Converting))
     return true;
   return false;
 }
@@ -1875,9 +1873,9 @@
           LPointee = Context.getQualifiedType(LPointee, MergedQuals);
           QualType Common
             = Context.getMemberPointerType(LPointee, MoreDerived.getTypePtr());
-          if (PerformImplicitConversion(LHS, Common, "converting"))
+          if (PerformImplicitConversion(LHS, Common, Sema::AA_Converting))
             return QualType();
-          if (PerformImplicitConversion(RHS, Common, "converting"))
+          if (PerformImplicitConversion(RHS, Common, Sema::AA_Converting))
             return QualType();
           return Common;
         }
@@ -2042,13 +2040,13 @@
                  && E2ToC2.ConversionKind !=
                       ImplicitConversionSequence::BadConversion;
   if (ToC1Viable && !ToC2Viable) {
-    if (!PerformImplicitConversion(E1, Composite1, E1ToC1, "converting") &&
-        !PerformImplicitConversion(E2, Composite1, E2ToC1, "converting"))
+    if (!PerformImplicitConversion(E1, Composite1, E1ToC1, Sema::AA_Converting) &&
+        !PerformImplicitConversion(E2, Composite1, E2ToC1, Sema::AA_Converting))
       return Composite1;
   }
   if (ToC2Viable && !ToC1Viable) {
-    if (!PerformImplicitConversion(E1, Composite2, E1ToC2, "converting") &&
-        !PerformImplicitConversion(E2, Composite2, E2ToC2, "converting"))
+    if (!PerformImplicitConversion(E1, Composite2, E1ToC2, Sema::AA_Converting) &&
+        !PerformImplicitConversion(E2, Composite2, E2ToC2, Sema::AA_Converting))
       return Composite2;
   }
   return QualType();

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Tue Dec 15 21:45:30 2009
@@ -205,7 +205,7 @@
 
     IsError |=
       DiagnoseAssignmentResult(Result, argExpr->getLocStart(), lhsType, rhsType,
-                               argExpr, "sending");
+                               argExpr, AA_Sending);
   }
 
   // Promote additional arguments to variadic methods.

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Dec 15 21:45:30 2009
@@ -73,7 +73,7 @@
   if (S.getLangOptions().CPlusPlus) {
     // FIXME: I dislike this error message. A lot.
     if (S.PerformImplicitConversion(Init, DeclType, 
-                                    "initializing", DirectInit)) {
+                                    Sema::AA_Initializing, DirectInit)) {
       ImplicitConversionSequence ICS;
       OverloadCandidateSet CandidateSet;
       if (S.IsUserDefinedConversion(Init, DeclType, ICS.UserDefined,
@@ -81,7 +81,7 @@
                               true, false, false) != OR_Ambiguous)
         return S.Diag(Init->getSourceRange().getBegin(),
                       diag::err_typecheck_convert_incompatible)
-                      << DeclType << Init->getType() << "initializing"
+                      << DeclType << Init->getType() << Sema::AA_Initializing
                       << Init->getSourceRange();
       S.Diag(Init->getSourceRange().getBegin(),
              diag::err_typecheck_convert_ambiguous)
@@ -95,7 +95,7 @@
   Sema::AssignConvertType ConvTy =
     S.CheckSingleAssignmentConstraints(DeclType, Init);
   return S.DiagnoseAssignmentResult(ConvTy, Init->getLocStart(), DeclType,
-                                  InitType, Init, "initializing");
+                                    InitType, Init, Sema::AA_Initializing);
 }
 
 static void CheckStringInit(Expr *Str, QualType &DeclT, Sema &S) {
@@ -279,7 +279,7 @@
       //      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, "initializing"))
+      if (!PerformImplicitConversion(Init, DeclType, Sema::AA_Initializing))
         return false;
 
       if (InitEntity)
@@ -747,7 +747,7 @@
 
       if (ICS.ConversionKind != ImplicitConversionSequence::BadConversion) {
         if (SemaRef.PerformImplicitConversion(expr, ElemType, ICS,
-                                               "initializing"))
+                                              Sema::AA_Initializing))
           hadError = true;
         UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
         ++Index;
@@ -787,7 +787,7 @@
     } else {
       // We cannot initialize this element, so let
       // PerformCopyInitialization produce the appropriate diagnostic.
-      SemaRef.PerformCopyInitialization(expr, ElemType, "initializing");
+      SemaRef.PerformCopyInitialization(expr, ElemType, Sema::AA_Initializing);
       hadError = true;
       ++Index;
       ++StructuredIndex;
@@ -3150,7 +3150,7 @@
       break;
         
     case SK_ConversionSequence:
-      if (S.PerformImplicitConversion(CurInitExpr, Step->Type, "converting", 
+        if (S.PerformImplicitConversion(CurInitExpr, Step->Type, Sema::AA_Converting, 
                                       false, false, *Step->ICS))
         return S.ExprError();
         

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Dec 15 21:45:30 2009
@@ -2080,7 +2080,7 @@
 /// be true when the copy may be elided (C++ 12.8p15). Overload resolution works
 /// differently in C++0x for this case.
 bool Sema::PerformCopyInitialization(Expr *&From, QualType ToType,
-                                     const char* Flavor, bool Elidable) {
+                                     AssignmentAction Action, bool Elidable) {
   if (!getLangOptions().CPlusPlus) {
     // In C, argument passing is the same as performing an assignment.
     QualType FromType = From->getType();
@@ -2092,7 +2092,7 @@
       ConvTy = Compatible;
 
     return DiagnoseAssignmentResult(ConvTy, From->getLocStart(), ToType,
-                                    FromType, From, Flavor);
+                                    FromType, From, Action);
   }
 
   if (ToType->isReferenceType())
@@ -2102,13 +2102,13 @@
                               /*AllowExplicit=*/false,
                               /*ForceRValue=*/false);
 
-  if (!PerformImplicitConversion(From, ToType, Flavor,
+  if (!PerformImplicitConversion(From, ToType, Action,
                                  /*AllowExplicit=*/false, Elidable))
     return false;
   if (!DiagnoseMultipleUserDefinedConversion(From, ToType))
     return Diag(From->getSourceRange().getBegin(),
                 diag::err_typecheck_convert_incompatible)
-      << ToType << From->getType() << Flavor << From->getSourceRange();
+      << ToType << From->getType() << Action << From->getSourceRange();
   return true;
 }
 
@@ -2229,7 +2229,7 @@
 /// of the expression From to bool (C++0x [conv]p3).
 bool Sema::PerformContextuallyConvertToBool(Expr *&From) {
   ImplicitConversionSequence ICS = TryContextuallyConvertToBool(From);
-  if (!PerformImplicitConversion(From, Context.BoolTy, ICS, "converting"))
+  if (!PerformImplicitConversion(From, Context.BoolTy, ICS, AA_Converting))
     return false;
   
   if (!DiagnoseMultipleUserDefinedConversion(From, Context.BoolTy))
@@ -4789,7 +4789,7 @@
         // Convert the arguments.
         if (PerformCopyInitialization(Input,
                                       FnDecl->getParamDecl(0)->getType(),
-                                      "passing"))
+                                      AA_Passing))
           return ExprError();
       }
 
@@ -4817,7 +4817,7 @@
       // break out so that we will build the appropriate built-in
       // operator node.
         if (PerformImplicitConversion(Input, Best->BuiltinTypes.ParamTypes[0],
-                                      Best->Conversions[0], "passing"))
+                                      Best->Conversions[0], AA_Passing))
           return ExprError();
 
         break;
@@ -4956,14 +4956,14 @@
         if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
           if (PerformObjectArgumentInitialization(Args[0], Method) ||
               PerformCopyInitialization(Args[1], FnDecl->getParamDecl(0)->getType(),
-                                        "passing"))
+                                        AA_Passing))
             return ExprError();
         } else {
           // Convert the arguments.
           if (PerformCopyInitialization(Args[0], FnDecl->getParamDecl(0)->getType(),
-                                        "passing") ||
+                                        AA_Passing) ||
               PerformCopyInitialization(Args[1], FnDecl->getParamDecl(1)->getType(),
-                                        "passing"))
+                                        AA_Passing))
             return ExprError();
         }
 
@@ -4992,9 +4992,9 @@
         // break out so that we will build the appropriate built-in
         // operator node.
         if (PerformImplicitConversion(Args[0], Best->BuiltinTypes.ParamTypes[0],
-                                      Best->Conversions[0], "passing") ||
+                                      Best->Conversions[0], AA_Passing) ||
             PerformImplicitConversion(Args[1], Best->BuiltinTypes.ParamTypes[1],
-                                      Best->Conversions[1], "passing"))
+                                      Best->Conversions[1], AA_Passing))
           return ExprError();
 
         break;
@@ -5106,7 +5106,7 @@
         if (PerformObjectArgumentInitialization(Args[0], Method) ||
             PerformCopyInitialization(Args[1],
                                       FnDecl->getParamDecl(0)->getType(),
-                                      "passing"))
+                                      AA_Passing))
           return ExprError();
 
         // Determine the result type
@@ -5136,9 +5136,9 @@
         // break out so that we will build the appropriate built-in
         // operator node.
         if (PerformImplicitConversion(Args[0], Best->BuiltinTypes.ParamTypes[0],
-                                      Best->Conversions[0], "passing") ||
+                                      Best->Conversions[0], AA_Passing) ||
             PerformImplicitConversion(Args[1], Best->BuiltinTypes.ParamTypes[1],
-                                      Best->Conversions[1], "passing"))
+                                      Best->Conversions[1], AA_Passing))
           return ExprError();
 
         break;
@@ -5522,7 +5522,7 @@
 
       // Pass the argument.
       QualType ProtoArgType = Proto->getArgType(i);
-      IsError |= PerformCopyInitialization(Arg, ProtoArgType, "passing");
+      IsError |= PerformCopyInitialization(Arg, ProtoArgType, AA_Passing);
     } else {
       OwningExprResult DefArg
         = BuildCXXDefaultArgExpr(LParenLoc, Method, Method->getParamDecl(i));

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Dec 15 21:45:30 2009
@@ -902,7 +902,7 @@
     AssignConvertType ConvTy =
       CheckSingleAssignmentConstraints(Context.VoidPtrTy, E);
     if (DiagnoseAssignmentResult(ConvTy, StarLoc, Context.VoidPtrTy, ETy,
-                                 E, "passing"))
+                                 E, AA_Passing))
       return StmtError();
   }
   return Owned(new (Context) IndirectGotoStmt(GotoLoc, StarLoc, E));
@@ -986,7 +986,7 @@
     // In C++ the return statement is handled via a copy initialization.
     // the C version of which boils down to CheckSingleAssignmentConstraints.
     // FIXME: Leaks RetValExp.
-    if (PerformCopyInitialization(RetValExp, FnRetType, "returning"))
+    if (PerformCopyInitialization(RetValExp, FnRetType, AA_Returning))
       return StmtError();
 
     if (RetValExp) CheckReturnStackAddr(RetValExp, FnRetType, ReturnLoc);
@@ -1096,7 +1096,7 @@
     // In C++ the return statement is handled via a copy initialization.
     // the C version of which boils down to CheckSingleAssignmentConstraints.
     // FIXME: Leaks RetValExp on error.
-    if (PerformCopyInitialization(RetValExp, FnRetType, "returning", Elidable)){
+    if (PerformCopyInitialization(RetValExp, FnRetType, AA_Returning, Elidable)){
       // We should still clean up our temporaries, even when we're failing!
       RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp);
       return StmtError();





More information about the cfe-commits mailing list