aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-01-26 07:37:41 +0000
committerJohn McCall <rjmccall@apple.com>2010-01-26 07:37:41 +0000
commit75345163535eb1765ba8fb971974be895645cb45 (patch)
tree70bf3a1e323b9768ef3de6e8b41f2bac8ac2dbe1 /lib/Sema/SemaOverload.cpp
parent7edb5fdf9703e1abd780417db691b77d5fcbc610 (diff)
Avoid some unnecessary copying of unresolved lookup results.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94531 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r--lib/Sema/SemaOverload.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 0fba0c6228..47a7d17519 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -4903,36 +4903,34 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
bool HasExplicitTemplateArgs = false;
TemplateArgumentListInfo ExplicitTemplateArgs;
-
- llvm::SmallVector<NamedDecl*,8> Fns;
+ const UnresolvedSetImpl *Fns;
// Look into the overloaded expression.
if (UnresolvedLookupExpr *UL
= dyn_cast<UnresolvedLookupExpr>(OvlExpr)) {
- Fns.append(UL->decls_begin(), UL->decls_end());
+ Fns = &UL->getDecls();
if (UL->hasExplicitTemplateArgs()) {
HasExplicitTemplateArgs = true;
UL->copyTemplateArgumentsInto(ExplicitTemplateArgs);
}
} else if (UnresolvedMemberExpr *ME
= dyn_cast<UnresolvedMemberExpr>(OvlExpr)) {
- Fns.append(ME->decls_begin(), ME->decls_end());
+ Fns = &ME->getDecls();
if (ME->hasExplicitTemplateArgs()) {
HasExplicitTemplateArgs = true;
ME->copyTemplateArgumentsInto(ExplicitTemplateArgs);
}
- }
+ } else return 0;
// If we didn't actually find anything, we're done.
- if (Fns.empty())
+ if (Fns->empty())
return 0;
// Look through all of the overloaded functions, searching for one
// whose type matches exactly.
llvm::SmallPtrSet<FunctionDecl *, 4> Matches;
bool FoundNonTemplateFunction = false;
- for (llvm::SmallVectorImpl<NamedDecl*>::iterator I = Fns.begin(),
- E = Fns.end(); I != E; ++I) {
+ for (UnresolvedSetIterator I = Fns->begin(), E = Fns->end(); I != E; ++I) {
// Look through any using declarations to find the underlying function.
NamedDecl *Fn = (*I)->getUnderlyingDecl();
@@ -5088,35 +5086,33 @@ FunctionDecl *Sema::ResolveSingleFunctionTemplateSpecialization(Expr *From) {
bool HasExplicitTemplateArgs = false;
TemplateArgumentListInfo ExplicitTemplateArgs;
-
- llvm::SmallVector<NamedDecl*,8> Fns;
+ const UnresolvedSetImpl *Fns;
// Look into the overloaded expression.
if (UnresolvedLookupExpr *UL
= dyn_cast<UnresolvedLookupExpr>(OvlExpr)) {
- Fns.append(UL->decls_begin(), UL->decls_end());
+ Fns = &UL->getDecls();
if (UL->hasExplicitTemplateArgs()) {
HasExplicitTemplateArgs = true;
UL->copyTemplateArgumentsInto(ExplicitTemplateArgs);
}
} else if (UnresolvedMemberExpr *ME
= dyn_cast<UnresolvedMemberExpr>(OvlExpr)) {
- Fns.append(ME->decls_begin(), ME->decls_end());
+ Fns = &ME->getDecls();
if (ME->hasExplicitTemplateArgs()) {
HasExplicitTemplateArgs = true;
ME->copyTemplateArgumentsInto(ExplicitTemplateArgs);
}
- }
+ } else return 0;
// If we didn't actually find any template-ids, we're done.
- if (Fns.empty() || !HasExplicitTemplateArgs)
+ if (Fns->empty() || !HasExplicitTemplateArgs)
return 0;
// Look through all of the overloaded functions, searching for one
// whose type matches exactly.
FunctionDecl *Matched = 0;
- for (llvm::SmallVectorImpl<NamedDecl*>::iterator I = Fns.begin(),
- E = Fns.end(); I != E; ++I) {
+ for (UnresolvedSetIterator I = Fns->begin(), E = Fns->end(); I != E; ++I) {
// C++0x [temp.arg.explicit]p3:
// [...] In contexts where deduction is done and fails, or in contexts
// where deduction is not done, if a template argument list is