Implement template instantiation for member class templates.

When performing template instantiation of the definitions of member
templates (or members thereof),  we build a data structure containing
the template arguments from each "level" of template
instantiation. During template instantiation, we substitute all levels
of template arguments simultaneously. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80389 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 4f9fcc3..2138557 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -25,13 +25,13 @@
     : public DeclVisitor<TemplateDeclInstantiator, Decl *> {
     Sema &SemaRef;
     DeclContext *Owner;
-    const TemplateArgumentList &TemplateArgs;
+    const MultiLevelTemplateArgumentList &TemplateArgs;
     
   public:
     typedef Sema::OwningExprResult OwningExprResult;
 
     TemplateDeclInstantiator(Sema &SemaRef, DeclContext *Owner,
-                             const TemplateArgumentList &TemplateArgs)
+                             const MultiLevelTemplateArgumentList &TemplateArgs)
       : SemaRef(SemaRef), Owner(Owner), TemplateArgs(TemplateArgs) { }
     
     // FIXME: Once we get closer to completion, replace these manually-written
@@ -457,8 +457,8 @@
   if (FunctionTemplate) {
     llvm::FoldingSetNodeID ID;
     FunctionTemplateSpecializationInfo::Profile(ID, 
-                                          TemplateArgs.getFlatArgumentList(),
-                                                TemplateArgs.flat_size(),
+                             TemplateArgs.getInnermost().getFlatArgumentList(),
+                                       TemplateArgs.getInnermost().flat_size(),
                                                 SemaRef.Context);
     
     FunctionTemplateSpecializationInfo *Info 
@@ -513,7 +513,7 @@
     // Record this function template specialization.
     Function->setFunctionTemplateSpecialization(SemaRef.Context,
                                                 FunctionTemplate,
-                                                &TemplateArgs,
+                                                &TemplateArgs.getInnermost(),
                                                 InsertPos);
   }
 
@@ -531,8 +531,8 @@
     // specialization for this particular set of template arguments.
     llvm::FoldingSetNodeID ID;
     FunctionTemplateSpecializationInfo::Profile(ID, 
-                                          TemplateArgs.getFlatArgumentList(),
-                                                TemplateArgs.flat_size(),
+                            TemplateArgs.getInnermost().getFlatArgumentList(),
+                                      TemplateArgs.getInnermost().flat_size(),
                                                 SemaRef.Context);
     
     FunctionTemplateSpecializationInfo *Info 
@@ -646,7 +646,7 @@
     // Record this function template specialization.
     Method->setFunctionTemplateSpecialization(SemaRef.Context,
                                               FunctionTemplate,
-                                              &TemplateArgs,
+                                              &TemplateArgs.getInnermost(),
                                               InsertPos);
   
   bool Redeclaration = false;
@@ -760,7 +760,7 @@
 }
 
 Decl *Sema::SubstDecl(Decl *D, DeclContext *Owner,
-                      const TemplateArgumentList &TemplateArgs) {
+                      const MultiLevelTemplateArgumentList &TemplateArgs) {
   TemplateDeclInstantiator Instantiator(*this, Owner, TemplateArgs);
   return Instantiator.Visit(D);
 }