[cfe-commits] r74028 - in /cfe/trunk/lib/Sema: SemaDecl.cpp SemaTemplate.cpp
Douglas Gregor
dgregor at apple.com
Tue Jun 23 17:23:40 PDT 2009
Author: dgregor
Date: Tue Jun 23 19:23:40 2009
New Revision: 74028
URL: http://llvm.org/viewvc/llvm-project?rev=74028&view=rev
Log:
When declaring a function template, create a FunctionTemplateDecl node
and associate it with the FunctionDecl.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=74028&r1=74027&r2=74028&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jun 23 19:23:40 2009
@@ -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
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=74028&r1=74027&r2=74028&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Jun 23 19:23:40 2009
@@ -67,9 +67,10 @@
}
}
- // FIXME: What follows is a gross hack.
+ // FIXME: What follows is a slightly less gross hack than what used to
+ // follow.
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(IIDecl)) {
- if (FD->getType()->isDependentType()) {
+ if (FD->getDescribedFunctionTemplate()) {
TemplateResult = TemplateTy::make(FD);
return TNK_Function_template;
}
@@ -78,7 +79,7 @@
for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(),
FEnd = Ovl->function_end();
F != FEnd; ++F) {
- if ((*F)->getType()->isDependentType()) {
+ if ((*F)->getDescribedFunctionTemplate()) {
TemplateResult = TemplateTy::make(Ovl);
return TNK_Function_template;
}
More information about the cfe-commits
mailing list