diff options
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 82834057ee2..bba8216fa2b 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -6307,30 +6307,45 @@ void Sema::AddFunctionCandidates(const UnresolvedSetImpl &Fns, for (UnresolvedSetIterator F = Fns.begin(), E = Fns.end(); F != E; ++F) { NamedDecl *D = F.getDecl()->getUnderlyingDecl(); if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { - if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) + if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) { + QualType ObjectType; + Expr::Classification ObjectClassification; + if (Expr *E = Args[0]) { + // Use the explit base to restrict the lookup: + ObjectType = E->getType(); + ObjectClassification = E->Classify(Context); + } // .. else there is an implit base. AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(), - cast<CXXMethodDecl>(FD)->getParent(), - Args[0]->getType(), Args[0]->Classify(Context), - Args.slice(1), CandidateSet, SuppressUserConversions, - PartialOverloading); - else + cast<CXXMethodDecl>(FD)->getParent(), ObjectType, + ObjectClassification, Args.slice(1), CandidateSet, + SuppressUserConversions, PartialOverloading); + } else { AddOverloadCandidate(FD, F.getPair(), Args, CandidateSet, SuppressUserConversions, PartialOverloading); + } } else { FunctionTemplateDecl *FunTmpl = cast<FunctionTemplateDecl>(D); if (isa<CXXMethodDecl>(FunTmpl->getTemplatedDecl()) && - !cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl())->isStatic()) + !cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl())->isStatic()) { + QualType ObjectType; + Expr::Classification ObjectClassification; + if (Expr *E = Args[0]) { + // Use the explit base to restrict the lookup: + ObjectType = E->getType(); + ObjectClassification = E->Classify(Context); + } // .. else there is an implit base. AddMethodTemplateCandidate( FunTmpl, F.getPair(), cast<CXXRecordDecl>(FunTmpl->getDeclContext()), - ExplicitTemplateArgs, Args[0]->getType(), - Args[0]->Classify(Context), Args.slice(1), CandidateSet, - SuppressUserConversions, PartialOverloading); - else + ExplicitTemplateArgs, ObjectType, ObjectClassification, + Args.slice(1), CandidateSet, SuppressUserConversions, + PartialOverloading); + } else { AddTemplateOverloadCandidate(FunTmpl, F.getPair(), ExplicitTemplateArgs, Args, CandidateSet, SuppressUserConversions, PartialOverloading); + } } } } |