[GCC-XML] template_origin for class templates

Brad King brad.king at kitware.com
Mon Mar 30 07:56:26 EDT 2009


Jochen Becher wrote:
> I need some more information about template classes than are currently
> written by gccxml: Each <Class/> which is an template instantiation
> should provide an attribute "template_origin" that links to the template
> it is created from.

This feature has been requested a few times.  The problem is that in order
to link to the template there must be a representation of the template
dumped.  Currently we do not dump uninstantiated templates.  Adding this
feature is non-trivial, is not necessary for my needs, and no one has
volunteered to do it.

> I added the following code to xml_output_record_type (from xml.c):
> 
>   {
>   tree tt = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (rt);
>   if (tt != rt)
>     {
>     int id = xml_add_node (xdi, tt, dn->complete);
>     fprintf (xdi->file, " template_origin=\"_%d\"", id);
>     }
>   }
> 
> 
> Unfortunately CLASSTYPE_PRIMARY_TEMPLATE_TYPE() always return the most
> general template. Is there any possibility to find out the type of the
> most specialized template? And to link from that specialized template to
> a more generalized template until the most generalized template is
> reached?

I'm not particularly familiar with the template representation inside GCC.
I don't know if you can directly get to the most-specialized template.
For compiling GCC needs only choose the most specialized template from
the template arguments and instantiate it.  There is no need AFAIK to go
the other way so the information may not be kept by their parser.  In
order to add this, one might have to patch the internals of GCC to keep
the information.

> BTW: what is the meaning of argument complete?

Whether or not to dump the complete type.  In some cases we do not
dump the entire interface of a type.  You'll have to dig into xml.c
to see when it passes complete=0.

-Brad




More information about the gccxml mailing list