<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On May 30, 2012, at 10:43 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><br><div class="gmail_quote">On Tue, May 29, 2012 at 6:01 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: rtrieu<br>
Date: Tue May 29 20:01:11 2012<br>
New Revision: 157666<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=157666&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=157666&view=rev</a><br>
Log:<br>
Add new -Wunique-enum which will warn on enums which all elements have the<br>
same value and were initialized with literals.  </blockquote><div><br></div><div>This currently produces a false positive on some anonymous-enum'd constants in Diagnostic.h:635:<br><br><pre style="font-size: medium; background-color: rgb(255, 255, 255); position: static; z-index: auto; ">  <b><font color="#228B22">enum</font></b> {
    <i><font color="#B22222">/// MaxArguments - The maximum number of arguments we can hold. We currently
</font></i>    <i><font color="#B22222">/// only support up to 10 arguments (%0-%9).  A single diagnostic with more
</font></i>    <i><font color="#B22222">/// than that almost certainly has to be simplified anyway.
</font></i>    MaxArguments = 10,

    <i><font color="#B22222">/// MaxRanges - The maximum number of ranges we can hold.
</font></i>    MaxRanges = 10,

    <i><font color="#B22222">/// MaxFixItHints - The maximum number of ranges we can hold.
</font></i>    MaxFixItHints = 10
  };

<span style="font-family:arial;font-size:small;white-space:normal">Perhaps we should ignore this warning if the enum is unnamed? Or specifically if it's both unnamed and has no instances (so it could still fire on "enum { x, y = 0 } a, b;")<br>
<br>Since this warning is on by default, this breaks a self-host Clang -Werror build.</span></pre></div></div></blockquote></div><div>Mac OS X frameworks use anonymous enums for constants in order to have the store type be word-sized:</div><div><br></div><div><pre class="declaration" style="margin-top: 0px; margin-right: 0.333em; margin-left: 0.5em; font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); background-color: rgb(255, 255, 255); position: static; z-index: auto; ">enum {
   <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/c_ref/NSCaseInsensitiveSearch" style="color: rgb(0, 51, 102); text-decoration: none; ">NSCaseInsensitiveSearch</a> = 1,
   <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/c_ref/NSLiteralSearch" style="color: rgb(0, 51, 102); text-decoration: none; ">NSLiteralSearch</a> = 2,
   <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/c_ref/NSBackwardsSearch" style="color: rgb(0, 51, 102); text-decoration: none; ">NSBackwardsSearch</a> = 4,
   <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/c_ref/NSAnchoredSearch" style="color: rgb(0, 51, 102); text-decoration: none; ">NSAnchoredSearch</a> = 8,
   <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/c_ref/NSNumericSearch" style="color: rgb(0, 51, 102); text-decoration: none; ">NSNumericSearch</a> = 64,
   <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/c_ref/NSDiacriticInsensitiveSearch" style="color: rgb(0, 51, 102); text-decoration: none; ">NSDiacriticInsensitiveSearch</a> = 128,
   <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/c_ref/NSWidthInsensitiveSearch" style="color: rgb(0, 51, 102); text-decoration: none; ">NSWidthInsensitiveSearch</a> = 256,
   <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/c_ref/NSForcedOrderingSearch" style="color: rgb(0, 51, 102); text-decoration: none; ">NSForcedOrderingSearch</a> = 512,
   <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/c_ref/NSRegularExpressionSearch" style="color: rgb(0, 51, 102); ">NSRegularExpressionSearch</a> = 1024
};</pre><pre class="declaration" style="margin-top: 0px; margin-right: 0.333em; margin-left: 0.5em; font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); background-color: rgb(255, 255, 255); position: relative; z-index: 0; ">typedef NSUInteger NSStringCompareOptions;</pre><div>It's not likely that all options here will be the same, but then I would have said the same about enums in general. I don't have a strong opinion, but it's possible we should just change Diagnostic.h to use separate enums. (How common is it to group semi-related constants in an enum?)</div><div><br></div><div>Jordan</div><div><div class="api discussion" style="font-family: 'Lucida Grande', Geneva, Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></div></div></div><br></body></html>