[cfe-commits] r60094 - in /cfe/trunk/lib/Sema: Sema.h SemaExpr.cpp SemaOverload.cpp
Douglas Gregor
doug.gregor at gmail.com
Tue Nov 25 22:01:48 PST 2008
Author: dgregor
Date: Wed Nov 26 00:01:48 2008
New Revision: 60094
URL: http://llvm.org/viewvc/llvm-project?rev=60094&view=rev
Log:
Tweak the new ResolveOverloadedCallFn to just return a FunctionDecl. It makes ActOnCallExpr simpler
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.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=60094&r1=60093&r2=60094&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Nov 26 00:01:48 2008
@@ -447,11 +447,11 @@
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,
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=60094&r1=60093&r2=60094&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Nov 26 00:01:48 2008
@@ -1295,12 +1295,16 @@
}
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())
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=60094&r1=60093&r2=60094&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Nov 26 00:01:48 2008
@@ -2967,24 +2967,20 @@
/// (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(),
More information about the cfe-commits
mailing list