summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-25 21:45:23 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-25 21:45:23 +0000
commitd90fd526d31a73611bbdb34d5a5ac34c5668d507 (patch)
tree6e1f4fa6cfce2d546aa12a5c0215b92cf3552a51 /clang/lib/Sema/SemaTemplate.cpp
parentfd6aad7f1cfab3fa8a03ed2aa7fd79f09690aa12 (diff)
downloadbcm5719-llvm-d90fd526d31a73611bbdb34d5a5ac34c5668d507.tar.gz
bcm5719-llvm-d90fd526d31a73611bbdb34d5a5ac34c5668d507.zip
Declarators can now properly represent template-ids, e.g., for
template void f<int>(int); ~~~~~~ Previously, we silently dropped the template arguments. With this change, we now use the template arguments (when available) as the explicitly-specified template arguments used to aid template argument deduction for explicit template instantiations. llvm-svn: 82806
Diffstat (limited to 'clang/lib/Sema/SemaTemplate.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 37fbf453742..27e8edd9622 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3409,23 +3409,38 @@ Sema::DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
return DeclPtrTy();
}
+ // Translate the parser's template argument list in our AST format.
+ bool HasExplicitTemplateArgs = false;
+ llvm::SmallVector<TemplateArgument, 16> TemplateArgs;
+ if (D.getKind() == Declarator::DK_TemplateId) {
+ TemplateIdAnnotation *TemplateId = D.getTemplateId();
+ ASTTemplateArgsPtr TemplateArgsPtr(*this,
+ TemplateId->getTemplateArgs(),
+ TemplateId->getTemplateArgIsType(),
+ TemplateId->NumArgs);
+ translateTemplateArguments(TemplateArgsPtr,
+ TemplateId->getTemplateArgLocations(),
+ TemplateArgs);
+ HasExplicitTemplateArgs = true;
+ }
+
+
// C++ [temp.explicit]p1:
// A [...] function [...] can be explicitly instantiated from its template.
// A member function [...] of a class template can be explicitly
// instantiated from the member definition associated with its class
// template.
- // FIXME: Implement this!
llvm::SmallVector<FunctionDecl *, 8> Matches;
for (LookupResult::iterator P = Previous.begin(), PEnd = Previous.end();
P != PEnd; ++P) {
NamedDecl *Prev = *P;
- if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
- // FIXME: If there were any explicitly-specified template arguments,
- // don't look for Method declarations.
- if (Context.hasSameUnqualifiedType(Method->getType(), R)) {
- Matches.clear();
- Matches.push_back(Method);
- break;
+ if (!HasExplicitTemplateArgs) {
+ if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
+ if (Context.hasSameUnqualifiedType(Method->getType(), R)) {
+ Matches.clear();
+ Matches.push_back(Method);
+ break;
+ }
}
}
@@ -3436,7 +3451,8 @@ Sema::DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
TemplateDeductionInfo Info(Context);
FunctionDecl *Specialization = 0;
if (TemplateDeductionResult TDK
- = DeduceTemplateArguments(FunTmpl, /*FIXME:*/false, 0, 0,
+ = DeduceTemplateArguments(FunTmpl, HasExplicitTemplateArgs,
+ TemplateArgs.data(), TemplateArgs.size(),
R, Specialization, Info)) {
// FIXME: Keep track of almost-matches?
(void)TDK;
OpenPOWER on IntegriCloud