[cfe-dev] Templates (again)

Douglas Gregor dgregor at apple.com
Wed Feb 4 11:06:30 PST 2009


Hi Andy,

On Jan 1, 2009, at 11:20 AM, Andrew Sutton wrote:

>
> Is the TemplateDecl getting returned all the way through to  
> ParseExternalDeclaration? That's how declarations get back to the
>
> Knowing that helps a *lot*. Here's iteration n + 1. This starts to  
> add -ast-print support for class templates, but it doesn't print  
> template parameters just yet. You'll get "template <...> Read top- 
> level tag...".

Sorry for the *long* delay... it's about time for us to get rolling on  
templates, eh?

> Getting this to work is... not very pretty. It's actually pretty  
> tough to push the TemplateDecl all the way up to  
> ParseExternalDeclaration since, somewhere in the call sequence, the  
> created declaration node is wrapped in a DeclSpec (in  
> ParseDeclarationOrFunctionDefinition IIRC) and ActOnTag only returns  
> a TagDecl. I modified ActOnTag to return *either* a TagDecl or a  
> TemplateDecl. This has the unfortunate side-effect of requiring you  
> to think about DeclTy's in the Action interface as either a Tag or  
> Template. It's easy to get the Tag from the Template, but  
> unfortuntely you still have to perform the cast (so far only in 3  
> places). This also means that I'm setting the TypeRep of a DeclSpec  
> as a TemplateDecl, which may or may not have unseen consequences  
> down the road.

Hrm. I'm not thrilled with this, especially since it's only really  
there to make the TemplateDecl get up to ParseExternalDeclaration. I  
left off this part of the patch, which we can revisit later when we  
need it. DeclSpecs shouldn't refer to templates at all, and the  
DeclSpec itself won't even be used for anything.

> It's a big patch, but I tried to make it as unintrusive as possible.  
> Best of all, it doesn't cause any regressions on my system.

... and, after resolving all of the conflicts from a month of  
development, no regressions on my system, either. Yay!

I've committed this patch, here:

   http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090202/011754.html

Thanks!

   - Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090204/005a5f60/attachment.html>


More information about the cfe-dev mailing list