summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp42
1 files changed, 19 insertions, 23 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 1957d7ff11b..99f9f55249e 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -1525,33 +1525,29 @@ Sema::FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
// in which the function or function template is defined and the
// classes and namespaces associated with its (non-dependent)
// parameter types and return type.
- DeclRefExpr *DRE = 0;
- TemplateIdRefExpr *TIRE = 0;
Arg = Arg->IgnoreParens();
- if (UnaryOperator *unaryOp = dyn_cast<UnaryOperator>(Arg)) {
- if (unaryOp->getOpcode() == UnaryOperator::AddrOf) {
- DRE = dyn_cast<DeclRefExpr>(unaryOp->getSubExpr());
- TIRE = dyn_cast<TemplateIdRefExpr>(unaryOp->getSubExpr());
- }
- } else {
- DRE = dyn_cast<DeclRefExpr>(Arg);
- TIRE = dyn_cast<TemplateIdRefExpr>(Arg);
- }
-
- OverloadedFunctionDecl *Ovl = 0;
- if (DRE)
- Ovl = dyn_cast<OverloadedFunctionDecl>(DRE->getDecl());
- else if (TIRE)
- Ovl = TIRE->getTemplateName().getAsOverloadedFunctionDecl();
- if (!Ovl)
+ if (UnaryOperator *unaryOp = dyn_cast<UnaryOperator>(Arg))
+ if (unaryOp->getOpcode() == UnaryOperator::AddrOf)
+ Arg = unaryOp->getSubExpr();
+
+ // TODO: avoid the copies. This should be easy when the cases
+ // share a storage implementation.
+ llvm::SmallVector<NamedDecl*, 8> Functions;
+
+ if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Arg))
+ Functions.append(ULE->decls_begin(), ULE->decls_end());
+ else if (TemplateIdRefExpr *TIRE = dyn_cast<TemplateIdRefExpr>(Arg)) {
+ TemplateName TName = TIRE->getTemplateName();
+ OverloadedFunctionDecl *Ovl = TName.getAsOverloadedFunctionDecl();
+ Functions.append(Ovl->function_begin(), Ovl->function_end());
+ } else
continue;
- for (OverloadedFunctionDecl::function_iterator Func = Ovl->function_begin(),
- FuncEnd = Ovl->function_end();
- Func != FuncEnd; ++Func) {
- FunctionDecl *FDecl = dyn_cast<FunctionDecl>(*Func);
+ for (llvm::SmallVectorImpl<NamedDecl*>::iterator I = Functions.begin(),
+ E = Functions.end(); I != E; ++I) {
+ FunctionDecl *FDecl = dyn_cast<FunctionDecl>(*I);
if (!FDecl)
- FDecl = cast<FunctionTemplateDecl>(*Func)->getTemplatedDecl();
+ FDecl = cast<FunctionTemplateDecl>(*I)->getTemplatedDecl();
// Add the namespace in which this function was defined. Note
// that, if this is a member function, we do *not* consider the
OpenPOWER on IntegriCloud