<div dir="ltr"><div><div>Then I'm afraid I'm not sure. Maybe the assignments aren't classed as a binary operator any longer?<br><br></div>It would be great if you can produce a COMPLETE (but minimal to show the problem) example of both the code you are working on, and the input that you are giving it, for debugging.<br><br>--<br></div>Mats<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 5 January 2017 at 06:51, 詹石岩 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"><div>I added code just at the beginning of VisitBinaryOperator like:</div><div><pre style="font-family:"DejaVu Sans Mono""><font size="2">bool VisitBinaryOperator(<wbr>BinaryOperator *b){<br> PrintingPolicy policy = PrintingPolicy(this-><wbr>TheRewriter.getLangOpts());<br> b->printPretty(llvm::errs(), NULL, policy);<br> llvm::errs()<<'\n';<br> if(b->isAssignmentOp()){<br> handler.HandleBinaryOperator(<wbr>b);<br> }<br> return true;<br>}</font></pre><pre style="font-family:"DejaVu Sans Mono""><font size="2">The test code includes these lines:</font></pre><span class=""><pre style="font-family:"DejaVu Sans Mono"">void setForceMethod(NbodyModel *theModel,int force_method) {<br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal"><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal"> theModel->force_method=force_<wbr>method;</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal"><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal">}</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal"><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal">void setTreeRangeCoefficient(<wbr>NbodyModel *theModel,double coefficient) {</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal"><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal"> theModel-><wbr>treeRangeCoefficient=<wbr>coefficient;</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal"><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal">}</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal"><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal">void setIntMethod(NbodyModel *theModel,int int_method) {</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal"><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal"> theModel->int_method=int_<wbr>method;</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal"><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";white-space:normal">}</span></pre></span><pre style="font-family:"DejaVu Sans Mono"">expected output should include these assignments but I didn't find them in terminal.</pre><pre style="font-family:"DejaVu Sans Mono"">I tried `clang -Xclang -ast-dump -fsyntax-only mycode.c` and these assignments were printed out.</pre><pre style="font-family:"DejaVu Sans Mono"">The older version of this tool can get most of these assignments(7 out of 8) but after I added some code, all of them are gone. Does this problem have any relation to compiler? Or the memory layout was messed up by my code?</pre></div><span class=""><blockquote style="margin:0.8em 0px 0.8em 2em;padding:0px 0px 0px 0.7em;border-left:2px solid rgb(221,221,221)"><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei"">Are you SURE that the VisitBinaryOperator function is not being called? I</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei"">find that highly unlikely (considering that these visitors are quite</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei"">commonly used for all sorts of different purposes, and checking for</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei"">assignments isn't unusual by any means).</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei"">I would expect that the conditions INSIDE your function is what is causing</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei"">problems. Try adding some printout (or set a breakpoint in a debugger) at</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei"">the beginning of the function. I suspect the function is being called, but</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei"">the operands are not the kind you think they are in this case, so your</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei"">printout or "do stuff" isn't happening.</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei"">--</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei"">Mats</span><br style="font-family:"lucida Grande",Verdana,"Microsoft YaHei""></blockquote><div><br></div></span><div><div style="color:#909090;font-family:Arial Narrow;font-size:12px">------------------</div><div style="font-size:14px;font-family:Verdana;color:#000"><div><font face="幼圆" size="2">----</font></div><font face="幼圆" size="2">祝好!</font><span class="HOEnZb"><font color="#888888"><div><font face="幼圆" size="2">詹石岩</font></div></font></span></div></div><div> </div><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>
<br></blockquote></div><br></div>