[cfe-dev] How can I get the template argument in a TypedefDecl ?

Manasij Mukherjee manasij7479 at gmail.com
Tue Aug 5 09:38:38 PDT 2014


Thanks, that seems to work.

Code for someone stumbling into this question later:

    if (const TemplateSpecializationType* tst
            =
dyn_cast<TemplateSpecializationType>(D->getTypeSourceInfo()->getType().getTypePtr())){
      for (uint i = 0; i < tst->getNumArgs(); ++i ) {
        const TemplateArgument& arg = tst->getArg(i);
        if (arg.getKind() == TemplateArgument::ArgKind::Type)
          std::string foo = arg.getAsType().getAsString();
      }



On Tue, Aug 5, 2014 at 9:03 PM, Yaron Keren <yaron.keren at gmail.com> wrote:

> I think you need to cast QT.getTypePtr() to a TemplateSpecializationType
> and then process its TemplateArguments.
>
>
>
> 2014-08-05 18:23 GMT+03:00 Manasij Mukherjee <manasij7479 at gmail.com>:
>
> That gives me "A<B> identifier".
>> (which could also be achieved with QT.getAsString(), afaik)
>>
>> I have the QualType for A<B>.
>> But I have to get "B" from this somehow.
>>
>> Sorry if I was ambiguous about that.
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140805/01e737c8/attachment.html>


More information about the cfe-dev mailing list