[llvm-commits] [llvm] r148746 - /llvm/trunk/include/llvm/Support/CommandLine.h

David Blaikie dblaikie at gmail.com
Mon Jan 23 15:27:47 PST 2012


Author: dblaikie
Date: Mon Jan 23 17:27:47 2012
New Revision: 148746

URL: http://llvm.org/viewvc/llvm-project?rev=148746&view=rev
Log:
Changing bitfield enums to unsigned ints.

This was suggested by Chandler Carruth on the basis of past experience with
esoteric compilers/quirks relating to signed enums.

Modified:
    llvm/trunk/include/llvm/Support/CommandLine.h

Modified: llvm/trunk/include/llvm/Support/CommandLine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=148746&r1=148745&r2=148746&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/CommandLine.h (original)
+++ llvm/trunk/include/llvm/Support/CommandLine.h Mon Jan 23 17:27:47 2012
@@ -163,12 +163,14 @@
   virtual void anchor();
 
   int NumOccurrences;     // The number of times specified
-  enum NumOccurrencesFlag Occurrences : 3;
+  // Occurrences, HiddenFlag, and Formatting are all enum types but to avoid
+  // with signed enums in bitfields in MSVC we'll store them as unsigned
+  unsigned Occurrences : 3; // enum NumOccurrencesFlag
   // not using the enum type for 'Value' because zero is an implementation
   // detail representing the non-value
   unsigned Value : 2;
-  enum OptionHidden HiddenFlag : 2;
-  enum FormattingFlags Formatting : 2;
+  unsigned HiddenFlag : 2; // enum OptionHidden
+  unsigned Formatting : 2; // enum FormattingFlags
   unsigned Misc : 3;
   unsigned Position;      // Position of last occurrence of the option
   unsigned AdditionalVals;// Greater than 0 for multi-valued option.
@@ -179,17 +181,17 @@
   const char *ValueStr;   // String describing what the value of this option is
 
   inline enum NumOccurrencesFlag getNumOccurrencesFlag() const {
-    return Occurrences;
+    return (enum NumOccurrencesFlag)Occurrences;
   }
   inline enum ValueExpected getValueExpectedFlag() const {
-    return Value ? static_cast<enum ValueExpected>(Value)
+    return Value ? ((enum ValueExpected)Value)
               : getValueExpectedFlagDefault();
   }
   inline enum OptionHidden getOptionHiddenFlag() const {
-    return HiddenFlag;
+    return (enum OptionHidden)HiddenFlag;
   }
   inline enum FormattingFlags getFormattingFlag() const {
-    return Formatting;
+    return (enum FormattingFlags)Formatting;
   }
   inline unsigned getMiscFlags() const {
     return Misc;





More information about the llvm-commits mailing list