Initial stab at a generalized operation for determining the
instantiation of a declaration from the template version (or version
that lives in a template) and a given set of template arguments. This
needs much, much more testing, but it suffices for simple examples
like

  typedef T* iterator;
  iterator begin();




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72461 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 86e6999..1cc9992 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -406,9 +406,13 @@
 QualType 
 TemplateTypeInstantiator::InstantiateTypedefType(const TypedefType *T,
                                                  unsigned Quals) const {
-  // FIXME: Implement this
-  assert(false && "Cannot instantiate TypedefType yet");
-  return QualType();
+  TypedefDecl *Typedef 
+    = cast_or_null<TypedefDecl>(SemaRef.InstantiateDeclRef(T->getDecl(), 
+                                                           TemplateArgs));
+  if (!Typedef)
+    return QualType();
+  
+  return SemaRef.Context.getTypeDeclType(Typedef);
 }
 
 QualType 
@@ -435,17 +439,25 @@
 QualType 
 TemplateTypeInstantiator::InstantiateRecordType(const RecordType *T,
                                                 unsigned Quals) const {
-  // FIXME: Implement this
-  assert(false && "Cannot instantiate RecordType yet");
-  return QualType();
+  RecordDecl *Record 
+    = cast_or_null<RecordDecl>(SemaRef.InstantiateDeclRef(T->getDecl(), 
+                                                          TemplateArgs));
+  if (!Record)
+    return QualType();
+  
+  return SemaRef.Context.getTypeDeclType(Record);
 }
 
 QualType 
 TemplateTypeInstantiator::InstantiateEnumType(const EnumType *T,
                                               unsigned Quals) const {
-  // FIXME: Implement this
-  assert(false && "Cannot instantiate EnumType yet");
-  return QualType();
+  EnumDecl *Enum 
+    = cast_or_null<EnumDecl>(SemaRef.InstantiateDeclRef(T->getDecl(), 
+                                                        TemplateArgs));
+  if (!Enum)
+    return QualType();
+  
+  return SemaRef.Context.getTypeDeclType(Enum);
 }
 
 QualType