[cfe-dev] how to get label from a statement and VisitLabelExpr
kozargabor at gmail.com
Tue May 14 01:18:17 PDT 2013
That seems to be correct, I'm not sure what could be the issue. Could you
show us some code?
(I think that VisitLabelStmt's parameter type is LabelStmt*, but I do not
think that could be the issue here.)
The only thing I can imagine is that you abort the tree traversal in one of
your override methods. To quote the documentation of
> *"Advanced users may override Traverse* and WalkUpFrom* to implement
custom traversal strategies. Returning false from one of these overridden
functions will abort the entire traversal."*
Try commenting out your entire visitor, and replacing it with a trivial one
that ONLY overrides VisitLabelStmt, and returns true - I don't remember
what the effect of returning false in a Visit* method is, but my guess
would be that it causes any derived-type Visit* methods not to be called
(i.e. if for a LabelStmt*, you return false from VisitStmt, then
VisitLabelStmt won't be called) - but again, that's just my guess.
Hope this helps.
2013/5/14 Rajendra <rks at cse.iitb.ac.in>
> How to get label of a LabelStmt?
> e.g. from code below, I want to get label MYASSERT1 and MYASSERT2, how to
> int main()
> int x, y;
> x = 10;
> MYASSERT1: x>0;
> y = 0;
> MYASSERT2: x==0;
> return 0;
> I have written VisitLabelStmt(Stmt*) but control doesn't come to this
> function. Also in VisitStmt(Stmt*) when I check stmt class as "LabelStmt",
> dont't get label. Any help?
> View this message in context:
> Sent from the Clang Developers mailing list archive at Nabble.com.
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev