<div dir="ltr">The -Wuninitialized warning isn't ever going to have zero false negatives. Why is it important to support the non-idiomatic case of<div><br></div><div>  (void)&x;</div><div><br></div><div>rather than suggesting people use the normal idiom of</div>
<div><br></div><div>  (void)x;</div><div><br></div><div>? I'm not fundamentally opposed to this, but it seems rather ad-hoc, and I'd like for us to have a good justification for this complexity.</div><div><br></div>
<div>That said, the patch is definitely going in the right direction, if we do want to handle this. I've not looked through VisitCastExprChildren, but I'm surprised by the complexity of it. How did you determine the set of things to check for there?</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 8, 2014 at 3:31 PM, Michael Bao <span dir="ltr"><<a href="mailto:mike.h.bao@gmail.com" target="_blank">mike.h.bao@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey all,<br>
<br>
I'm looking at this bug report here:<br>
<a href="http://llvm.org/bugs/show_bug.cgi?id=17558" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=17558</a><br>
<br>
And I wanted to get some feedback/ask some questions before putting<br>
the patch onto cfe-commits.<br>
<br>
I've narrowed down the issue ClassifyRefs::VisitCastExpr. Once it sees<br>
an expression like (void)&x, it'll proceed to classify the<br>
UnaryOperator which is the immediate subexpression of the Cast<br>
expression rather than the DeclRefExpr whose classification will be<br>
queried later when checking for uninitialized variables.<br>
<br>
So my idea was to pretty much make sure that when ClassifyRefs<br>
encounters a Cast expression, it will classify the nested DeclRefExpr<br>
instead. This way Clang will not think that (void)&x is initializing<br>
x.<br>
<br>
However, I think that a previous commit's test case (for PR 16054<br>
-<a href="http://llvm.org/bugs/show_bug.cgi?id=16054" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=16054</a>) seems to be relying on<br>
this behavior. In test/Analysis/uninit-sometimes.cpp,we have<br>
<br>
> void PR16054() {<br>
>   int x; // expected-note {{variable}} expected-warning {{used uninitialized whenever function 'PR16054}}<br>
>   while (x != 0) { // expected-note {{use}}<br>
>     (void)&x;<br>
>   }<br>
> }<br>
<br>
Changing (void)&x to (void)x results in the "sometimes-uninitialized"<br>
warning becoming a regular "uninitialized" warning. I believe in this<br>
case, this warning should be the regular uninitialized warning, am I<br>
correct in assuming this?<br>
<br>
Finally, I have this following piece of code which is of questionable<br>
quality. The purpose of this hack is to make the code function the<br>
same as before when it encounters one of these situations. More or<br>
less, I don't want to dig into function calls (including typeid,<br>
sizeof and uuid) and mark them as ignore because that would override<br>
the mark on them as being used. I'm sure there's probably a better way<br>
to do this though, thoughts?<br>
<br>
>   if (isa<CXXTypeidExpr>(S) || isa<CallExpr>(S) || isa<CXXUuidofExpr>(S)<br>
>       || isa<SizeOfPackExpr>(S)) {<br>
>     classify(dyn_cast<Expr>(S), Ignore);<br>
>     return;<br>
>   }<br>
<br>
Thanks!<br>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>