[cfe-dev] Getting template arguments (as written) from a function template specialization.
Douglas Gregor
dgregor at apple.com
Thu May 20 08:02:45 PDT 2010
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
More information about the cfe-dev
mailing list