[cfe-dev] How to get the template argument type from AST matcher?
Jason Haslam
jason.haslam at gmail.com
Mon Jul 20 00:14:48 PDT 2015
Call the version of getAsString that takes a PrintingPolicy with the SuppressTagKeyword field set. Something like:
PrintingPolicy pp;
pp.SuppressTagKeyword = true;
type.getAsString(pp);
Jason
> On Jul 17, 2015, at 10:45 AM, Han Wang <wanghan02 at gmail.com> wrote:
>
> Hi,
>
> Let's say we have code like this,
>
> class MyClass {};
> vector<MyClass> a;
>
> I would like to get MyClass out as a string. We could use this matcher to get the TemplateArgument.
>
> varDecl(hasType(classTemplateSpecializationDecl(hasTemplateArgument(0, templateArgument().bind("TemplateType")))))
>
> We could also use xxx->getAsType().getAsString() to get the type string. But the thing is I can only get the type "class MyClass". How can I get only "MyClass" without "class"?
>
> Thanks!
> Best regards,
> Han
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list