diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-01-23 23:27:47 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-01-23 23:27:47 +0000 |
commit | 153c8adc496466972c5d742507156b0257078543 (patch) | |
tree | 0309a47e206c712a78f82919950188278329c0b9 /include | |
parent | c387fc66bd52e4276fdc2704a3aaed57cc1f9a11 (diff) | |
download | external_llvm-153c8adc496466972c5d742507156b0257078543.zip external_llvm-153c8adc496466972c5d742507156b0257078543.tar.gz external_llvm-153c8adc496466972c5d742507156b0257078543.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148746 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Support/CommandLine.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index dfa5844..65b3497 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -163,12 +163,14 @@ class Option { 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 @@ public: 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; |