<div>I don't think the patch is right. My recollection of this class is (though perhaps Richard Trieu can correct me):</div><div><br></div><div>HandleExpr is intended to be called for the expression which is the top-level initializer of the declaration.</div>
<div>HandleValue is intended to be called for an expression which is "used" (either directly in the initialization of the result, or as the operand of an lvalue-to-rvalue conversion).</div><div>Visit* are called for all evaluated subexpressions (including ones we don't consider to be "used").</div>
<div><br></div><div>So... I think that we shouldn't be calling HandleExpr (nor HandleValue) from VisitParenListExpr, since it doesn't imply a use, in the required sense. I think the right way to deal with this is to add special cases for ParenListExpr and InitListExpr to HandleExpr. We also need to decide whether to warn in these cases:</div>
<div><br></div><div>int n(n); // Warn here, or is this treated like int n = n;?</div><div>int n{n}; // Warn here, or is this treated like int n = n;?</div><div><br></div><div><br></div><div>FWIW, it looks like we're missing an IgnoreParenCasts call from HandleExpr, and the IgnoreParenImpCasts call in HandleValue should be IgnoreParenCasts. We don't currently warn on cases like these, for instance:</div>
<div><br></div><div>int &r = static_cast<int&>(r);</div><div><br></div><div>... nor ...</div><div><br></div><div>struct S {} s = static_cast<S&>(s);</div><div><br></div><div><div class="gmail_quote">
On Fri, Sep 28, 2012 at 9:18 AM, 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">
This still doesn't handle C++11 initialization, does it?<br>
<br>
void g() {<br>
        int &a{a};<br>
}<br>
<br>
Jordan<br>
<div><div class="h5"><br>
<br>
On Sep 28, 2012, at 4:05 , Hans Wennborg <<a href="mailto:hans@chromium.org">hans@chromium.org</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> As pointed out in Wei's email [1], Clang currently fails to warn about<br>
> self-initialized references when using parenthesized initializers:<br>
><br>
>  void f() {<br>
>    int &a(a);<br>
>  }<br>
><br>
> The attached patch fixes this. Please take a look.<br>
><br>
> Thanks,<br>
> Hans<br>
><br>
> [1]. <a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-September/024582.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-September/024582.html</a><br>
</div></div>> <ref_self_init_parenthesized_initializers.patch>_______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>