Implicit instantiation for function template specializations.

For a FunctionDecl that has been instantiated due to template argument
deduction, we now store the primary template from which it was
instantiated and the deduced template arguments. From this
information, we can instantiate the body of the function template.

llvm-svn: 74232
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 95655d8..a05095f 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -645,16 +645,17 @@
 /// function.
 void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
                                          FunctionDecl *Function) {
-  // FIXME: make this work for function template specializations, too.
-
   if (Function->isInvalidDecl())
     return;
 
   assert(!Function->getBody(Context) && "Already instantiated!");
   
   // Find the function body that we'll be substituting.
-  const FunctionDecl *PatternDecl 
-    = Function->getInstantiatedFromMemberFunction();
+  const FunctionDecl *PatternDecl = 0;
+  if (FunctionTemplateDecl *Primary = Function->getPrimaryTemplate())
+    PatternDecl = Primary->getTemplatedDecl();
+  else 
+    PatternDecl = Function->getInstantiatedFromMemberFunction();
   Stmt *Pattern = 0;
   if (PatternDecl)
     Pattern = PatternDecl->getBody(Context, PatternDecl);