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

Han Wang wanghan02 at gmail.com
Fri Jul 17 09:45:12 PDT 2015


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


More information about the cfe-dev mailing list