<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">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>On Oct 7, 2011, at 9:32 PM, Guoping Long wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">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">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>
_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br></blockquote></div><br></div></body></html>