[cfe-dev] declRefExpr clang

Mohammad Adil madil90 at gmail.com
Thu Nov 15 14:07:39 PST 2012


Can you please give an example of how ParentMap can be used in this
situation?


On Fri, Nov 16, 2012 at 3:00 AM, Eli Friedman <eli.friedman at gmail.com>wrote:

> On Thu, Nov 15, 2012 at 1:23 PM, Mohammad Adil <madil90 at gmail.com> wrote:
> > How can I get the CompundStmt or the Stmt for this expression?
>
> ParentMap (or some equivalent).
>
> > Is there any
> > way to move token by token forward from a SourceLocation?
>
> No.
>
> -Eli
>
> > On Fri, Nov 16, 2012 at 1:30 AM, Eli Friedman <eli.friedman at gmail.com>
> > wrote:
> >>
> >> On Thu, Nov 15, 2012 at 12:00 PM, madil90 <madil90 at gmail.com> wrote:
> >> > Hi,
> >> >   I have a DeclRefExpr which tells me wherever a variable is used. I
> >> > want to
> >> > find out the previous or the next ";" so that I can go to the start of
> >> > the
> >> > command in which this variable was used e.g.
> >> >
> >> > int a,b;
> >> >
> >> > a = b + 3;
> >> >      | |
> >> >
> >> >    In this case the DeclRefExpr for b will start and end at the
> >> > locations
> >> > shown. How can I find the previous ";" (in this case at the end of the
> >> > line
> >> > int a,b;))
> >>
> >> There isn't any existing code to handle this, but it isn't too hard:
> >> find the CompoundStmt which contains the given expression, then get
> >> the end location of previous statement in that CompoundStmt.  (This is
> >> ignoring various edge cases, but that's the fundamental algorithm.)
> >> The ParentMap class might be useful for implementing this.
> >>
> >> -Eli
> >
> >
> >
> >
> > --
> > Mohammad Adil
> > LUMS SSE
> >
>



-- 
Mohammad Adil
LUMS SSE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121116/a83eddc5/attachment.html>


More information about the cfe-dev mailing list