Teach PackExpansionExpr to keep track of the number of pack expansions
it will expand to, if known. Propagate this information throughout Sema.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123470 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateVariadic.cpp b/lib/Sema/SemaTemplateVariadic.cpp
index 899b58e..38a777e 100644
--- a/lib/Sema/SemaTemplateVariadic.cpp
+++ b/lib/Sema/SemaTemplateVariadic.cpp
@@ -415,6 +415,11 @@
 }
 
 ExprResult Sema::ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc) {
+  return CheckPackExpansion(Pattern, EllipsisLoc, llvm::Optional<unsigned>());
+}
+
+ExprResult Sema::CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
+                                    llvm::Optional<unsigned> NumExpansions) {
   if (!Pattern)
     return ExprError();
   
@@ -430,7 +435,7 @@
   
   // Create the pack expansion expression and source-location information.
   return Owned(new (Context) PackExpansionExpr(Context.DependentTy, Pattern,
-                                               EllipsisLoc));
+                                               EllipsisLoc, NumExpansions));
 }
 
 /// \brief Retrieve the depth and index of a parameter pack.
@@ -459,10 +464,6 @@
   std::pair<IdentifierInfo *, SourceLocation> FirstPack;
   bool HaveFirstPack = false;
   
-  // FIXME: Variadic templates. Even if we don't expand, we'd still like to
-  // return the number of expansions back to the caller, perhaps as an 
-  // llvm::Optional, so that it can be embedded in the pack expansion. This
-  // is important for the multi-level substitution case.
   for (unsigned I = 0; I != NumUnexpanded; ++I) {
     // Compute the depth and index for this parameter pack.
     unsigned Depth;