How can I get the CompundStmt or the Stmt for this expression? Is there any way to move token by token forward from a SourceLocation?<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 16, 2012 at 1:30 AM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Nov 15, 2012 at 12:00 PM, madil90 <<a href="mailto:madil90@gmail.com">madil90@gmail.com</a>> wrote:<br>
> Hi,<br>
>   I have a DeclRefExpr which tells me wherever a variable is used. I want to<br>
> find out the previous or the next ";" so that I can go to the start of the<br>
> command in which this variable was used e.g.<br>
><br>
> int a,b;<br>
><br>
> a = b + 3;<br>
>      | |<br>
><br>
>    In this case the DeclRefExpr for b will start and end at the locations<br>
> shown. How can I find the previous ";" (in this case at the end of the line<br>
> int a,b;))<br>
<br>
There isn't any existing code to handle this, but it isn't too hard:<br>
find the CompoundStmt which contains the given expression, then get<br>
the end location of previous statement in that CompoundStmt.  (This is<br>
ignoring various edge cases, but that's the fundamental algorithm.)<br>
The ParentMap class might be useful for implementing this.<br>
<span class="HOEnZb"><font color="#888888"><br>
-Eli<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Mohammad Adil<div>LUMS SSE</div><br>
</div>