aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-12-22 21:19:48 +0000
committerDouglas Gregor <dgregor@apple.com>2010-12-22 21:19:48 +0000
commite02e26293cf8e3bad1059b39cea75c6582896da6 (patch)
treee7e1852ce7aeaea89a2db8f5bdcbf2c2f07c41c3 /lib/Sema/SemaTemplateInstantiateDecl.cpp
parente6913d385e2401f4f680b7ae1ca3bf360879c786 (diff)
Implement template argument deduction for pack expansions whose
pattern is a template argument, which involves repeatedly deducing template arguments using the pattern of the pack expansion, then bundling the resulting deductions into an argument pack. We can now handle a variety of simple list-handling metaprograms using variadic templates. See, e.g., the new "count" metaprogram. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122439 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp25
1 files changed, 7 insertions, 18 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 115cdc4545..54c509544f 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1095,13 +1095,9 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D,
// Instantiate the explicit template arguments.
TemplateArgumentListInfo ExplicitArgs(Info->getLAngleLoc(),
Info->getRAngleLoc());
- for (unsigned I = 0, E = Info->getNumTemplateArgs(); I != E; ++I) {
- TemplateArgumentLoc Loc;
- if (SemaRef.Subst(Info->getTemplateArg(I), Loc, TemplateArgs))
- return 0;
-
- ExplicitArgs.addArgument(Loc);
- }
+ if (SemaRef.Subst(Info->getTemplateArgs(), Info->getNumTemplateArgs(),
+ ExplicitArgs, TemplateArgs))
+ return 0;
// Map the candidate templates to their instantiations.
for (unsigned I = 0, E = Info->getNumTemplates(); I != E; ++I) {
@@ -1791,19 +1787,12 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization(
// Substitute into the template arguments of the class template partial
// specialization.
- const TemplateArgumentLoc *PartialSpecTemplateArgs
- = PartialSpec->getTemplateArgsAsWritten();
- unsigned N = PartialSpec->getNumTemplateArgsAsWritten();
-
TemplateArgumentListInfo InstTemplateArgs; // no angle locations
- for (unsigned I = 0; I != N; ++I) {
- TemplateArgumentLoc Loc;
- if (SemaRef.Subst(PartialSpecTemplateArgs[I], Loc, TemplateArgs))
- return 0;
- InstTemplateArgs.addArgument(Loc);
- }
+ if (SemaRef.Subst(PartialSpec->getTemplateArgsAsWritten(),
+ PartialSpec->getNumTemplateArgsAsWritten(),
+ InstTemplateArgs, TemplateArgs))
+ return 0;
-
// Check that the template argument list is well-formed for this
// class template.
llvm::SmallVector<TemplateArgument, 4> Converted;