Getting template arguments (as written) from a function template specialization.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting template arguments (as written) from a function template specialization.

Enea Zaffanella
Hello.

We would like to retrieve a TemplateArgumentListInfo (or equivalent
information) from a FunctionDecl node representing an explicit function
template specialization.

The FunctionTemplateSpecializationInfo structure only encodes the
semantic form of the template arguments, i.e., a TemplateArgumentList*.
Would it be OK to also add a TemplateArgumentListInfo*?

We noted that FunctionTemplateSpecializationInfo are profiled.
As far as we understand, the new data member should not be used in the
profiling step. (Correct?)

If the proposal above is OK, then probably all we will need to do in
this first step is to modify calls to function
    FunctionDecl::setFunctionTemplateSpecialization()
inside
    Sema::CheckFunctionTemplateSpecialization()

In a second step, we will consider whether or not a similar change is
required when building explicit instantiations of function templates
(rather than specializations) ... things should not be much different.
Are there other issues we may be missing?

Regards,
Enea.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting template arguments (as written) from a function template specialization.

Douglas Gregor
Hello Enea,

On May 20, 2010, at 7:12 AM, Enea Zaffanella wrote:

> Hello.
>
> We would like to retrieve a TemplateArgumentListInfo (or equivalent
> information) from a FunctionDecl node representing an explicit function
> template specialization.
>
> The FunctionTemplateSpecializationInfo structure only encodes the
> semantic form of the template arguments, i.e., a TemplateArgumentList*.

Right.

> Would it be OK to also add a TemplateArgumentListInfo*?

Yes!

> We noted that FunctionTemplateSpecializationInfo are profiled.
> As far as we understand, the new data member should not be used in the
> profiling step. (Correct?)

Correct. The spelling of the arguments does not affect the semantics.

> If the proposal above is OK, then probably all we will need to do in
> this first step is to modify calls to function
>    FunctionDecl::setFunctionTemplateSpecialization()
> inside
>    Sema::CheckFunctionTemplateSpecialization()

Correct.

> In a second step, we will consider whether or not a similar change is
> required when building explicit instantiations of function templates
> (rather than specializations) ... things should not be much different.

It should be very similar.

> Are there other issues we may be missing?

IIRC, we don't keep track of all of the function template specializations or explicit instantiations that occur for a given function template with a given set of template arguments within a DeclContext, so there might be more work to do to ensure that all of the specializations and instantiations show up. For example, our -ast-dump output for

  template<typename T> void f(T);
  template<> void f<int>(int);
  template<> void f(int);
  template void f(int)

is fairly sparse :)

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting template arguments (as written) from a function template specialization.

Abramo Bagnara-2
Il 20/05/2010 17:02, Douglas Gregor ha scritto:

> Hello Enea,
>
> On May 20, 2010, at 7:12 AM, Enea Zaffanella wrote:
>
>> Hello.
>>
>> We would like to retrieve a TemplateArgumentListInfo (or equivalent
>> information) from a FunctionDecl node representing an explicit function
>> template specialization.
>>
>> The FunctionTemplateSpecializationInfo structure only encodes the
>> semantic form of the template arguments, i.e., a TemplateArgumentList*.
>
> Right.
>
>> Would it be OK to also add a TemplateArgumentListInfo*?
>
> Yes!

Just committed in r104226.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev