summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-11-17 07:50:12 +0000
committerJohn McCall <rjmccall@apple.com>2009-11-17 07:50:12 +0000
commitf0f1cf087e704ed2c8592669399a837f7c5308b1 (patch)
treec9e85bc86d5454c447bbfb6b8b755440c7559421 /clang/lib/Sema/SemaOverload.cpp
parentf19f251523f990a8a24266112a256c57eee16b50 (diff)
downloadbcm5719-llvm-f0f1cf087e704ed2c8592669399a837f7c5308b1.tar.gz
bcm5719-llvm-f0f1cf087e704ed2c8592669399a837f7c5308b1.zip
Store "sugared" decls in LookupResults (i.e. decl aliases like using declarations);
strip the sugar off in getFoundDecl() and getAsSingleDecl(), but leave it on for clients like overload resolution who want to use the iterators. Refactor a few pieces of overload resolution to strip off using declarations in a single place. Don't do anything useful with the extra context knowledge yet. llvm-svn: 89061
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp56
1 files changed, 32 insertions, 24 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 804a5fc87c4..cae75160123 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -2367,6 +2367,33 @@ void Sema::AddFunctionCandidates(const FunctionSet &Functions,
}
}
+/// AddMethodCandidate - Adds a named decl (which is some kind of
+/// method) as a method candidate to the given overload set.
+void Sema::AddMethodCandidate(NamedDecl *Decl, Expr *Object,
+ Expr **Args, unsigned NumArgs,
+ OverloadCandidateSet& CandidateSet,
+ bool SuppressUserConversions, bool ForceRValue) {
+
+ // FIXME: use this
+ //DeclContext *ActingContext = Decl->getDeclContext();
+
+ if (isa<UsingShadowDecl>(Decl))
+ Decl = cast<UsingShadowDecl>(Decl)->getTargetDecl();
+
+ if (FunctionTemplateDecl *TD = dyn_cast<FunctionTemplateDecl>(Decl)) {
+ assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
+ "Expected a member function template");
+ AddMethodTemplateCandidate(TD, false, 0, 0,
+ Object, Args, NumArgs,
+ CandidateSet,
+ SuppressUserConversions,
+ ForceRValue);
+ } else {
+ AddMethodCandidate(cast<CXXMethodDecl>(Decl), Object, Args, NumArgs,
+ CandidateSet, SuppressUserConversions, ForceRValue);
+ }
+}
+
/// AddMethodCandidate - Adds the given C++ member function to the set
/// of candidate functions, using the given function call arguments
/// and the object argument (@c Object). For example, in a call
@@ -2840,21 +2867,9 @@ void Sema::AddMemberOperatorCandidates(OverloadedOperatorKind Op,
for (LookupResult::iterator Oper = Operators.begin(),
OperEnd = Operators.end();
Oper != OperEnd;
- ++Oper) {
- if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(*Oper)) {
- AddMethodCandidate(Method, Args[0], Args+1, NumArgs - 1, CandidateSet,
- /*SuppressUserConversions=*/false);
- continue;
- }
-
- assert(isa<FunctionTemplateDecl>(*Oper) &&
- isa<CXXMethodDecl>(cast<FunctionTemplateDecl>(*Oper)
- ->getTemplatedDecl()) &&
- "Expected a member function template");
- AddMethodTemplateCandidate(cast<FunctionTemplateDecl>(*Oper), false, 0, 0,
- Args[0], Args+1, NumArgs - 1, CandidateSet,
- /*SuppressUserConversions=*/false);
- }
+ ++Oper)
+ AddMethodCandidate(*Oper, Args[0], Args + 1, NumArgs - 1, CandidateSet,
+ /* SuppressUserConversions = */ false);
}
}
@@ -5267,15 +5282,8 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
for (LookupResult::iterator Oper = R.begin(), OperEnd = R.end();
Oper != OperEnd; ++Oper) {
- if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(*Oper)) {
- AddMethodTemplateCandidate(FunTmpl, false, 0, 0, Object, Args, NumArgs,
- CandidateSet,
- /*SuppressUserConversions=*/false);
- continue;
- }
-
- AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Object, Args, NumArgs,
- CandidateSet, /*SuppressUserConversions=*/false);
+ AddMethodCandidate(*Oper, Object, Args, NumArgs, CandidateSet,
+ /*SuppressUserConversions=*/ false);
}
// C++ [over.call.object]p2:
OpenPOWER on IntegriCloud