[cfe-dev] Accessing number of template parameter for a record type

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Sun Dec 8 23:29:22 PST 2019


On Sat, 7 Dec 2019 at 00:12, Awanish Pandey via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Dear all,
>
> I want to access the number of parameters given to a template class during
> object creation in *collectTemplateParams*() ( in CGDebugInfo.cpp).
>
> Ex
> foo<int,>        a; // I want 1
> foo<int,char> b; // I want 2
> assuming *foo* is template class and its default parameters are <
> *char,char*>
>
> In  *collectTemplateParams*(), I can find actual number of parameters,
> which is after desugaring the *templateSpecialization* type.
>
> Is there any way that can give me the parameters count?
>

You're looking for the number of template arguments, not the number of
template parameters. You can find that by looking at
TemplateSpecializationType::getNumArgs() (prior to desugaring, which will
remove the difference between the types of a and b).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191208/2424f7aa/attachment.html>


More information about the cfe-dev mailing list