Template instantiation for "typeof" for both types and expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72440 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 3c32a21..86e6999 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -414,17 +414,22 @@
 QualType 
 TemplateTypeInstantiator::InstantiateTypeOfExprType(const TypeOfExprType *T,
                                                     unsigned Quals) const {
-  // FIXME: Implement this
-  assert(false && "Cannot instantiate TypeOfExprType yet");
-  return QualType();
+  Sema::OwningExprResult E 
+    = SemaRef.InstantiateExpr(T->getUnderlyingExpr(), TemplateArgs);
+  if (E.isInvalid())
+    return QualType();
+
+  return SemaRef.Context.getTypeOfExprType(E.takeAs<Expr>());
 }
 
 QualType 
 TemplateTypeInstantiator::InstantiateTypeOfType(const TypeOfType *T,
                                                 unsigned Quals) const {
-  // FIXME: Implement this
-  assert(false && "Cannot instantiate TypeOfType yet");
-  return QualType();
+  QualType Underlying = Instantiate(T->getUnderlyingType());
+  if (Underlying.isNull())
+    return QualType();
+
+  return SemaRef.Context.getTypeOfType(Underlying);
 }
 
 QualType 
diff --git a/lib/Sema/SemaTemplateInstantiateExpr.cpp b/lib/Sema/SemaTemplateInstantiateExpr.cpp
index 0c29839..9dc14d5 100644
--- a/lib/Sema/SemaTemplateInstantiateExpr.cpp
+++ b/lib/Sema/SemaTemplateInstantiateExpr.cpp
@@ -138,9 +138,15 @@
     else
       assert(false && 
              "FIXME: instantiation of non-local variable declarations");
-  } else if (isa<FunctionDecl>(D) || isa<OverloadedFunctionDecl>(D)) {
+  } else if (isa<FunctionDecl>(D)) {
     // FIXME: Instantiate decl!
     NewD = cast<ValueDecl>(D);
+  } else if (isa<OverloadedFunctionDecl>(D)) {
+    // FIXME: instantiate decls?
+    return SemaRef.Owned(new (SemaRef.Context) DeclRefExpr(cast<NamedDecl>(D),
+                                                   SemaRef.Context.OverloadTy,
+                                                           E->getLocation(),
+                                                           false, false));
   } else
     assert(false && "FIXME: unhandled declaration reference kind");