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/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index e48ba15..4fbf2f6 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -359,6 +359,10 @@
 
   C.Deallocate(ParamInfo);
 
+  if (TemplateSpecializationInfo *Info 
+        = TemplateOrSpecialization.dyn_cast<TemplateSpecializationInfo*>())
+    C.Deallocate(Info);
+  
   Decl::Destroy(C);
 }
 
@@ -555,6 +559,20 @@
     return OO_None;
 }
 
+void 
+FunctionDecl::setFunctionTemplateSpecialization(ASTContext &Context,
+                                                FunctionTemplateDecl *Template,
+                                     const TemplateArgumentList *TemplateArgs) {
+  TemplateSpecializationInfo *Info 
+    = TemplateOrSpecialization.dyn_cast<TemplateSpecializationInfo*>();
+  if (!Info)
+    Info = new (Context) TemplateSpecializationInfo;
+  
+  Info->Template = Template;
+  Info->TemplateArguments = TemplateArgs;
+  TemplateOrSpecialization = Info;
+}
+
 //===----------------------------------------------------------------------===//
 // TagDecl Implementation
 //===----------------------------------------------------------------------===//