<div dir="ltr"><div><div>I'm reasonably sure there is no "magic" way to find this. You can use an AST Matcher to find loops, but you then have to step through the content of the loop. Or you can use a RecursiveASTVisitor, and find the for-statements, then find variable declarations within that, for example using a "map" to track which loop it is that contains what declarations. <br><br>RecursiveASTVisitor example:<br><a href="https://clang.llvm.org/docs/RAVFrontendAction.html">https://clang.llvm.org/docs/RAVFrontendAction.html</a><br><br></div>A stack overflow question on using AST Matcher to find loops:<br><a href="http://stackoverflow.com/questions/36880574/finding-nested-loops-with-clang-ast-statementmatcher">http://stackoverflow.com/questions/36880574/finding-nested-loops-with-clang-ast-statementmatcher</a><br><br>--<br></div>Mats<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 3 May 2017 at 13:47, via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi everyone,<br>
<br>
I want to get all variable declaration which is inside a loop ( whose<br>
scope limited to that loop only). Can someone please tell me how can i do<br>
this?<br>
<br>
Ex<br>
<br>
int a,bl<br>
for(){<br>
int c,d;<br>
}<br>
Output should be c,d<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Thanks and Regards<br>
Awanish Pandey<br>
PhD, CSE<br>
IIT Kanpur<br>
<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</font></span></blockquote></div><br></div>