<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
If it turns out that in some corner-cases the last expression is not
the terminator condition, pls let me know^^<br>
<br>
Otherwise we might as well add an API to retrieve it, so that people
could rely on it.<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 8/7/18 3:46 PM, Gábor Horváth wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAPRL4a3mk32_-M3jczXojS1o_inNCncZoFHb4_HH8KfXswfgnQ@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">Cool, thanks! The last expression is indeed the
way to go for me. <br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Fri, 3 Aug 2018 at 15:02, Artem Dergachev <<a
href="mailto:noqnoqneo@gmail.com" moz-do-not-send="true">noqnoqneo@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"> <br>
<br>
<div class="m_6463236416835500423moz-cite-prefix">On 8/3/18
2:53 PM, Artem Dergachev wrote:<br>
</div>
<blockquote type="cite"> 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>
</blockquote>
<br>
On second thought, it's exactly how it works right now, if
we declare that the "terminator condition expression" is
just the last expression in the block. I.e., for [B4] the
condition is 'a' and the terminator is '||', for [B3] the
condition is 'b' and the terminator is 'if'. <br>
<br>
<blockquote type="cite"> <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="m_6463236416835500423moz-cite-prefix">On
8/3/18 2:35 PM, Gábor Horváth via cfe-dev wrote:<br>
</div>
<blockquote type="cite">
<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="m_6463236416835500423mimeAttachmentHeader"></fieldset>
<pre class="m_6463236416835500423moz-quote-pre">_______________________________________________
cfe-dev mailing list
<a class="m_6463236416835500423moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org" target="_blank" moz-do-not-send="true">cfe-dev@lists.llvm.org</a>
<a class="m_6463236416835500423moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank" moz-do-not-send="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
</div>
</blockquote>
</div>
</blockquote>
<br>
</body>
</html>