aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/TemplateBase.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-01-14 17:04:44 +0000
committerDouglas Gregor <dgregor@apple.com>2011-01-14 17:04:44 +0000
commitcded4f649cd4b7ba7d461c25c6482ef52b8d3a2a (patch)
tree886197b026701bb900caeca77c4135297c4b276a /lib/AST/TemplateBase.cpp
parent5576d9b0a389f6f1f89bdcd37194f4e992b1fbcb (diff)
Keep track of the number of expansions to be produced from a type pack
expansion, when it is known due to the substitution of an out parameter pack. This allows us to properly handle substitution into pack expansions that involve multiple parameter packs at different template parameter levels, even when this substitution happens one level at a time (as with partial specializations of member class templates and the signatures of member function templates). Note that the diagnostic we provide when there is an arity mismatch between an outer parameter pack and an inner parameter pack in this case isn't as clear as the normal diagnostic for an arity mismatch. However, this doesn't matter because these cases are very, very rare and (even then) only typically occur in a SFINAE context. The other kinds of pack expansions (expression, template, etc.) still need to support optional tracking of the number of expansions, and we need the moral equivalent of SubstTemplateTypeParmPackType for substituted argument packs of template template and non-type template parameters. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123448 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/TemplateBase.cpp')
-rw-r--r--lib/AST/TemplateBase.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp
index 42a936c500..f7c4ac832f 100644
--- a/lib/AST/TemplateBase.cpp
+++ b/lib/AST/TemplateBase.cpp
@@ -346,6 +346,7 @@ SourceRange TemplateArgumentLoc::getSourceRange() const {
TemplateArgumentLoc
TemplateArgumentLoc::getPackExpansionPattern(SourceLocation &Ellipsis,
+ llvm::Optional<unsigned> &NumExpansions,
ASTContext &Context) const {
assert(Argument.isPackExpansion());
@@ -363,6 +364,7 @@ TemplateArgumentLoc::getPackExpansionPattern(SourceLocation &Ellipsis,
Ellipsis = Expansion.getEllipsisLoc();
TypeLoc Pattern = Expansion.getPatternLoc();
+ NumExpansions = Expansion.getTypePtr()->getNumExpansions();
// FIXME: This is horrible. We know where the source location data is for
// the pattern, and we have the pattern's type, but we are forced to copy
@@ -382,10 +384,12 @@ TemplateArgumentLoc::getPackExpansionPattern(SourceLocation &Ellipsis,
= cast<PackExpansionExpr>(Argument.getAsExpr());
Expr *Pattern = Expansion->getPattern();
Ellipsis = Expansion->getEllipsisLoc();
+ // FIXME: Variadic templates num expansions
return TemplateArgumentLoc(Pattern, Pattern);
}
case TemplateArgument::TemplateExpansion:
+ // FIXME: Variadic templates num expansions
Ellipsis = getTemplateEllipsisLoc();
return TemplateArgumentLoc(Argument.getPackExpansionPattern(),
getTemplateQualifierRange(),