[cfe-dev] ASTMatcher classTemplateSpecializationDecl(): how to get source location of template argument?

Manuel Klimek klimek at google.com
Wed Aug 14 00:01:15 PDT 2013


On Mon, Aug 12, 2013 at 7:39 PM, Richard <legalize at xmission.com> wrote:

> Suppose I have the following code, patterned after remove-cstr-calls:
>
> Finder.addMatcher(classTemplateSpecializationDecl().bind("ts"), &Callback);
>
> Inside the Callback, I want to do something like:
>
> if (ClassTemplateSpecializationDecl const *const TemplateSpecialization
>         = Nodes.getNodeAs<ClassTemplateSpecializationDecl>("ts")) {
>         // obtain text of template specialization
> }
>
> I can find out if this is an explicit instantiation or specialization
> and I can get the template arguments with getTemplateArgs(), but I
> can't seem to find accessors for the source location around the
> template argument.
>
> It seems silly for me to have to scrape out the template argument from
> the whole specialization with ad-hoc string searches.  I'm thinking
> there's a better way that I'm missing.
>
> Suggestions?
>

Does
getTypeAsWritten()->getTypeLoc() give you a TemplateSpecializationTypeLoc?

Cheers,
/Manuel



> --
> "The Direct3D Graphics Pipeline" free book <
> http://tinyurl.com/d3d-pipeline>
>      The Computer Graphics Museum <http://computergraphicsmuseum.org>
>          The Terminals Wiki <http://terminals.classiccmp.org>
>   Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
> _______________________________________________
> 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/20130814/b4f42799/attachment.html>


More information about the cfe-dev mailing list