<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    The terminator for [B3] is not the binary operator; it's the whole
    if-statement. I guess it's kind of generic if-statement logic here.
    It wouldn't make that much sense to change the terminator here to
    'b' if in all other places it's still the if-statement. And i think
    we don't really want to rewrite AST to create an 'if (b)' statement
    only to use it as a terminator, that'd be pretty weird.<br>
    <br>
    But it might make sense if we change the behavior in all other
    places to avoid using the if-statement as a terminator. I'm not sure
    how much information would be lost in this case; it might work if we
    simply say in all places "here's the condition expression, compute
    it, then jump to this or that block depending on the value" and
    simply never store control flow statements in the CFG. We might as
    well separate "terminator condition expression" from "terminator
    control flow statement", not sure if i'm making any sense right now.<br>
    <br>
    The logic in the Analyzer to act upon this part of CFG is pretty
    weird, cf. ExprEngine::VisitLogicalExpr(). It definitely needs a
    cleanup, probably with the help of a more easy-to-read CFG.<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 8/3/18 2:35 PM, Gábor Horváth via
      cfe-dev wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAPRL4a17NYGTSMtZ9zvFx42KJa56uk3FtktRVMGBE9PQJSagiQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Hi!</div>
        <div><br>
        </div>
        <div>I found the terminator condition for binary operators a bit
          unintuitive in the CFG. I was wondering if I am missing
          something or it is a possible improvement.</div>
        <div><br>
        </div>
        <div>Let's consider the following simple code snippet:</div>
        <div><br>
        </div>
        <div><span style="font-family:monospace,monospace"><font
              size="2">void g(bool a, bool b) {<br>
                  if (a || b) {<br>
                      body();<br>
                  } else {<br>
                      body2();<br>
                  }<br>
              }</font></span></div>
        <div><br>
        </div>
        <div>We get the following CFG:</div>
        <div><br>
        </div>
        <div><span style="font-family:monospace,monospace"><font
              size="2"> [B1]<br>
                 1: body2<br>
                 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay,
              void (*)(void))<br>
                 3: [B1.2]()<br>
                 Preds (1): B3<br>
                 Succs (1): B0<br>
              <br>
               [B2]<br>
                 1: body<br>
                 2: [B2.1] (ImplicitCastExpr, FunctionToPointerDecay,
              void (*)(void))<br>
                 3: [B2.2]()<br>
                 Preds (2): B3 B4<br>
                 Succs (1): B0<br>
              <br>
               [B3]<br>
                 1: b<br>
                 2: [B3.1] (ImplicitCastExpr, LValueToRValue, _Bool)<br>
                 T: if [B4.2] || [B3.2]<br>
                 Preds (1): B4<br>
                 Succs (2): B2 B1<br>
              <br>
               [B4]<br>
                 1: a<br>
                 2: [B4.1] (ImplicitCastExpr, LValueToRValue, _Bool)<br>
                 T: [B4.2] || ...<br>
                 Preds (1): B5<br>
                 Succs (2): B2 B3</font></span><br>
        </div>
        <div><br>
        </div>
        <div>The terminator condition for <span
            style="font-family:monospace,monospace">[B4]</span> is (a
          cast above) <span style="font-family:monospace,monospace">a</span>.
          This is pretty intuitive. This value will determine which
          branch do we take when we leave the basic block.</div>
        <div><br>
        </div>
        <div>The terminator condition for <span
            style="font-family:monospace,monospace">[B3]</span>,
          however, is the whole binary or expression. I would expect it
          to be the right hand side of the logical or. What do you
          think? What is the reason that we have the whole expression
          here?</div>
        <div><br>
        </div>
        <div>Regards,</div>
        <div>Gabor<br>
        </div>
        <div><br>
        </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="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>