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

Jordan Rose jordan_rose at apple.com
Thu Jun 28 11:27:15 PDT 2012


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/b9a0f1cf/attachment.html>


More information about the cfe-commits mailing list