Implement template instantiation for ClassTemplateSpecializationTypes,
such as replacing 'T' in vector<T>. There are a few aspects to this:

  - Extend TemplateArgument to allow arbitrary expressions (an
    Expr*), and switch ClassTemplateSpecializationType to store
    TemplateArguments rather than it's own type-or-expression
    representation.

  - ClassTemplateSpecializationType can now store dependent types. In
    that case, the canonical type is another
    ClassTemplateSpecializationType (with default template arguments
    expanded) rather than a declaration (we don't build Decls for
    dependent types).

  - Split ActOnClassTemplateId into ActOnClassTemplateId (called from
    the parser) and CheckClassTemplateId (called from
    ActOnClassTemplateId and InstantiateType). They're smart enough to
    handle dependent types, now.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66509 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 4579fb5..a51f432 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1309,14 +1309,15 @@
 
 QualType 
 ASTContext::getClassTemplateSpecializationType(TemplateDecl *Template,
+                                               const TemplateArgument *Args,
                                                unsigned NumArgs,
-                                               uintptr_t *Args, bool *ArgIsType,
                                                QualType Canon) {
-  Canon = getCanonicalType(Canon);
+  if (!Canon.isNull())
+    Canon = getCanonicalType(Canon);
 
   llvm::FoldingSetNodeID ID;
-  ClassTemplateSpecializationType::Profile(ID, Template, NumArgs, Args, 
-                                           ArgIsType);
+  ClassTemplateSpecializationType::Profile(ID, Template, Args, NumArgs);
+
   void *InsertPos = 0;
   ClassTemplateSpecializationType *Spec
     = ClassTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos);
@@ -1324,13 +1325,11 @@
   if (Spec)
     return QualType(Spec, 0);
   
-  void *Mem = Allocate(sizeof(ClassTemplateSpecializationType) + 
-                       (sizeof(uintptr_t) * 
-                        (ClassTemplateSpecializationType::
-                           getNumPackedWords(NumArgs) + 
-                         NumArgs)), 8);
-  Spec = new (Mem) ClassTemplateSpecializationType(Template, NumArgs, Args,
-                                                   ArgIsType, Canon);
+  void *Mem = Allocate((sizeof(ClassTemplateSpecializationType) + 
+                        sizeof(TemplateArgument) * NumArgs),
+                       8);
+  Spec = new (Mem) ClassTemplateSpecializationType(Template, Args, NumArgs, 
+                                                   Canon);
   Types.push_back(Spec);
   ClassTemplateSpecializationTypes.InsertNode(Spec, InsertPos);