[cfe-commits] [patch] Warn on self assignment for member variables

Nico Weber thakis at chromium.org
Thu Jun 28 16:24:59 PDT 2012


Thanks! All done.


On Thu, Jun 28, 2012 at 11:27 AM, Jordan Rose <jordan_rose at apple.com> wrote:

>
> On Jun 27, 2012, at 15:12 , Nico Weber <thakis at chromium.org> wrote:
>
> New patch!
>
> In this version:
> * no longer uses FoldingSetNodeID, which hopefully addressed performance
> concerns (this means "s->a_ = s->a_" is no longer caught, but that has
> never happened to me anyway)
> * ObjC support as requested by Jordan
> * Fix to an existing ObjC test that triggered this warning (accidentally I
> think)
>
>
> Yeah, this is probably a better effort/reward tradeoff. Some small notes:
>
> - In the ObjC one you're already comparing the two decls equal to each
> other; you might as well not bother to check for "self". It's very rare in
> idiomatic Objective-C to assign to other objects' ivars anyway, but in the
> rare case that you did, you'd get the "s->a_ = s->a_" warning.
> - In ObjC they're called "instance variables", not "member variables". Can
> you make the diagnostic more flexible?
> - A random LFunction change snuck into this patch. :-)
>
> Thanks!
> Jordan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120628/2a722cc8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-memvar-assign.patch
Type: application/octet-stream
Size: 5401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120628/2a722cc8/attachment.obj>


More information about the cfe-commits mailing list