<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    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"
      cite="mid:1595941187617.8262@accesssoftek.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <style type="text/css" style="display:none"><!-- 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" wrap="">_______________________________________________
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>
  </body>
</html>