[cfe-commits] r65397 - in /cfe/trunk/lib/Sema: Sema.h SemaInit.cpp

Chris Lattner sabre at nondot.org
Tue Feb 24 14:46:58 PST 2009


Author: lattner
Date: Tue Feb 24 16:46:58 2009
New Revision: 65397

URL: http://llvm.org/viewvc/llvm-project?rev=65397&view=rev
Log:
Make CheckSingleInitializer a static function in SemaInit.cpp

Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaInit.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Feb 24 16:46:58 2009
@@ -1889,8 +1889,6 @@
                              SourceLocation InitLoc,DeclarationName InitEntity,
                              bool DirectInit);
   bool CheckInitList(InitListExpr *&InitList, QualType &DeclType);
-  bool CheckSingleInitializer(Expr *&simpleInit, QualType declType,
-                              bool DirectInit);
   bool CheckForConstantInitializer(Expr *e, QualType t);
   bool CheckArithmeticConstantExpression(const Expr* e);
   bool CheckAddressConstantExpression(const Expr* e);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Feb 24 16:46:58 2009
@@ -35,25 +35,25 @@
   return 0;
 }
 
-bool Sema::CheckSingleInitializer(Expr *&Init, QualType DeclType, 
-                                  bool DirectInit) {  
+static bool CheckSingleInitializer(Expr *&Init, QualType DeclType, 
+                                   bool DirectInit, Sema &S) {
   // Get the type before calling CheckSingleAssignmentConstraints(), since
   // it can promote the expression.
   QualType InitType = Init->getType(); 
   
-  if (getLangOptions().CPlusPlus) {
+  if (S.getLangOptions().CPlusPlus) {
     // FIXME: I dislike this error message. A lot.
-    if (PerformImplicitConversion(Init, DeclType, "initializing", DirectInit))
-      return Diag(Init->getSourceRange().getBegin(),
-                  diag::err_typecheck_convert_incompatible)
-      << DeclType << Init->getType() << "initializing" 
-      << Init->getSourceRange();
-    
+    if (S.PerformImplicitConversion(Init, DeclType, "initializing", DirectInit))
+      return S.Diag(Init->getSourceRange().getBegin(),
+                    diag::err_typecheck_convert_incompatible)
+        << DeclType << Init->getType() << "initializing" 
+        << Init->getSourceRange();
     return false;
   }
   
-  AssignConvertType ConvTy = CheckSingleAssignmentConstraints(DeclType, Init);
-  return DiagnoseAssignmentResult(ConvTy, Init->getLocStart(), DeclType,
+  Sema::AssignConvertType ConvTy =
+    S.CheckSingleAssignmentConstraints(DeclType, Init);
+  return S.DiagnoseAssignmentResult(ConvTy, Init->getLocStart(), DeclType,
                                   InitType, Init, "initializing");
 }
 
@@ -163,7 +163,7 @@
       return Diag(Init->getLocStart(), diag::err_array_init_list_required)
       << Init->getSourceRange();
     
-    return CheckSingleInitializer(Init, DeclType, DirectInit);
+    return CheckSingleInitializer(Init, DeclType, DirectInit, *this);
   } 
   
   bool hadError = CheckInitList(InitList, DeclType);
@@ -676,7 +676,7 @@
     }
 
     Expr *savExpr = expr; // Might be promoted by CheckSingleInitializer.
-    if (SemaRef->CheckSingleInitializer(expr, DeclType, false))
+    if (CheckSingleInitializer(expr, DeclType, false, *SemaRef))
       hadError = true; // types weren't compatible.
     else if (savExpr != expr) {
       // The type was promoted, update initializer list.





More information about the cfe-commits mailing list