aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateDeduction.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-02-02 06:20:04 +0000
committerJohn McCall <rjmccall@apple.com>2010-02-02 06:20:04 +0000
commit7bb12da2b0749eeebb21854c77877736969e59f2 (patch)
treed273884f33148292c07b9fdbb4dc11cc2459ed93 /lib/Sema/SemaTemplateDeduction.cpp
parentb217bcce1463db6d6a9c45f53b984af49ee35d03 (diff)
Extract a common base class between UnresolvedLookupExpr and
UnresolvedMemberExpr and employ it in a few places where it's useful. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95072 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp31
1 files changed, 8 insertions, 23 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index de13b664fe..984aa6bb61 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -1324,34 +1324,19 @@ static QualType GetTypeOfFunction(ASTContext &Context,
static QualType
ResolveOverloadForDeduction(Sema &S, TemplateParameterList *TemplateParams,
Expr *Arg, QualType ParamType) {
- bool isAddressOfOperand = false;
+ llvm::PointerIntPair<OverloadExpr*,1> R = OverloadExpr::find(Arg);
- Arg = Arg->IgnoreParens();
- if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
- assert(UnOp->getOpcode() == UnaryOperator::AddrOf);
- isAddressOfOperand = true;
- Arg = UnOp->getSubExpr()->IgnoreParens();
- }
-
- const UnresolvedSetImpl *Decls;
- bool HasExplicitArgs;
- if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Arg)) {
- Decls = &ULE->getDecls();
- HasExplicitArgs = ULE->hasExplicitTemplateArgs();
- } else {
- UnresolvedMemberExpr *UME = cast<UnresolvedMemberExpr>(Arg);
- Decls = &UME->getDecls();
- HasExplicitArgs = ULE->hasExplicitTemplateArgs();
- }
+ bool isAddressOfOperand = bool(R.getInt());
+ OverloadExpr *Ovl = R.getPointer();
// If there were explicit template arguments, we can only find
// something via C++ [temp.arg.explicit]p3, i.e. if the arguments
// unambiguously name a full specialization.
- if (HasExplicitArgs) {
+ if (Ovl->hasExplicitTemplateArgs()) {
// But we can still look for an explicit specialization.
if (FunctionDecl *ExplicitSpec
- = S.ResolveSingleFunctionTemplateSpecialization(Arg))
- return GetTypeOfFunction(S.Context, isAddressOfOperand, ExplicitSpec);
+ = S.ResolveSingleFunctionTemplateSpecialization(Ovl))
+ return GetTypeOfFunction(S.Context, isAddressOfOperand, ExplicitSpec);
return QualType();
}
@@ -1365,8 +1350,8 @@ ResolveOverloadForDeduction(Sema &S, TemplateParameterList *TemplateParams,
return QualType();
QualType Match;
- for (UnresolvedSetIterator I = Decls->begin(),
- E = Decls->end(); I != E; ++I) {
+ for (UnresolvedSetIterator I = Ovl->decls_begin(),
+ E = Ovl->decls_end(); I != E; ++I) {
NamedDecl *D = (*I)->getUnderlyingDecl();
// - If the argument is an overload set containing one or more