<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Thanks, Artem!<br>
</p>
<p><br>
</p>
<p>><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe WP", "Segoe UI WPC", Tahoma, Arial, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">You can find all your answers on the exploded graph dump.</span><br>
</p>
<p>Ok, I see. In this particular example analyzer splits an exploded graph on every iteration and the code below is reached in case of false branch. But what I am <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">really</span>
 interested in is to reach the code in true branch.<br>
</p>
<p>The problem is that the core generates a sink node after it reaches the limit of loop iterations.<br>
</p>
<p>My better example:<br>
</p>
<blockquote type="cite" style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
<span style="font-family: Consolas, monospace; font-size: 9pt;">void f1()</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
<span style="font-family: Consolas, monospace; font-size: 9pt;">{<br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
<span style="font-family: Consolas, monospace; font-size: 9pt;">  int i = 0;<br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
<span style="font-family: Consolas, monospace; font-size: 9pt;">  while(i < 100)</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
<span style="font-size: 9pt;"><span style="font-family: Consolas, monospace;">    i++;</span><br style="font-family: Consolas, monospace;">
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
<span style="font-family: Consolas, monospace; font-size: 9pt;">  // Interested in some code here!!<br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
<span style="font-family: Consolas, monospace; font-size: 9pt;">}</span></div>
</blockquote>
<span style="font-size: 12pt;">​​</span><span style="font-size: 12pt;">one more example</span><br>
<span style="font-family: Consolas, monospace; font-size: 9pt;">​</span><br>
<blockquote type="cite" style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
<span style="font-family: Consolas, monospace; font-size: 9pt;">void f2()</span><br>
<span style="font-family: Consolas, monospace; font-size: 9pt;">{</span><br>
<span style="font-family: Consolas, monospace; font-size: 9pt;">  int i = 0;</span><br>
<span style="font-family: Consolas, monospace; font-size: 9pt;">  while(true)</span><br>
<span style="font-family: Consolas, monospace; font-size: 9pt;">    i++;</span><br>
<span style="font-family: Consolas, monospace; font-size: 9pt;">  // Interested in some code here!!</span><br>
<div><span style="font-family: Consolas, monospace; font-size: 9pt;">}​</span></div>
</div>
</blockquote>
​As I understand, there is no way to do this, right?<br>
<p><br>
</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<hr>
<div><b>Denys Petrov</b></div>
<div>Senior ó++ Developer | Kharkiv, Ukraine</div>
<div><br>
</div>
<div></div>
</div>
</div>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>ïÔ:</b> Artem Dergachev <noqnoqneo@gmail.com><br>
<b>ïÔÐÒÁ×ÌÅÎÏ:</b> 28 ÉÀÌÑ 2020 Ç. 22:34<br>
<b>ëÏÍÕ:</b> Denis Petrov; cfe-dev<br>
<b>ôÅÍÁ:</b> Re: [cfe-dev] [analyzer] How to analyzer the code after an indefinite loop?</font>
<div> </div>
</div>
<div>
<div style="font-size:9pt; font-family:'Calibri',sans-serif">
<h3 style="background-color:#ffffff; font-size:10pt; border:1px dotted #003333; padding:.8em">
<span style="color:#ff6600">CAUTION:<strong> </strong></span>This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.  If you suspect potential phishing or spam
 email, report it to ReportSpam@accesssoftek.com</h3>
</div>
<div>Here's how you can find this out with the help of ExprInspection:<br>
<br>
<br>
$ cat test.c<br>
<br>
int f(int x, int flag)<br>
{<br>
  int i = 0;<br>
  while(i < x)<br>
    i++;<br>
<br>
  clang_analyzer_warnIfReached();<br>
}<br>
<br>
<br>
$ clang --analyze -Xclang -analyzer-checker=debug.ExprInspection test.c<br>
<br>
test.c:7:3: warning: REACHABLE [debug.ExprInspection]<br>
  clang_analyzer_warnIfReached();<br>
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
1 warning generated.<br>
<br>
<br>
Here's a slightly more interesting experiment:<br>
<br>
<br>
$ cat test.c<br>
<br>
int f(int x, int flag)<br>
{<br>
  int i = 0;<br>
  while(i < x)<br>
    i++;<br>
<br>
  if (flag) {<br>
    clang_analyzer_warnIfReached();<br>
    clang_analyzer_numTimesReached();<br>
    return i;<br>
  } else {<br>
    clang_analyzer_warnIfReached();<br>
    clang_analyzer_numTimesReached();<br>
    return 0;<br>
  }<br>
}<br>
<br>
<br>
$ clang --analyze -Xclang -analyzer-checker=debug.ExprInspection test.c<br>
<br>
test.c:8:5: warning: REACHABLE [debug.ExprInspection]<br>
    clang_analyzer_warnIfReached();<br>
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
test.c:9:5: warning: 4 [debug.ExprInspection]<br>
    clang_analyzer_numTimesReached();<br>
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
test.c:12:5: warning: REACHABLE [debug.ExprInspection]<br>
    clang_analyzer_warnIfReached();<br>
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
test.c:13:5: warning: 1 [debug.ExprInspection]<br>
    clang_analyzer_numTimesReached();<br>
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
4 warnings generated.<br>
<br>
<br>
Will you be able to figure out why is one branch reached 4 times while the other branch is reached only once? You can find all your answers on the exploded graph dump.<br>
<br>
<br>
<div class="moz-cite-prefix">On 7/28/20 5:59 AM, Denis Petrov via cfe-dev wrote:<br>
</div>
<blockquote type="cite"><style type="text/css" style="">
<!--
p
        {margin-top:0px;
        margin-bottom:0px}
-->
</style>
<p>Hi, community!<br>
</p>
<p><br>
</p>
<p>A quick question.<br>
</p>
<p><br>
</p>
<p>Is CSA Core able to analyze the code after some indefinite loop?<br>
</p>
<p>E.g.<br>
</p>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">void f(int x)</span></span></span></span></div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">{</span></span></span></span><br style="font-family:Consolas,monospace">
</span></div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">  int i = 0;</span></span></span></span><br style="font-family:Consolas,monospace">
</span></div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">  while(i < x)</span></span></span></span></div>
<div><span style="font-size:9pt"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">    i++;</span></span><br style="font-family:Consolas,monospace">
</span></div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">  // Interested
 in some code here!!</span></span></span></span><br style="font-family:Consolas,monospace">
</span></div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">}</span></span></span></span><br>
</div>
<p><br>
</p>
<p>I found that Exploded graph grows going through the loop 4 times and then stops to analyze the code further.<br>
</p>
<p>P.S. I know about -<span style="color:rgb(36,41,46); font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace; font-size:12px; white-space:pre; background-color:rgb(255,255,255)">analyzer-max-loop</span>(4)​.<br>
</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<hr>
<div><b>Denys Petrov</b></div>
<div>Senior ó++ Developer | Kharkiv, Ukraine</div>
<div><br>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
</div>
</div>
</div>
</body>
</html>