[cfe-dev] Templates (again)

Douglas Gregor dgregor at apple.com
Tue Dec 23 18:57:26 PST 2008


On Dec 23, 2008, at 10:45 AM, Douglas Gregor wrote:
> I actually have a partial patch (that includes a TemplateDecl that's
> surprisingly similar to yours <g>) which starts to deal with some of
> the AST nodes and parser state for template parameter lists. It might
> answer the question you have in the ActOnTemplateTemplateParameter
> FIXME about the "signature" of the template template parameter. I'll
> try to commit the non-TemplateDecl parts of that tonight, so you don't
> have to re-invent it (and we don't conflict).


This is in the tree now. Basically, we keep track of the template  
parameter lists that we've parsed and then provide those to the  
various Action routines that will end up constructing templates, e.g.,  
ActOnTag for creating class templates (but not enum templates <g>).

The Depth/Position stuff is working toward a fix in the type system.  
Basically, template parameters in the type system will be identified  
by their kind, depth (= the number of enclosing template parameter  
lists), and position with in that template parameter list. For  
example, 'T' in

	template<typename T> void foo(T);

is a template type parameter with depth=0 and position=0. That's the  
canonical type for 'T', and we'll use some sugar to give it the name  
'T'. That way, we can quickly match the declaration above with the  
definition below

	template<class U> void foo(U) { }

	- Doug



More information about the cfe-dev mailing list