Move the overloading logic of Sema::ActOnCallExpr to a separate function

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60093 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index fdd5732..a6e1611 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1294,39 +1294,13 @@
     }
   }
 
-  // If we have a set of overloaded functions, perform overload
-  // resolution to pick the function.
   if (Ovl) {
-    OverloadCandidateSet CandidateSet;
-    AddOverloadCandidates(Ovl, Args, NumArgs, CandidateSet);
-    OverloadCandidateSet::iterator Best;
-    switch (BestViableFunction(CandidateSet, Best)) {
-    case OR_Success: 
-      {
-        // Success! Let the remainder of this function build a call to
-        // the function selected by overload resolution.
-        FDecl = Best->Function;
-        Expr *NewFn = new DeclRefExpr(FDecl, FDecl->getType(), 
-                                      Fn->getSourceRange().getBegin());
-        delete Fn;
-        Fn = NewFn;
-      }
-      break;
-
-    case OR_No_Viable_Function:
-      Diag(Fn->getSourceRange().getBegin(), 
-           diag::err_ovl_no_viable_function_in_call)
-        << Ovl->getDeclName() << (unsigned)CandidateSet.size()
-        << Fn->getSourceRange();
-      PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);
+    Fn = ResolveOverloadedCallFn(Fn, Ovl, LParenLoc, Args, NumArgs, CommaLocs,
+                                 RParenLoc);
+    if (!Fn)
       return true;
 
-    case OR_Ambiguous:
-      Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_ambiguous_call)
-        << Ovl->getDeclName() << Fn->getSourceRange();
-      PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true);
-      return true;
-    }
+    // Fall through and build the call to Fn.
   }
 
   if (getLangOptions().CPlusPlus && Fn->getType()->isRecordType())