Start processing template-ids as types when the template-name refers
to a class template. For example, the template-id 'vector<int>' now
has a nice, sugary type in the type system. What we can do now:

  - Parse template-ids like 'vector<int>' (where 'vector' names a
    class template) and form proper types for them in the type system.
  - Parse icky template-ids like 'A<5>' and 'A<(5 > 0)>' properly,
    using (sadly) a bool in the parser to tell it whether '>' should
    be treated as an operator or not.

This is a baby-step, with major problems and limitations:
  - There are currently two ways that we handle template arguments
  (whether they are types or expressions). These will be merged, and,
  most likely, TemplateArg will disappear.
  - We don't have any notion of the declaration of class template
  specializations or of template instantiations, so all template-ids
  are fancy names for 'int' :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64153 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index a87a902..72aef42 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1220,6 +1220,34 @@
   return QualType(TypeParm, 0);
 }
 
+QualType 
+ASTContext::getClassTemplateSpecializationType(TemplateDecl *Template,
+                                               unsigned NumArgs,
+                                               uintptr_t *Args, bool *ArgIsType,
+                                               QualType Canon) {
+  llvm::FoldingSetNodeID ID;
+  ClassTemplateSpecializationType::Profile(ID, Template, NumArgs, Args, 
+                                           ArgIsType);
+  void *InsertPos = 0;
+  ClassTemplateSpecializationType *Spec
+    = ClassTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos);
+
+  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);
+  Types.push_back(Spec);
+  ClassTemplateSpecializationTypes.InsertNode(Spec, InsertPos);
+
+  return QualType(Spec, 0);  
+}
+
 /// CmpProtocolNames - Comparison predicate for sorting protocols
 /// alphabetically.
 static bool CmpProtocolNames(const ObjCProtocolDecl *LHS,