When declaring a function template, create a FunctionTemplateDecl node
and associate it with the FunctionDecl.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74028 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 10ab5c2..48d1d64 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2157,6 +2157,26 @@
   // from the semantic context.
   NewFD->setLexicalDeclContext(CurContext);
 
+  // If there is a template parameter list, then we are dealing with a 
+  // template declaration or specialization.
+  FunctionTemplateDecl *FunctionTemplate = 0;
+  if (TemplateParamLists.size()) {
+    // FIXME: member templates!
+    TemplateParameterList *TemplateParams 
+      = static_cast<TemplateParameterList *>(*TemplateParamLists.release());
+    
+    if (TemplateParams->size() > 0) {
+      // This is a function template
+      FunctionTemplate = FunctionTemplateDecl::Create(Context, CurContext,
+                                                      NewFD->getLocation(),
+                                                      Name, TemplateParams,
+                                                      NewFD);
+      NewFD->setDescribedFunctionTemplate(FunctionTemplate);
+    } else {
+      // FIXME: Handle function template specializations
+    }
+  }
+  
   // C++ [dcl.fct.spec]p5:
   //   The virtual specifier shall only be used in declarations of
   //   nonstatic class member functions that appear within a