[cfe-commits] [Patch] -Wduplicate-enum which fixes PR6343

Ted Kremenek kremenek at apple.com
Wed Jul 18 17:41:46 PDT 2012


Hi Richard,

I think this checking is quadratic, n(n+1)/2.  This might be fairly expensive on a large set of enums.  Do you have any performance numbers?  I agree that it is a good checking, but the way it is implemented is likely to be noticeably slow on some (important) cases.

Ted

On Jul 18, 2012, at 4:46 PM, Richard Trieu <rtrieu at google.com> wrote:

> http://llvm.org/bugs/show_bug.cgi?id=6343
> 
> Warn on enum elements that are assigned values already in use.  This is based on the misconception that elements not given a value will be given the next smallest, unused value.  Instead, elements are assigned 1 more than the previous value.  Some example code this warning will catch:
> 
> enum { A, B, C, Aref = A, count };
> Both B and count will have value 1.
> 
> enum { A, B, C, D = -1, E, F };
> A = E = 0
> B = F = 1
> 
> This warning found one such issue in LLVM that was fixed in r160465.
> <duplicate-enum.patch>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120718/7ca26ecc/attachment.html>


More information about the cfe-commits mailing list