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

Richard legalize at xmission.com
Mon Aug 12 19:39:40 PDT 2013


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?
-- 
"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>



More information about the cfe-dev mailing list