]> granicus.if.org Git - clang/commitdiff
Eliminate the non-InitializedEntity PerformCopyInitialization() and
authorDouglas Gregor <dgregor@apple.com>
Fri, 26 Mar 2010 20:35:59 +0000 (20:35 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 26 Mar 2010 20:35:59 +0000 (20:35 +0000)
re-route its only caller to the newer
PerformCopyInitialization(). We're down to one remaining caller of
Sema::CheckReferenceInit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99650 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.h
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaOverload.cpp

index 2ccc41f287560b2ce0a949c0765ab58f04ad84b0..5436aa940d68df6598cd2a48f0b5a0b391570e31 100644 (file)
@@ -1101,9 +1101,6 @@ public:
                         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);
index 1e506a905ecb5c36f800780cac275dab117aaf94..52dc6d8fa4f316e37443c3ed8a1e80ca291cc32e 100644 (file)
@@ -1062,10 +1062,15 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
     // 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);
index 410bf9a7c1e9f4fb1253c08bc56f55c40de53f72..bb67a759726d229e1fe66a7f351167bc9cfb7f58 100644 (file)
@@ -2201,44 +2201,6 @@ Sema::TryCopyInitialization(Expr *From, QualType ToType,
   }
 }
 
-/// 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.