Tweak the new ResolveOverloadedCallFn to just return a FunctionDecl. It makes ActOnCallExpr simpler
llvm-svn: 60094
This commit is contained in:
parent
99dcbff154
commit
a60a6914cc
|
@ -447,11 +447,11 @@ public:
|
||||||
bool Complain);
|
bool Complain);
|
||||||
void FixOverloadedFunctionReference(Expr *E, FunctionDecl *Fn);
|
void FixOverloadedFunctionReference(Expr *E, FunctionDecl *Fn);
|
||||||
|
|
||||||
Expr *ResolveOverloadedCallFn(Expr *Fn, OverloadedFunctionDecl *Ovl,
|
FunctionDecl *ResolveOverloadedCallFn(Expr *Fn, OverloadedFunctionDecl *Ovl,
|
||||||
SourceLocation LParenLoc,
|
SourceLocation LParenLoc,
|
||||||
Expr **Args, unsigned NumArgs,
|
Expr **Args, unsigned NumArgs,
|
||||||
SourceLocation *CommaLocs,
|
SourceLocation *CommaLocs,
|
||||||
SourceLocation RParenLoc);
|
SourceLocation RParenLoc);
|
||||||
|
|
||||||
ExprResult
|
ExprResult
|
||||||
BuildCallToObjectOfClassType(Expr *Object, SourceLocation LParenLoc,
|
BuildCallToObjectOfClassType(Expr *Object, SourceLocation LParenLoc,
|
||||||
|
|
|
@ -1295,12 +1295,16 @@ ActOnCallExpr(ExprTy *fn, SourceLocation LParenLoc,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ovl) {
|
if (Ovl) {
|
||||||
Fn = ResolveOverloadedCallFn(Fn, Ovl, LParenLoc, Args, NumArgs, CommaLocs,
|
FDecl = ResolveOverloadedCallFn(Fn, Ovl, LParenLoc, Args, NumArgs, CommaLocs,
|
||||||
RParenLoc);
|
RParenLoc);
|
||||||
if (!Fn)
|
if (!FDecl)
|
||||||
return true;
|
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())
|
if (getLangOptions().CPlusPlus && Fn->getType()->isRecordType())
|
||||||
|
|
|
@ -2967,24 +2967,20 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
|
||||||
/// (which eventually refers to the set of overloaded functions in
|
/// (which eventually refers to the set of overloaded functions in
|
||||||
/// Ovl) and the call arguments Args/NumArgs, attempt to resolve the
|
/// Ovl) and the call arguments Args/NumArgs, attempt to resolve the
|
||||||
/// function call down to a specific function. If overload resolution
|
/// function call down to a specific function. If overload resolution
|
||||||
/// succeeds, returns an expression that refers to a specific function
|
/// succeeds, returns the function declaration produced by overload
|
||||||
/// and deletes Fn. Otherwise, emits diagnostics, deletes all of the
|
/// resolution. Otherwise, emits diagnostics, deletes all of the
|
||||||
/// arguments and Fn, and returns NULL.
|
/// arguments and Fn, and returns NULL.
|
||||||
Expr *Sema::ResolveOverloadedCallFn(Expr *Fn, OverloadedFunctionDecl *Ovl,
|
FunctionDecl *Sema::ResolveOverloadedCallFn(Expr *Fn, OverloadedFunctionDecl *Ovl,
|
||||||
SourceLocation LParenLoc,
|
SourceLocation LParenLoc,
|
||||||
Expr **Args, unsigned NumArgs,
|
Expr **Args, unsigned NumArgs,
|
||||||
SourceLocation *CommaLocs,
|
SourceLocation *CommaLocs,
|
||||||
SourceLocation RParenLoc) {
|
SourceLocation RParenLoc) {
|
||||||
OverloadCandidateSet CandidateSet;
|
OverloadCandidateSet CandidateSet;
|
||||||
AddOverloadCandidates(Ovl, Args, NumArgs, CandidateSet);
|
AddOverloadCandidates(Ovl, Args, NumArgs, CandidateSet);
|
||||||
OverloadCandidateSet::iterator Best;
|
OverloadCandidateSet::iterator Best;
|
||||||
switch (BestViableFunction(CandidateSet, Best)) {
|
switch (BestViableFunction(CandidateSet, Best)) {
|
||||||
case OR_Success: {
|
case OR_Success:
|
||||||
Expr *NewFn = new DeclRefExpr(Best->Function, Best->Function->getType(),
|
return Best->Function;
|
||||||
Fn->getSourceRange().getBegin());
|
|
||||||
Fn->Destroy(Context);
|
|
||||||
return NewFn;
|
|
||||||
}
|
|
||||||
|
|
||||||
case OR_No_Viable_Function:
|
case OR_No_Viable_Function:
|
||||||
Diag(Fn->getSourceRange().getBegin(),
|
Diag(Fn->getSourceRange().getBegin(),
|
||||||
|
|
Loading…
Reference in New Issue