Add the ability to clone integer and string literals. Use it when instantiating template expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67030 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 6647945..a357ae7 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -1867,6 +1867,14 @@
                            ClassTemplateSpecializationDecl *ClassTemplateSpec,
                            bool ExplicitInstantiation);
 
+  // Simple function for cloning expressions.
+  template<typename T> 
+  OwningExprResult Clone(T *E) {
+    assert(!E->isValueDependent() && !E->isTypeDependent() &&
+           "expression is value or type dependent!");
+    return Owned(E->Clone(Context));
+  }
+  
   // Objective-C declarations.
   virtual DeclTy *ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
                                            IdentifierInfo *ClassName,
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 9126d2a..7b2d24b 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -591,7 +591,8 @@
     OwningExprResult VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E);
 
     // Base case. I'm supposed to ignore this.
-    Sema::OwningExprResult VisitStmt(Stmt *) { 
+    Sema::OwningExprResult VisitStmt(Stmt *S) { 
+      S->dump();
       assert(false && "Cannot instantiate this kind of expression");
       return SemaRef.ExprError(); 
     }
@@ -600,10 +601,7 @@
 
 Sema::OwningExprResult 
 TemplateExprInstantiator::VisitIntegerLiteral(IntegerLiteral *E) {
-  // FIXME: Can't we just re-use the expression node?
-  return SemaRef.Owned(new (SemaRef.Context) IntegerLiteral(E->getValue(), 
-                                                            E->getType(),
-                                                            E->getLocation()));
+  return SemaRef.Clone(E);
 }
 
 Sema::OwningExprResult