[cfe-dev] About the good use of the SourceLocation Object

Arnaud Desaulty ar.desaulty at gmail.com
Mon Aug 11 08:01:53 PDT 2014

Hi everyone, I'm new to this forum and clang in general so excuse me in
advance if my question seems dumb !

I'm actually using the clang library to keep track of all the variables via
the ASTMatchers. My goal is to save all the sourceRange of the declarations
and then find the first and last use of each variable and then use a
rewriter at these location to perform some refactoring.

I'm using a Struct containing all the informations about each of these
variables :

I use a first ASTMatcher to find all declarations of variables and save
their  and 

My problem appears when i try to use a second Matcher to find all the
statements of one of these variables and save the first use of this variable
and the last use. I'm able to  the  and  but cannot print the  at all.

I think the problem is that i use the SourceManager that is embedded in the
MatchResult object that i get from my second ASTMatcher Query. This result
in something like that :

So is it possible to maintain the sourceManager used in my first matcher and
that would allow me to printToString() the location of the declaration of
these variable ?

View this message in context: http://clang-developers.42468.n3.nabble.com/About-the-good-use-of-the-SourceLocation-Object-tp4041082.html
Sent from the Clang Developers mailing list archive at Nabble.com.

More information about the cfe-dev mailing list