[cfe-commits] r99650 - in /cfe/trunk/lib/Sema: Sema.h SemaExprCXX.cpp SemaOverload.cpp

Douglas Gregor dgregor at apple.com
Fri Mar 26 13:35:59 PDT 2010


Author: dgregor
Date: Fri Mar 26 15:35:59 2010
New Revision: 99650

URL: http://llvm.org/viewvc/llvm-project?rev=99650&view=rev
Log:
Eliminate the non-InitializedEntity PerformCopyInitialization() and
re-route its only caller to the newer
PerformCopyInitialization(). We're down to one remaining caller of
Sema::CheckReferenceInit.

Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=99650&r1=99649&r2=99650&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Fri Mar 26 15:35:59 2010
@@ -1101,9 +1101,6 @@
                         bool SuppressUserConversions, bool ForceRValue,
                         bool InOverloadResolution);
   
-  bool PerformCopyInitialization(Expr *&From, QualType ToType,
-                                 AssignmentAction Action, bool Elidable = false);
-
   OwningExprResult PerformCopyInitialization(const InitializedEntity &Entity,
                                              SourceLocation EqualLoc,
                                              OwningExprResult Init);

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=99650&r1=99649&r2=99650&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Mar 26 15:35:59 2010
@@ -1062,10 +1062,15 @@
     // Watch out for variadic allocator function.
     unsigned NumArgsInFnDecl = FnDecl->getNumParams();
     for (unsigned i = 0; (i < NumArgs && i < NumArgsInFnDecl); ++i) {
-      if (PerformCopyInitialization(Args[i],
-                                    FnDecl->getParamDecl(i)->getType(),
-                                    AA_Passing))
+      OwningExprResult Result
+        = PerformCopyInitialization(InitializedEntity::InitializeParameter(
+                                                       FnDecl->getParamDecl(i)),
+                                    SourceLocation(),
+                                    Owned(Args[i]->Retain()));
+      if (Result.isInvalid())
         return true;
+      
+      Args[i] = Result.takeAs<Expr>();
     }
     Operator = FnDecl;
     CheckAllocationAccess(StartLoc, Range, R.getNamingClass(), Best->FoundDecl);

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=99650&r1=99649&r2=99650&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Mar 26 15:35:59 2010
@@ -2201,44 +2201,6 @@
   }
 }
 
-/// PerformCopyInitialization - Copy-initialize an object of type @p ToType with
-/// the expression @p From. Returns true (and emits a diagnostic) if there was
-/// an error, returns false if the initialization succeeded. Elidable should
-/// 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,
-                                     AssignmentAction Action, bool Elidable) {
-  if (!getLangOptions().CPlusPlus) {
-    // In C, argument passing is the same as performing an assignment.
-    QualType FromType = From->getType();
-
-    AssignConvertType ConvTy =
-      CheckSingleAssignmentConstraints(ToType, From);
-    if (ConvTy != Compatible &&
-        CheckTransparentUnionArgumentConstraints(ToType, From) == Compatible)
-      ConvTy = Compatible;
-
-    return DiagnoseAssignmentResult(ConvTy, From->getLocStart(), ToType,
-                                    FromType, From, Action);
-  }
-
-  if (ToType->isReferenceType())
-    return CheckReferenceInit(From, ToType,
-                              /*FIXME:*/From->getLocStart(),
-                              /*SuppressUserConversions=*/false,
-                              /*AllowExplicit=*/false,
-                              /*ForceRValue=*/false);
-
-  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() << Action << From->getSourceRange();
-  return true;
-}
-
 /// TryObjectArgumentInitialization - Try to initialize the object
 /// parameter of the given member function (@c Method) from the
 /// expression @p From.





More information about the cfe-commits mailing list