Also, it seems there is an assert error in UninitializedValues.cpp. Giving this test program:<div><div>  1 int main(int argc, char *argv[])</div><div>  2 {</div><div>  3   int x=3, y = 5, z = 6;</div><div>  4 </div><div>  5   if(x<0) {</div>
<div>  6     while(y>0){</div><div>  7       y--;</div><div>  8       x = z+1;</div><div>  9     }</div><div> 10   }else x = y;</div><div> 11   return 0;</div><div> 12 }</div><div>Here is the assert error: </div><div><div>
Assertion failed: (res.getDeclRefExpr() == lastDR), function VisitUnaryOperator, file /Users/gplong/llvm/tools/clang/lib/Analysis/UninitializedValues.cpp, line 529.</div></div><div>This message is triggered in call VisitUnaryOperator(). The line number may not be correct because I added some print statements.</div>
<div><br></div><div>-----</div><div>Guoping</div><br><div class="gmail_quote">2011/10/8 Guoping Long <span dir="ltr"><<a href="mailto:longguoping@gmail.com">longguoping@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On my testing environment, the UninitializedValues.cpp has the same problem (do not have any output). Both analyses are based on the StmtVisitor interface.  I think there may be a version mismatch, that is these two analyses are based on an older version of StmtVisitor class to work?  I just downloaded a new version from website and did all tests again and still have this problem.<div>

<br></div><div>----</div><div>Guoping<div><div></div><div class="h5"><br><br><div class="gmail_quote">2011/10/8 Guoping Long <span dir="ltr"><<a href="mailto:longguoping@gmail.com" target="_blank">longguoping@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi, Ted<div><br></div><div>   I will be very curious why results in your environment are correct. Attached is my test code. I stepped into the program using GDB, it turned out that no live variables can be found. Take the last return statement in my previous example program as an example: return b * d + c. The transfer function eventually called the default StmtVisit function which did not recognize variables b, d, c which are actually used.The only function in LiveVariables.cpp that can generate live variables is VisitDeclRefExpr(), but when running the program this function is never called. </div>


<div><br></div><div>  I am using the newest version of Clang/LLVM. Is it because my environment setup is wrong? </div><div><br></div><div>----</div><div>Guoping</div><div><div></div><div><div><br><div class="gmail_quote">

2011/10/7 Ted Kremenek <span dir="ltr"><<a href="mailto:kremenek@apple.com" target="_blank">kremenek@apple.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">This is what I am seeing:<div><br></div><div><div>$ clang -cc1 -analyze -analyzer-checker=debug.DumpLiveVars t.c</div>


<div><br></div><div>[ B0 (live variables at block exit) ]</div><div><br></div><div>[ B1 (live variables at block exit) ]</div><div><br></div><div>[ B2 (live variables at block exit) ]</div><div> b <t.c:2:10></div><div>


 d <t.c:2:16></div><div><br></div><div>[ B3 (live variables at block exit) ]</div><div> a <t.c:2:7></div><div> b <t.c:2:10></div><div> d <t.c:2:16></div><div><br></div><div>[ B4 (live variables at block exit) ]</div>


<div><br></div><div><br></div><div>I also think the number of the blocks is not quite right in your example, or at least how they correspond to Clang's CFG:</div><div><br></div><div><div>$ clang -cc1 -analyze -analyzer-checker=debug.DumpCFG t.c</div>


<div><br></div><div> [ B4 (ENTRY) ]</div><div>    Predecessors (0):</div><div>    Successors (1): B3</div><div><br></div><div> [ B1 ]</div><div>      1: 4</div><div>      2: c</div><div>      3: [B1.2] = [B1.1]</div><div>


      4: b</div><div>      5: [B1.4]</div><div>      6: d</div><div>      7: [B1.6]</div><div>      8: [B1.5] * [B1.7]</div><div>      9: c</div><div>     10: [B1.9]</div><div>     11: [B1.8] + [B1.10]</div><div>     12: return [B1.11];</div>


<div>    Predecessors (2): B2 B3</div><div>    Successors (1): B0</div><div><br></div><div> [ B2 ]</div><div>      1: a</div><div>      2: [B2.1]</div><div>      3: b</div><div>      4: [B2.3]</div><div>      5: [B2.2] + [B2.4]</div>


<div>      6: c</div><div>      7: [B2.6] = [B2.5]</div><div>      8: 2</div><div>      9: d</div><div>     10: [B2.9] = [B2.8]</div><div>    Predecessors (1): B3</div><div>    Successors (1): B1</div><div><br></div><div>


 [ B3 ]</div><div>      1: int a;</div><div>      2: int b;</div><div>      3: int c;</div><div>      4: int d;</div><div>      5: int x;</div><div>      6: 3</div><div>      7: a</div><div>      8: [B3.7] = [B3.6]</div>

<div>
      9: 5</div><div>     10: b</div><div>     11: [B3.10] = [B3.9]</div><div>     12: 4</div><div>     13: d</div><div>     14: [B3.13] = [B3.12]</div><div>     15: 100</div><div>     16: x</div><div>     17: [B3.16] = [B3.15]</div>


<div>     18: a</div><div>     19: [B3.18]</div><div>     20: b</div><div>     21: [B3.20]</div><div>     22: [B3.19] > [B3.21]</div><div>      T: if [B3.22]</div><div>    Predecessors (1): B4</div><div>    Successors (2): B2 B1</div>


<div><br></div><div> [ B0 (EXIT) ]</div><div>    Predecessors (1): B1</div><div>    Successors (0):</div></div><div><br></div><div><br></div><div>Block B3 is actually the entrance block, since the CFG is built bottom-up.</div>


<div><br></div><div>Perhaps there is something not quite right with how you are running the checkers?</div><div><br></div><div><div><div></div><div><div>On Oct 7, 2011, at 9:32 PM, Guoping Long wrote:</div><br>
</div></div><blockquote type="cite"><div><div></div><div>Hi, <div><br></div><div>   While LiveVariables analysis (tools/clang/lib/Analysis/LiveVariables.cpp) does not generate any output? Specifically, for this simple program:</div>


<div><div>  1 int main(int argc, char *argv[])</div>
<div>  2 {</div><div>  3   int a,b,c,d,x;</div><div>  4 </div><div>  5   a = 3;   //Basic block B1</div><div>  6   b = 5;</div><div>  7   d = 4;</div><div>  8   x = 100;</div><div>  9   </div><div> 10   if(a>b){  //Basic block B2</div>



<div> 11     c = a+b;</div><div> 12     d = 2;</div><div> 13   }</div><div> 14   </div><div> 15   c = 4;   //Basic block B3</div><div> 16   return b * d + c;</div><div> 17 }</div></div><div>This simple example is taken from this wiki page illustrating live variables analysis (<a href="http://en.wikipedia.org/wiki/Live_variable_analysis" target="_blank">http://en.wikipedia.org/wiki/Live_variable_analysis</a>).</div>



<div>Both B2 and B3 should have live variables, but the output (using LiveVariables::dumpBlockLiveness(SourceManager &)) says no live variables exist. I am trying to use this analysis as an example on how to write a good analysis algorithm for Clang, but really did not expect this behavior for this analysis.</div>



<div>Anybody who knows the answer please let me know. Many thanks!!!</div><div><br></div><div>--------</div><div>Guoping</div></div></div>
_______________________________________________<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>


</blockquote></div><br></div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>