[cfe-dev] How to get the template argument type from AST matcher?

Han Wang wanghan02 at gmail.com
Mon Jul 20 00:33:05 PDT 2015


Hi Jason,

Thanks! It works. :)

Best regards,
Han

On Mon, Jul 20, 2015 at 9:14 AM, Jason Haslam <jason.haslam at gmail.com>
wrote:

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150720/05e20554/attachment.html>


More information about the cfe-dev mailing list