forked from OSchip/llvm-project
Handle overload resolution when calling an overloaded function set
with, e.g., (&f)(a, b, c). Fixes PR8013. llvm-svn: 118508
This commit is contained in:
parent
d7e3b54635
commit
8f225bb508
|
@ -3306,6 +3306,10 @@ void Sema::CodeCompleteCall(Scope *S, ExprTy *FnIn,
|
|||
llvm::SmallVector<ResultCandidate, 8> Results;
|
||||
|
||||
Expr *NakedFn = Fn->IgnoreParenCasts();
|
||||
if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn))
|
||||
if (UnOp->getOpcode() == UO_AddrOf)
|
||||
NakedFn = UnOp->getSubExpr()->IgnoreParens();
|
||||
|
||||
if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
|
||||
AddOverloadedCallCandidates(ULE, Args, NumArgs, CandidateSet,
|
||||
/*PartialOverloading=*/ true);
|
||||
|
|
|
@ -3781,17 +3781,15 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
|
|||
// lookup and whether there were any explicitly-specified template arguments.
|
||||
|
||||
Expr *NakedFn = Fn->IgnoreParens();
|
||||
if (isa<UnresolvedLookupExpr>(NakedFn)) {
|
||||
UnresolvedLookupExpr *ULE = cast<UnresolvedLookupExpr>(NakedFn);
|
||||
return BuildOverloadedCallExpr(S, Fn, ULE, LParenLoc, Args, NumArgs,
|
||||
RParenLoc);
|
||||
}
|
||||
|
||||
NamedDecl *NDecl = 0;
|
||||
if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn))
|
||||
if (UnOp->getOpcode() == UO_AddrOf)
|
||||
NakedFn = UnOp->getSubExpr()->IgnoreParens();
|
||||
|
||||
if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
|
||||
return BuildOverloadedCallExpr(S, Fn, ULE, LParenLoc, Args, NumArgs,
|
||||
RParenLoc);
|
||||
|
||||
if (isa<DeclRefExpr>(NakedFn))
|
||||
NDecl = cast<DeclRefExpr>(NakedFn)->getDecl();
|
||||
|
||||
|
|
|
@ -17,12 +17,14 @@ void f();
|
|||
|
||||
void test() {
|
||||
f(Y(), 0, 0);
|
||||
// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CC1 %s
|
||||
(&f)(Y(), 0, 0);
|
||||
// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
|
||||
// CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
|
||||
// CHECK-CC1: f(N::Y y, <#int ZZ#>)
|
||||
// CHECK-CC1-NEXT: f(int i, <#int j#>, int k)
|
||||
// CHECK-CC1-NEXT: f(float x, <#float y#>)
|
||||
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CC2 %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
|
||||
// CHECK-CC2-NOT: f(N::Y y, int ZZ)
|
||||
// CHECK-CC2: f(int i, int j, <#int k#>)
|
||||
}
|
||||
// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:20:16 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
|
||||
|
|
|
@ -503,3 +503,11 @@ namespace rdar8499524 {
|
|||
g(W());
|
||||
}
|
||||
}
|
||||
|
||||
namespace PR8013 {
|
||||
void f(int,int);
|
||||
void f(int,int,int);
|
||||
void g() {
|
||||
(&f)(1,2,3);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue