<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Sorry to be late to the party guys. We should just fix this in the analyzer. I'll take a look.<div><br><div><div>On Jul 24, 2012, at 6:12 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">On Tue, Jul 24, 2012 at 5:54 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Jul 24, 2012, at 5:25 PM, Jordan Rose wrote:<br>> On Jul 24, 2012, at 2:04 PM, Richard Smith wrote:<br>>> On Fri, Jul 20, 2012 at 4:03 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
>> On Wed, Jul 18, 2012 at 9:59 PM, Ted Kremenek <<a href="mailto:kremenek@apple.com">kremenek@apple.com</a>> wrote:<br>
>> Author: kremenek<br>
>> Date: Wed Jul 18 23:59:05 2012<br>
>> New Revision: 160494<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=160494&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=160494&view=rev</a><br>
>> Log:<br>
>> Simplify UninitializedValues.cpp by removing logic to handle the previous (imprecise) representation<br>
>> of '&&' and '||' in the CFG. This is no longer needed<br>
>><br>
>> Sadly, that appears to be untrue. We now produce a bogus -Wuninitialized warning on this:<br>
>><br>
>> int x(int*); int f(bool b) { int n = (b || x(&n)) ? 0 : n; return n; }<br>
>><br>
>> More generally, && and || as the LHS of a ?: still produce a CFG with false edges.<br>
>><br>
>> Fixed in r160691.<br>
><br>
> This broke one of our internal buildbots for the static analyzer, on precisely this case (|| and ?:) in ctype.h. Here's a simplified test case:<br>
><br>
> // clang -cc1 -analyze -analyzer-checker=core -x c<br>
> int isctype(char c, unsigned long f)<br>
> {<br>
> return (c < 1 || c > 10) ? 0 : !!(c & f);<br>
> }<br>
><br>
> This is the assertion:<br>
><br>
>> Assertion failed: (X.isUndef()), function VisitGuardedExpr, file ExprEngineC.cpp, line 597.<br>
><br>
> I don't remember /why/ we have to pass the decision Expr through an UndefinedVal here, but we're clearly confused by this. I think we're still expecting to see the || in the CFG before the ?:, and with this change that doesn't seem to be the case anymore.<br>
<br>
</div></div>More info: when the analyzer sees a ||, it walks back through the path to find out if we took the true path or the false path, and then uses that to decide which expression to use as the branch value. ?: expects to get that answer from its condition, but we aren't evaluating the || anymore.<br>
<br>
I'm not sure what's the right thing to do. This CFG is /mostly/ equivalent to the previous ones, and it is more efficient...but it means that clients have to reason about branches with short-circuit conditions specially. It's just not an issue in the analyzer for 'if' and friends because those are top-level statements -- they don't need to be visited for a value as well as a branch.<br>
<br>
Ted probably has some guidance here.<br></blockquote></div><br><div>I don't know enough about the static analyzer to formulate a fix here. If this is causing you an immediate problem, please feel free to revert both r160691 and r160494 (Ted's change caused a -Werror build break for us).</div>
</blockquote></div><br></div></body></html>