[cfe-dev] how to get label from a statement and VisitLabelExpr

Gábor Kozár kozargabor at gmail.com
Tue May 14 01:18:17 PDT 2013


Hi,

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
RecursiveASTVisitor<http://clang.llvm.org/doxygen/classclang_1_1RecursiveASTVisitor.html>
:

> *"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.

Gabor


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
> do
> that?
>
> 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",
> I
> dont't get label. Any help?
>
>
>
> --
> View this message in context:
> http://clang-developers.42468.n3.nabble.com/how-to-get-label-from-a-statement-and-VisitLabelExpr-tp4032103.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130514/c46e4490/attachment.html>


More information about the cfe-dev mailing list