[cfe-commits] [Review request] Adding source location for the template keyword in AST template-id expressions.

Enea Zaffanella zaffanella at cs.unipr.it
Fri Jan 13 10:21:18 PST 2012


Ping.

Il 09/01/2012 18:32, Enea Zaffanella ha scritto:
> Hello.
> 
> The current AST representations for expression nodes that possibly
> include a template-id (namely, DeclRefExpr and MemberExpr, their
> DependentScope variants and their Unresolved variants) store source
> location info for:
>  - the name qualifier (NestedNameSpecifierLoc);
>  - the name (DeclarationNameInfo);
>  - the explicit template arguments (ASTTemplateArgumentListInfo).
> 
> What was missing is the source location of the (often optional,
> sometimes mandatory) template keyword that may occur between the name
> qualifier and the name itself.
> 
> We would appreciate if someone could review the attached (big, but not
> really complex) patch, which is meant to add this info so as to improve
> the source-code accuracy of the AST representation.
> 
> Below we summarize the relevant changes to help in the review process.
> Comments are welcome.
> 
> Enea
> 
> 
> 
> **** Changes in the AST nodes:
> 
> We extend ASTTemplateArgumentListInfo so as to allow for storing the
> additional source location of the template keyword (TemplateKWLoc).
> The new structure is called ASTTemplateKWAndArgsInfo and replaces the
> old one in all the expression nodes mentioned above.
> (Note: function template specializations keep using the old
> ASTTemplateArgumentListInfo structure).
> 
> In the expression nodes, the structure is allocated if the expression is
> provided with the template keyword OR the explicit template argument
> list; previously, it was not allocated if there was no explicit template
> argument list.
> 
> Other changes include: helper functions for querying the new location,
> support for its (de-)serialization, changes to the pretty printer to
> exploit the knowledge that there was a template keyword.
> 
> 
> **** Changes in Parse:
> 
>  - Added a TemplateKWLoc field to TemplateIdAnnotation;
>  - Modified ParseUnqualifiedId to also return the source location of the
> optionally parsed template keyword;
>  - Modified a few other Parse*Id* helpers and the relevant Sema::ActOn*
> routines to add TemplateKWLoc as an additional input argument;
> 
> 
> **** Changes in Sema:
> 
>  - Many (basically trivial) changes to Sema routines so as to propagate
> the new TemplateKWLoc input argument down to the code creating the
> relevant AST nodes. The new input argument has been kept on his own on
> purpose, since it is not really part of the name qualifier or the name
> itself. Also changed the relevant routines in TreeTransform.h so as to
> propagate the info on instantiation.



More information about the cfe-commits mailing list