]> granicus.if.org Git - clang/commitdiff
Tweak the new ResolveOverloadedCallFn to just return a FunctionDecl. It makes ActOnCa...
authorDouglas Gregor <dgregor@apple.com>
Wed, 26 Nov 2008 06:01:48 +0000 (06:01 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 26 Nov 2008 06:01:48 +0000 (06:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60094 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.h
lib/Sema/SemaExpr.cpp
lib/Sema/SemaOverload.cpp

index cf9b10c0c858d37e1079b2589b6bbae22df2bd3b..c8352172f9ae123105f64d6e82651e399fbc0078 100644 (file)
@@ -447,11 +447,11 @@ public:
                                                    bool Complain);
   void FixOverloadedFunctionReference(Expr *E, FunctionDecl *Fn);
 
-  Expr *ResolveOverloadedCallFn(Expr *Fn, OverloadedFunctionDecl *Ovl,
-                                SourceLocation LParenLoc,
-                                Expr **Args, unsigned NumArgs,
-                                SourceLocation *CommaLocs, 
-                                SourceLocation RParenLoc);
+  FunctionDecl *ResolveOverloadedCallFn(Expr *Fn, OverloadedFunctionDecl *Ovl,
+                                        SourceLocation LParenLoc,
+                                        Expr **Args, unsigned NumArgs,
+                                        SourceLocation *CommaLocs, 
+                                        SourceLocation RParenLoc);
 
   ExprResult 
   BuildCallToObjectOfClassType(Expr *Object, SourceLocation LParenLoc,
index a6e1611dc311315444b351c43e553c6d7485f145..a13bcbab629ceac6034b0269083e8feb6bc40d4b 100644 (file)
@@ -1295,12 +1295,16 @@ ActOnCallExpr(ExprTy *fn, SourceLocation LParenLoc,
   }
 
   if (Ovl) {
-    Fn = ResolveOverloadedCallFn(Fn, Ovl, LParenLoc, Args, NumArgs, CommaLocs,
-                                 RParenLoc);
-    if (!Fn)
+    FDecl = ResolveOverloadedCallFn(Fn, Ovl, LParenLoc, Args, NumArgs, CommaLocs,
+                                    RParenLoc);
+    if (!FDecl)
       return true;
 
-    // Fall through and build the call to Fn.
+    // Update Fn to refer to the actual function selected.
+    Expr *NewFn = new DeclRefExpr(FDecl, FDecl->getType(), 
+                                  Fn->getSourceRange().getBegin());
+    Fn->Destroy(Context);
+    Fn = NewFn;
   }
 
   if (getLangOptions().CPlusPlus && Fn->getType()->isRecordType())
index 14e0f44c878b227dccf855b2d75756b25d5c3fae..c6b028456fef23640bf0fd20bc152039ac6fb566 100644 (file)
@@ -2967,24 +2967,20 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
 /// (which eventually refers to the set of overloaded functions in
 /// Ovl) and the call arguments Args/NumArgs, attempt to resolve the
 /// function call down to a specific function. If overload resolution
-/// succeeds, returns an expression that refers to a specific function
-/// and deletes Fn. Otherwise, emits diagnostics, deletes all of the
+/// succeeds, returns the function declaration produced by overload
+/// resolution. Otherwise, emits diagnostics, deletes all of the
 /// arguments and Fn, and returns NULL.
-Expr *Sema::ResolveOverloadedCallFn(Expr *Fn, OverloadedFunctionDecl *Ovl,
-                                    SourceLocation LParenLoc,
-                                    Expr **Args, unsigned NumArgs,
-                                    SourceLocation *CommaLocs, 
-                                    SourceLocation RParenLoc) {
+FunctionDecl *Sema::ResolveOverloadedCallFn(Expr *Fn, OverloadedFunctionDecl *Ovl,
+                                            SourceLocation LParenLoc,
+                                            Expr **Args, unsigned NumArgs,
+                                            SourceLocation *CommaLocs, 
+                                            SourceLocation RParenLoc) {
   OverloadCandidateSet CandidateSet;
   AddOverloadCandidates(Ovl, Args, NumArgs, CandidateSet);
   OverloadCandidateSet::iterator Best;
   switch (BestViableFunction(CandidateSet, Best)) {
-  case OR_Success: {
-    Expr *NewFn = new DeclRefExpr(Best->Function, Best->Function->getType(), 
-                                  Fn->getSourceRange().getBegin());
-    Fn->Destroy(Context);
-    return NewFn;
-  }
+  case OR_Success:
+    return Best->Function;
 
   case OR_No_Viable_Function:
     Diag(Fn->getSourceRange().getBegin(),