<div dir="ltr">But then which function is expected? Only getConditionVariable() returns VarDecl.<div>I just want to know induction var and all vars which are derived from induction var.</div><div><br></div></div><div class="gmail_extra">

<br><br><div class="gmail_quote">On Fri, Sep 27, 2013 at 12:46 AM, Pan, Wei <span dir="ltr"><<a href="mailto:wei.pan@intel.com" target="_blank">wei.pan@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">






<div>
<div style="direction:ltr;font-size:10pt;font-family:Tahoma">It looks like you are calling the wrong function getConditionVariable(), which returns 0 most of time.<br>
<br>
<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html#a43f4d356baa047f895978ddc8d64fee0" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html#a43f4d356baa047f895978ddc8d64fee0</a><br>
<br>
Weo<br>
<br>
<div style="font-size:16px;font-family:Times New Roman">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma"><b>From:</b> <a href="mailto:cfe-dev-bounces@cs.uiuc.edu" target="_blank">cfe-dev-bounces@cs.uiuc.edu</a> [<a href="mailto:cfe-dev-bounces@cs.uiuc.edu" target="_blank">cfe-dev-bounces@cs.uiuc.edu</a>] on behalf of Madhur Amilkanthwar [<a href="mailto:madhur13490@gmail.com" target="_blank">madhur13490@gmail.com</a>]<br>


<b>Sent:</b> Thursday, September 26, 2013 12:58 PM<br>
<b>To:</b> Gabor Kozar<br>
<b>Cc:</b> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [cfe-dev] How to know whether expression is derived from induction variable?<br>
</font><br>
</div><div><div class="h5">
<div></div>
<div>
<div dir="ltr">I am very basic thing now
<div>I inherited RecursiveASTVisitor Class and  overloaded function VisitStmt as</div>
<div>
<div>bool VisitStmt(Stmt *s)</div>
<div><span style="white-space:pre-wrap"></span>{</div>
<div><span style="white-space:pre-wrap"></span>if(isa<ForStmt>(s))</div>
<div><span style="white-space:pre-wrap"></span>{</div>
<div><span style="white-space:pre-wrap"></span>std::cout<<"For Statement found\n";</div>
<div><span style="white-space:pre-wrap"></span>VarDecl *D=cast<ForStmt>(s)->getConditionVariable();</div>
<div><span style="white-space:pre-wrap"></span>if(D->isLocalVarDecl())</div>
<div><span style="white-space:pre-wrap"></span>llvm::errs()<<"local";</div>
<div><span style="white-space:pre-wrap">}</span></div>
</div>
<div><span style="white-space:pre-wrap">return true;</span></div>
<div><span style="white-space:pre-wrap">}</span></div>
<div><span style="white-space:pre-wrap">but I am facing runtime error.(seg fault) any clue?</span></div>
<div><span style="white-space:pre-wrap"><br>
</span></div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Thu, Sep 26, 2013 at 7:35 PM, Madhur Amilkanthwar <span dir="ltr">
<<a href="mailto:madhur13490@gmail.com" target="_blank">madhur13490@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Ohk..this looks cool. Let me try that. Thanks.</div>
<div>
<div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Thu, Sep 26, 2013 at 6:37 PM, Gabor Kozar <span dir="ltr">
<<a href="mailto:kozargabor@gmail.com" target="_blank">kozargabor@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<u></u>
<div>
<div>The simplest probably would be finding all relevant loop nodes, i.e. ForExpr-s, identifying the loop induction variable, i.e. the VarDecl-s (if any), and finally running a RecursiveASTVisitor on its body, looking for a DeclRefExpr referring to any of the
 VarDecl-s you identified in the previous step.<br>
</div>
<div> </div>
<div>
<div>-- <br>
</div>
<div>Gábor Kozár -- ShdNx<br>
</div>
<div><a href="mailto:kozargabor@gmail.com" target="_blank">kozargabor@gmail.com</a><br>
</div>
<div> </div>
</div>
<div>
<div>
<div> </div>
<div> </div>
<div>On Thu, Sep 26, 2013, at 15:00, Madhur Amilkanthwar wrote:<br>
</div>
</div>
</div>
<blockquote type="cite">
<div>
<div>
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>Hi,<br>
</div>
<div>I am interested in knowing if an expression is derived from loop induction variable or not. As of now, I am able to inspect every expression after locating "if" statement in the code.
<br>
</div>
<div>Assume following code:<br>
</div>
</div>
<div>for(int i=0;i<32;i++)<br>
</div>
</div>
<div>  i=i+2;<br>
</div>
<div> </div>
</div>
<div>in above code, I am able to get access to the expression "i+2" but how should I analyze its LHS and RHS for induction variable?<br>
</div>
<div> </div>
</div>
<div>Any help appreciated. <br>
</div>
<div>
<div>
<div>
<div>
<div>
<div> </div>
<div>-- <br>
</div>
<div>Thank You.<br>
</div>
<div>Madhur D. Amilkanthwar<br>
</div>
<div>RISE lab,<br>
</div>
<div>IIT Madras. <br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div><u>_______________________________________________</u><br>
</div>
<div>cfe-dev mailing list<br>
</div>
<div><a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
</div>
<div><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div>
</blockquote>
</div>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
Thank You.<br>
Madhur D. Amilkanthwar<br>
RISE lab,<br>
IIT Madras.<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
Thank You.<br>
Madhur D. Amilkanthwar<br>
RISE lab,<br>
IIT Madras.<br>
</div>
</div>
</div></div></div>
</div>
</div>

</blockquote></div><br><br clear="all"><div><br></div>-- <br>Thank You.<br>Madhur D. Amilkanthwar<br>RISE lab,<br>IIT Madras.<br>
</div>