CommandLine.h (226633) | CommandLine.h (234353) |
---|---|
1//===- llvm/Support/CommandLine.h - Command line handler --------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 26 unchanged lines hidden (view full) --- 35/// cl Namespace - This namespace contains all of the command line option 36/// processing machinery. It is intentionally a short name to make qualified 37/// usage concise. 38namespace cl { 39 40//===----------------------------------------------------------------------===// 41// ParseCommandLineOptions - Command line option processing entry point. 42// | 1//===- llvm/Support/CommandLine.h - Command line handler --------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 26 unchanged lines hidden (view full) --- 35/// cl Namespace - This namespace contains all of the command line option 36/// processing machinery. It is intentionally a short name to make qualified 37/// usage concise. 38namespace cl { 39 40//===----------------------------------------------------------------------===// 41// ParseCommandLineOptions - Command line option processing entry point. 42// |
43void ParseCommandLineOptions(int argc, char **argv, | 43void ParseCommandLineOptions(int argc, const char * const *argv, |
44 const char *Overview = 0, 45 bool ReadResponseFiles = false); 46 47//===----------------------------------------------------------------------===// 48// ParseEnvironmentOptions - Environment variable option processing alternate 49// entry point. 50// 51void ParseEnvironmentOptions(const char *progName, const char *envvar, --- 26 unchanged lines hidden (view full) --- 78// MarkOptionsChanged - Internal helper function. 79void MarkOptionsChanged(); 80 81//===----------------------------------------------------------------------===// 82// Flags permitted to be passed to command line arguments 83// 84 85enum NumOccurrencesFlag { // Flags for the number of occurrences allowed | 44 const char *Overview = 0, 45 bool ReadResponseFiles = false); 46 47//===----------------------------------------------------------------------===// 48// ParseEnvironmentOptions - Environment variable option processing alternate 49// entry point. 50// 51void ParseEnvironmentOptions(const char *progName, const char *envvar, --- 26 unchanged lines hidden (view full) --- 78// MarkOptionsChanged - Internal helper function. 79void MarkOptionsChanged(); 80 81//===----------------------------------------------------------------------===// 82// Flags permitted to be passed to command line arguments 83// 84 85enum NumOccurrencesFlag { // Flags for the number of occurrences allowed |
86 Optional = 0x01, // Zero or One occurrence 87 ZeroOrMore = 0x02, // Zero or more occurrences allowed 88 Required = 0x03, // One occurrence required 89 OneOrMore = 0x04, // One or more occurrences required | 86 Optional = 0x00, // Zero or One occurrence 87 ZeroOrMore = 0x01, // Zero or more occurrences allowed 88 Required = 0x02, // One occurrence required 89 OneOrMore = 0x03, // One or more occurrences required |
90 91 // ConsumeAfter - Indicates that this option is fed anything that follows the 92 // last positional argument required by the application (it is an error if 93 // there are zero positional arguments, and a ConsumeAfter option is used). 94 // Thus, for example, all arguments to LLI are processed until a filename is 95 // found. Once a filename is found, all of the succeeding arguments are 96 // passed, unprocessed, to the ConsumeAfter option. 97 // | 90 91 // ConsumeAfter - Indicates that this option is fed anything that follows the 92 // last positional argument required by the application (it is an error if 93 // there are zero positional arguments, and a ConsumeAfter option is used). 94 // Thus, for example, all arguments to LLI are processed until a filename is 95 // found. Once a filename is found, all of the succeeding arguments are 96 // passed, unprocessed, to the ConsumeAfter option. 97 // |
98 ConsumeAfter = 0x05, 99 100 OccurrencesMask = 0x07 | 98 ConsumeAfter = 0x04 |
101}; 102 103enum ValueExpected { // Is a value required for the option? | 99}; 100 101enum ValueExpected { // Is a value required for the option? |
104 ValueOptional = 0x08, // The value can appear... or not 105 ValueRequired = 0x10, // The value is required to appear! 106 ValueDisallowed = 0x18, // A value may not be specified (for flags) 107 ValueMask = 0x18 | 102 // zero reserved for the unspecified value 103 ValueOptional = 0x01, // The value can appear... or not 104 ValueRequired = 0x02, // The value is required to appear! 105 ValueDisallowed = 0x03 // A value may not be specified (for flags) |
108}; 109 110enum OptionHidden { // Control whether -help shows this option | 106}; 107 108enum OptionHidden { // Control whether -help shows this option |
111 NotHidden = 0x20, // Option included in -help & -help-hidden 112 Hidden = 0x40, // -help doesn't, but -help-hidden does 113 ReallyHidden = 0x60, // Neither -help nor -help-hidden show this arg 114 HiddenMask = 0x60 | 109 NotHidden = 0x00, // Option included in -help & -help-hidden 110 Hidden = 0x01, // -help doesn't, but -help-hidden does 111 ReallyHidden = 0x02 // Neither -help nor -help-hidden show this arg |
115}; 116 117// Formatting flags - This controls special features that the option might have 118// that cause it to be parsed differently... 119// 120// Prefix - This option allows arguments that are otherwise unrecognized to be 121// matched by options that are a prefix of the actual value. This is useful for 122// cases like a linker, where options are typically of the form '-lfoo' or 123// '-L../../include' where -l or -L are the actual flags. When prefix is 124// enabled, and used, the value for the flag comes from the suffix of the 125// argument. 126// 127// Grouping - With this option enabled, multiple letter options are allowed to 128// bunch together with only a single hyphen for the whole group. This allows 129// emulation of the behavior that ls uses for example: ls -la === ls -l -a 130// 131 132enum FormattingFlags { | 112}; 113 114// Formatting flags - This controls special features that the option might have 115// that cause it to be parsed differently... 116// 117// Prefix - This option allows arguments that are otherwise unrecognized to be 118// matched by options that are a prefix of the actual value. This is useful for 119// cases like a linker, where options are typically of the form '-lfoo' or 120// '-L../../include' where -l or -L are the actual flags. When prefix is 121// enabled, and used, the value for the flag comes from the suffix of the 122// argument. 123// 124// Grouping - With this option enabled, multiple letter options are allowed to 125// bunch together with only a single hyphen for the whole group. This allows 126// emulation of the behavior that ls uses for example: ls -la === ls -l -a 127// 128 129enum FormattingFlags { |
133 NormalFormatting = 0x000, // Nothing special 134 Positional = 0x080, // Is a positional argument, no '-' required 135 Prefix = 0x100, // Can this option directly prefix its value? 136 Grouping = 0x180, // Can this option group with other options? 137 FormattingMask = 0x180 // Union of the above flags. | 130 NormalFormatting = 0x00, // Nothing special 131 Positional = 0x01, // Is a positional argument, no '-' required 132 Prefix = 0x02, // Can this option directly prefix its value? 133 Grouping = 0x03 // Can this option group with other options? |
138}; 139 140enum MiscFlags { // Miscellaneous flags to adjust argument | 134}; 135 136enum MiscFlags { // Miscellaneous flags to adjust argument |
141 CommaSeparated = 0x200, // Should this cl::list split between commas? 142 PositionalEatsArgs = 0x400, // Should this positional cl::list eat -args? 143 Sink = 0x800, // Should this cl::list eat all unknown options? 144 MiscMask = 0xE00 // Union of the above flags. | 137 CommaSeparated = 0x01, // Should this cl::list split between commas? 138 PositionalEatsArgs = 0x02, // Should this positional cl::list eat -args? 139 Sink = 0x04 // Should this cl::list eat all unknown options? |
145}; 146 147 148 149//===----------------------------------------------------------------------===// 150// Option Base class 151// 152class alias; --- 10 unchanged lines hidden (view full) --- 163 virtual enum ValueExpected getValueExpectedFlagDefault() const { 164 return ValueOptional; 165 } 166 167 // Out of line virtual function to provide home for the class. 168 virtual void anchor(); 169 170 int NumOccurrences; // The number of times specified | 140}; 141 142 143 144//===----------------------------------------------------------------------===// 145// Option Base class 146// 147class alias; --- 10 unchanged lines hidden (view full) --- 158 virtual enum ValueExpected getValueExpectedFlagDefault() const { 159 return ValueOptional; 160 } 161 162 // Out of line virtual function to provide home for the class. 163 virtual void anchor(); 164 165 int NumOccurrences; // The number of times specified |
171 int Flags; // Flags for the argument | 166 // Occurrences, HiddenFlag, and Formatting are all enum types but to avoid 167 // problems with signed enums in bitfields. 168 unsigned Occurrences : 3; // enum NumOccurrencesFlag 169 // not using the enum type for 'Value' because zero is an implementation 170 // detail representing the non-value 171 unsigned Value : 2; 172 unsigned HiddenFlag : 2; // enum OptionHidden 173 unsigned Formatting : 2; // enum FormattingFlags 174 unsigned Misc : 3; |
172 unsigned Position; // Position of last occurrence of the option 173 unsigned AdditionalVals;// Greater than 0 for multi-valued option. 174 Option *NextRegistered; // Singly linked list of registered options. 175public: 176 const char *ArgStr; // The argument string itself (ex: "help", "o") 177 const char *HelpStr; // The descriptive text message for -help 178 const char *ValueStr; // String describing what the value of this option is 179 180 inline enum NumOccurrencesFlag getNumOccurrencesFlag() const { | 175 unsigned Position; // Position of last occurrence of the option 176 unsigned AdditionalVals;// Greater than 0 for multi-valued option. 177 Option *NextRegistered; // Singly linked list of registered options. 178public: 179 const char *ArgStr; // The argument string itself (ex: "help", "o") 180 const char *HelpStr; // The descriptive text message for -help 181 const char *ValueStr; // String describing what the value of this option is 182 183 inline enum NumOccurrencesFlag getNumOccurrencesFlag() const { |
181 return static_cast<enum NumOccurrencesFlag>(Flags & OccurrencesMask); | 184 return (enum NumOccurrencesFlag)Occurrences; |
182 } 183 inline enum ValueExpected getValueExpectedFlag() const { | 185 } 186 inline enum ValueExpected getValueExpectedFlag() const { |
184 int VE = Flags & ValueMask; 185 return VE ? static_cast<enum ValueExpected>(VE) | 187 return Value ? ((enum ValueExpected)Value) |
186 : getValueExpectedFlagDefault(); 187 } 188 inline enum OptionHidden getOptionHiddenFlag() const { | 188 : getValueExpectedFlagDefault(); 189 } 190 inline enum OptionHidden getOptionHiddenFlag() const { |
189 return static_cast<enum OptionHidden>(Flags & HiddenMask); | 191 return (enum OptionHidden)HiddenFlag; |
190 } 191 inline enum FormattingFlags getFormattingFlag() const { | 192 } 193 inline enum FormattingFlags getFormattingFlag() const { |
192 return static_cast<enum FormattingFlags>(Flags & FormattingMask); | 194 return (enum FormattingFlags)Formatting; |
193 } 194 inline unsigned getMiscFlags() const { | 195 } 196 inline unsigned getMiscFlags() const { |
195 return Flags & MiscMask; | 197 return Misc; |
196 } 197 inline unsigned getPosition() const { return Position; } 198 inline unsigned getNumAdditionalVals() const { return AdditionalVals; } 199 200 // hasArgStr - Return true if the argstr != "" 201 bool hasArgStr() const { return ArgStr[0] != 0; } 202 203 //-------------------------------------------------------------------------=== 204 // Accessor functions set by OptionModifiers 205 // 206 void setArgStr(const char *S) { ArgStr = S; } 207 void setDescription(const char *S) { HelpStr = S; } 208 void setValueStr(const char *S) { ValueStr = S; } | 198 } 199 inline unsigned getPosition() const { return Position; } 200 inline unsigned getNumAdditionalVals() const { return AdditionalVals; } 201 202 // hasArgStr - Return true if the argstr != "" 203 bool hasArgStr() const { return ArgStr[0] != 0; } 204 205 //-------------------------------------------------------------------------=== 206 // Accessor functions set by OptionModifiers 207 // 208 void setArgStr(const char *S) { ArgStr = S; } 209 void setDescription(const char *S) { HelpStr = S; } 210 void setValueStr(const char *S) { ValueStr = S; } |
209 210 void setFlag(unsigned Flag, unsigned FlagMask) { 211 Flags &= ~FlagMask; 212 Flags |= Flag; 213 } 214 | |
215 void setNumOccurrencesFlag(enum NumOccurrencesFlag Val) { | 211 void setNumOccurrencesFlag(enum NumOccurrencesFlag Val) { |
216 setFlag(Val, OccurrencesMask); | 212 Occurrences = Val; |
217 } | 213 } |
218 void setValueExpectedFlag(enum ValueExpected Val) { setFlag(Val, ValueMask); } 219 void setHiddenFlag(enum OptionHidden Val) { setFlag(Val, HiddenMask); } 220 void setFormattingFlag(enum FormattingFlags V) { setFlag(V, FormattingMask); } 221 void setMiscFlag(enum MiscFlags M) { setFlag(M, M); } | 214 void setValueExpectedFlag(enum ValueExpected Val) { Value = Val; } 215 void setHiddenFlag(enum OptionHidden Val) { HiddenFlag = Val; } 216 void setFormattingFlag(enum FormattingFlags V) { Formatting = V; } 217 void setMiscFlag(enum MiscFlags M) { Misc |= M; } |
222 void setPosition(unsigned pos) { Position = pos; } 223protected: | 218 void setPosition(unsigned pos) { Position = pos; } 219protected: |
224 explicit Option(unsigned DefaultFlags) 225 : NumOccurrences(0), Flags(DefaultFlags | NormalFormatting), Position(0), | 220 explicit Option(enum NumOccurrencesFlag Occurrences, 221 enum OptionHidden Hidden) 222 : NumOccurrences(0), Occurrences(Occurrences), HiddenFlag(Hidden), 223 Formatting(NormalFormatting), Position(0), |
226 AdditionalVals(0), NextRegistered(0), 227 ArgStr(""), HelpStr(""), ValueStr("") { | 224 AdditionalVals(0), NextRegistered(0), 225 ArgStr(""), HelpStr(""), ValueStr("") { |
228 assert(getNumOccurrencesFlag() != 0 && 229 getOptionHiddenFlag() != 0 && "Not all default flags specified!"); | |
230 } 231 232 inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; } 233public: 234 // addArgument - Register this argument with the commandline system. 235 // 236 void addArgument(); 237 --- 83 unchanged lines hidden (view full) --- 321 322//===----------------------------------------------------------------------===// 323// OptionValue class 324 325// Support value comparison outside the template. 326struct GenericOptionValue { 327 virtual ~GenericOptionValue() {} 328 virtual bool compare(const GenericOptionValue &V) const = 0; | 226 } 227 228 inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; } 229public: 230 // addArgument - Register this argument with the commandline system. 231 // 232 void addArgument(); 233 --- 83 unchanged lines hidden (view full) --- 317 318//===----------------------------------------------------------------------===// 319// OptionValue class 320 321// Support value comparison outside the template. 322struct GenericOptionValue { 323 virtual ~GenericOptionValue() {} 324 virtual bool compare(const GenericOptionValue &V) const = 0; |
325private: 326 virtual void anchor(); |
|
329}; 330 331template<class DataType> struct OptionValue; 332 333// The default value safely does nothing. Option value printing is only 334// best-effort. 335template<class DataType, bool isClass> 336struct OptionValueBase : public GenericOptionValue { 337 // Temporary storage for argument passing. 338 typedef OptionValue<DataType> WrapperType; 339 340 bool hasValue() const { return false; } 341 | 327}; 328 329template<class DataType> struct OptionValue; 330 331// The default value safely does nothing. Option value printing is only 332// best-effort. 333template<class DataType, bool isClass> 334struct OptionValueBase : public GenericOptionValue { 335 // Temporary storage for argument passing. 336 typedef OptionValue<DataType> WrapperType; 337 338 bool hasValue() const { return false; } 339 |
342 const DataType &getValue() const { assert(false && "no default value"); } | 340 const DataType &getValue() const { llvm_unreachable("no default value"); } |
343 344 // Some options may take their value from a different data type. 345 template<class DT> 346 void setValue(const DT& /*V*/) {} 347 348 bool compare(const DataType &/*V*/) const { return false; } 349 350 virtual bool compare(const GenericOptionValue& /*V*/) const { return false; } --- 60 unchanged lines hidden (view full) --- 411 412 OptionValue(const cl::boolOrDefault& V) { 413 this->setValue(V); 414 } 415 OptionValue<cl::boolOrDefault> &operator=(const cl::boolOrDefault& V) { 416 setValue(V); 417 return *this; 418 } | 341 342 // Some options may take their value from a different data type. 343 template<class DT> 344 void setValue(const DT& /*V*/) {} 345 346 bool compare(const DataType &/*V*/) const { return false; } 347 348 virtual bool compare(const GenericOptionValue& /*V*/) const { return false; } --- 60 unchanged lines hidden (view full) --- 409 410 OptionValue(const cl::boolOrDefault& V) { 411 this->setValue(V); 412 } 413 OptionValue<cl::boolOrDefault> &operator=(const cl::boolOrDefault& V) { 414 setValue(V); 415 return *this; 416 } |
417private: 418 virtual void anchor(); |
|
419}; 420 421template<> 422struct OptionValue<std::string> : OptionValueCopy<std::string> { 423 typedef StringRef WrapperType; 424 425 OptionValue() {} 426 427 OptionValue(const std::string& V) { 428 this->setValue(V); 429 } 430 OptionValue<std::string> &operator=(const std::string& V) { 431 setValue(V); 432 return *this; 433 } | 419}; 420 421template<> 422struct OptionValue<std::string> : OptionValueCopy<std::string> { 423 typedef StringRef WrapperType; 424 425 OptionValue() {} 426 427 OptionValue(const std::string& V) { 428 this->setValue(V); 429 } 430 OptionValue<std::string> &operator=(const std::string& V) { 431 setValue(V); 432 return *this; 433 } |
434private: 435 virtual void anchor(); |
|
434}; 435 436//===----------------------------------------------------------------------===// 437// Enum valued command line option 438// 439#define clEnumVal(ENUMVAL, DESC) #ENUMVAL, int(ENUMVAL), DESC 440#define clEnumValN(ENUMVAL, FLAGNAME, DESC) FLAGNAME, int(ENUMVAL), DESC 441#define clEnumValEnd (reinterpret_cast<void*>(0)) --- 724 unchanged lines hidden (view full) --- 1166 template<class T> 1167 DataType &operator=(const T &Val) { 1168 this->setValue(Val); 1169 return this->getValue(); 1170 } 1171 1172 // One option... 1173 template<class M0t> | 436}; 437 438//===----------------------------------------------------------------------===// 439// Enum valued command line option 440// 441#define clEnumVal(ENUMVAL, DESC) #ENUMVAL, int(ENUMVAL), DESC 442#define clEnumValN(ENUMVAL, FLAGNAME, DESC) FLAGNAME, int(ENUMVAL), DESC 443#define clEnumValEnd (reinterpret_cast<void*>(0)) --- 724 unchanged lines hidden (view full) --- 1168 template<class T> 1169 DataType &operator=(const T &Val) { 1170 this->setValue(Val); 1171 return this->getValue(); 1172 } 1173 1174 // One option... 1175 template<class M0t> |
1174 explicit opt(const M0t &M0) : Option(Optional | NotHidden) { | 1176 explicit opt(const M0t &M0) : Option(Optional, NotHidden) { |
1175 apply(M0, this); 1176 done(); 1177 } 1178 1179 // Two options... 1180 template<class M0t, class M1t> | 1177 apply(M0, this); 1178 done(); 1179 } 1180 1181 // Two options... 1182 template<class M0t, class M1t> |
1181 opt(const M0t &M0, const M1t &M1) : Option(Optional | NotHidden) { | 1183 opt(const M0t &M0, const M1t &M1) : Option(Optional, NotHidden) { |
1182 apply(M0, this); apply(M1, this); 1183 done(); 1184 } 1185 1186 // Three options... 1187 template<class M0t, class M1t, class M2t> 1188 opt(const M0t &M0, const M1t &M1, | 1184 apply(M0, this); apply(M1, this); 1185 done(); 1186 } 1187 1188 // Three options... 1189 template<class M0t, class M1t, class M2t> 1190 opt(const M0t &M0, const M1t &M1, |
1189 const M2t &M2) : Option(Optional | NotHidden) { | 1191 const M2t &M2) : Option(Optional, NotHidden) { |
1190 apply(M0, this); apply(M1, this); apply(M2, this); 1191 done(); 1192 } 1193 // Four options... 1194 template<class M0t, class M1t, class M2t, class M3t> 1195 opt(const M0t &M0, const M1t &M1, const M2t &M2, | 1192 apply(M0, this); apply(M1, this); apply(M2, this); 1193 done(); 1194 } 1195 // Four options... 1196 template<class M0t, class M1t, class M2t, class M3t> 1197 opt(const M0t &M0, const M1t &M1, const M2t &M2, |
1196 const M3t &M3) : Option(Optional | NotHidden) { | 1198 const M3t &M3) : Option(Optional, NotHidden) { |
1197 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1198 done(); 1199 } 1200 // Five options... 1201 template<class M0t, class M1t, class M2t, class M3t, class M4t> 1202 opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, | 1199 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1200 done(); 1201 } 1202 // Five options... 1203 template<class M0t, class M1t, class M2t, class M3t, class M4t> 1204 opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, |
1203 const M4t &M4) : Option(Optional | NotHidden) { | 1205 const M4t &M4) : Option(Optional, NotHidden) { |
1204 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1205 apply(M4, this); 1206 done(); 1207 } 1208 // Six options... 1209 template<class M0t, class M1t, class M2t, class M3t, 1210 class M4t, class M5t> 1211 opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, | 1206 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1207 apply(M4, this); 1208 done(); 1209 } 1210 // Six options... 1211 template<class M0t, class M1t, class M2t, class M3t, 1212 class M4t, class M5t> 1213 opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, |
1212 const M4t &M4, const M5t &M5) : Option(Optional | NotHidden) { | 1214 const M4t &M4, const M5t &M5) : Option(Optional, NotHidden) { |
1213 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1214 apply(M4, this); apply(M5, this); 1215 done(); 1216 } 1217 // Seven options... 1218 template<class M0t, class M1t, class M2t, class M3t, 1219 class M4t, class M5t, class M6t> 1220 opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, 1221 const M4t &M4, const M5t &M5, | 1215 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1216 apply(M4, this); apply(M5, this); 1217 done(); 1218 } 1219 // Seven options... 1220 template<class M0t, class M1t, class M2t, class M3t, 1221 class M4t, class M5t, class M6t> 1222 opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, 1223 const M4t &M4, const M5t &M5, |
1222 const M6t &M6) : Option(Optional | NotHidden) { | 1224 const M6t &M6) : Option(Optional, NotHidden) { |
1223 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1224 apply(M4, this); apply(M5, this); apply(M6, this); 1225 done(); 1226 } 1227 // Eight options... 1228 template<class M0t, class M1t, class M2t, class M3t, 1229 class M4t, class M5t, class M6t, class M7t> 1230 opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, 1231 const M4t &M4, const M5t &M5, const M6t &M6, | 1225 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1226 apply(M4, this); apply(M5, this); apply(M6, this); 1227 done(); 1228 } 1229 // Eight options... 1230 template<class M0t, class M1t, class M2t, class M3t, 1231 class M4t, class M5t, class M6t, class M7t> 1232 opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, 1233 const M4t &M4, const M5t &M5, const M6t &M6, |
1232 const M7t &M7) : Option(Optional | NotHidden) { | 1234 const M7t &M7) : Option(Optional, NotHidden) { |
1233 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1234 apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); 1235 done(); 1236 } 1237}; 1238 1239EXTERN_TEMPLATE_INSTANTIATION(class opt<unsigned>); 1240EXTERN_TEMPLATE_INSTANTIATION(class opt<int>); --- 92 unchanged lines hidden (view full) --- 1333 } 1334 1335 void setNumAdditionalVals(unsigned n) { 1336 Option::setNumAdditionalVals(n); 1337 } 1338 1339 // One option... 1340 template<class M0t> | 1235 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1236 apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); 1237 done(); 1238 } 1239}; 1240 1241EXTERN_TEMPLATE_INSTANTIATION(class opt<unsigned>); 1242EXTERN_TEMPLATE_INSTANTIATION(class opt<int>); --- 92 unchanged lines hidden (view full) --- 1335 } 1336 1337 void setNumAdditionalVals(unsigned n) { 1338 Option::setNumAdditionalVals(n); 1339 } 1340 1341 // One option... 1342 template<class M0t> |
1341 explicit list(const M0t &M0) : Option(ZeroOrMore | NotHidden) { | 1343 explicit list(const M0t &M0) : Option(ZeroOrMore, NotHidden) { |
1342 apply(M0, this); 1343 done(); 1344 } 1345 // Two options... 1346 template<class M0t, class M1t> | 1344 apply(M0, this); 1345 done(); 1346 } 1347 // Two options... 1348 template<class M0t, class M1t> |
1347 list(const M0t &M0, const M1t &M1) : Option(ZeroOrMore | NotHidden) { | 1349 list(const M0t &M0, const M1t &M1) : Option(ZeroOrMore, NotHidden) { |
1348 apply(M0, this); apply(M1, this); 1349 done(); 1350 } 1351 // Three options... 1352 template<class M0t, class M1t, class M2t> 1353 list(const M0t &M0, const M1t &M1, const M2t &M2) | 1350 apply(M0, this); apply(M1, this); 1351 done(); 1352 } 1353 // Three options... 1354 template<class M0t, class M1t, class M2t> 1355 list(const M0t &M0, const M1t &M1, const M2t &M2) |
1354 : Option(ZeroOrMore | NotHidden) { | 1356 : Option(ZeroOrMore, NotHidden) { |
1355 apply(M0, this); apply(M1, this); apply(M2, this); 1356 done(); 1357 } 1358 // Four options... 1359 template<class M0t, class M1t, class M2t, class M3t> 1360 list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) | 1357 apply(M0, this); apply(M1, this); apply(M2, this); 1358 done(); 1359 } 1360 // Four options... 1361 template<class M0t, class M1t, class M2t, class M3t> 1362 list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) |
1361 : Option(ZeroOrMore | NotHidden) { | 1363 : Option(ZeroOrMore, NotHidden) { |
1362 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1363 done(); 1364 } 1365 // Five options... 1366 template<class M0t, class M1t, class M2t, class M3t, class M4t> 1367 list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, | 1364 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1365 done(); 1366 } 1367 // Five options... 1368 template<class M0t, class M1t, class M2t, class M3t, class M4t> 1369 list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, |
1368 const M4t &M4) : Option(ZeroOrMore | NotHidden) { | 1370 const M4t &M4) : Option(ZeroOrMore, NotHidden) { |
1369 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1370 apply(M4, this); 1371 done(); 1372 } 1373 // Six options... 1374 template<class M0t, class M1t, class M2t, class M3t, 1375 class M4t, class M5t> 1376 list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, | 1371 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1372 apply(M4, this); 1373 done(); 1374 } 1375 // Six options... 1376 template<class M0t, class M1t, class M2t, class M3t, 1377 class M4t, class M5t> 1378 list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, |
1377 const M4t &M4, const M5t &M5) : Option(ZeroOrMore | NotHidden) { | 1379 const M4t &M4, const M5t &M5) : Option(ZeroOrMore, NotHidden) { |
1378 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1379 apply(M4, this); apply(M5, this); 1380 done(); 1381 } 1382 // Seven options... 1383 template<class M0t, class M1t, class M2t, class M3t, 1384 class M4t, class M5t, class M6t> 1385 list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, 1386 const M4t &M4, const M5t &M5, const M6t &M6) | 1380 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1381 apply(M4, this); apply(M5, this); 1382 done(); 1383 } 1384 // Seven options... 1385 template<class M0t, class M1t, class M2t, class M3t, 1386 class M4t, class M5t, class M6t> 1387 list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, 1388 const M4t &M4, const M5t &M5, const M6t &M6) |
1387 : Option(ZeroOrMore | NotHidden) { | 1389 : Option(ZeroOrMore, NotHidden) { |
1388 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1389 apply(M4, this); apply(M5, this); apply(M6, this); 1390 done(); 1391 } 1392 // Eight options... 1393 template<class M0t, class M1t, class M2t, class M3t, 1394 class M4t, class M5t, class M6t, class M7t> 1395 list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, 1396 const M4t &M4, const M5t &M5, const M6t &M6, | 1390 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1391 apply(M4, this); apply(M5, this); apply(M6, this); 1392 done(); 1393 } 1394 // Eight options... 1395 template<class M0t, class M1t, class M2t, class M3t, 1396 class M4t, class M5t, class M6t, class M7t> 1397 list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, 1398 const M4t &M4, const M5t &M5, const M6t &M6, |
1397 const M7t &M7) : Option(ZeroOrMore | NotHidden) { | 1399 const M7t &M7) : Option(ZeroOrMore, NotHidden) { |
1398 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1399 apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); 1400 done(); 1401 } 1402}; 1403 1404// multi_val - Modifier to set the number of additional values. 1405struct multi_val { --- 125 unchanged lines hidden (view full) --- 1531 1532 unsigned getPosition(unsigned optnum) const { 1533 assert(optnum < this->size() && "Invalid option index"); 1534 return Positions[optnum]; 1535 } 1536 1537 // One option... 1538 template<class M0t> | 1400 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1401 apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); 1402 done(); 1403 } 1404}; 1405 1406// multi_val - Modifier to set the number of additional values. 1407struct multi_val { --- 125 unchanged lines hidden (view full) --- 1533 1534 unsigned getPosition(unsigned optnum) const { 1535 assert(optnum < this->size() && "Invalid option index"); 1536 return Positions[optnum]; 1537 } 1538 1539 // One option... 1540 template<class M0t> |
1539 explicit bits(const M0t &M0) : Option(ZeroOrMore | NotHidden) { | 1541 explicit bits(const M0t &M0) : Option(ZeroOrMore, NotHidden) { |
1540 apply(M0, this); 1541 done(); 1542 } 1543 // Two options... 1544 template<class M0t, class M1t> | 1542 apply(M0, this); 1543 done(); 1544 } 1545 // Two options... 1546 template<class M0t, class M1t> |
1545 bits(const M0t &M0, const M1t &M1) : Option(ZeroOrMore | NotHidden) { | 1547 bits(const M0t &M0, const M1t &M1) : Option(ZeroOrMore, NotHidden) { |
1546 apply(M0, this); apply(M1, this); 1547 done(); 1548 } 1549 // Three options... 1550 template<class M0t, class M1t, class M2t> 1551 bits(const M0t &M0, const M1t &M1, const M2t &M2) | 1548 apply(M0, this); apply(M1, this); 1549 done(); 1550 } 1551 // Three options... 1552 template<class M0t, class M1t, class M2t> 1553 bits(const M0t &M0, const M1t &M1, const M2t &M2) |
1552 : Option(ZeroOrMore | NotHidden) { | 1554 : Option(ZeroOrMore, NotHidden) { |
1553 apply(M0, this); apply(M1, this); apply(M2, this); 1554 done(); 1555 } 1556 // Four options... 1557 template<class M0t, class M1t, class M2t, class M3t> 1558 bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) | 1555 apply(M0, this); apply(M1, this); apply(M2, this); 1556 done(); 1557 } 1558 // Four options... 1559 template<class M0t, class M1t, class M2t, class M3t> 1560 bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) |
1559 : Option(ZeroOrMore | NotHidden) { | 1561 : Option(ZeroOrMore, NotHidden) { |
1560 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1561 done(); 1562 } 1563 // Five options... 1564 template<class M0t, class M1t, class M2t, class M3t, class M4t> 1565 bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, | 1562 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1563 done(); 1564 } 1565 // Five options... 1566 template<class M0t, class M1t, class M2t, class M3t, class M4t> 1567 bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, |
1566 const M4t &M4) : Option(ZeroOrMore | NotHidden) { | 1568 const M4t &M4) : Option(ZeroOrMore, NotHidden) { |
1567 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1568 apply(M4, this); 1569 done(); 1570 } 1571 // Six options... 1572 template<class M0t, class M1t, class M2t, class M3t, 1573 class M4t, class M5t> 1574 bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, | 1569 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1570 apply(M4, this); 1571 done(); 1572 } 1573 // Six options... 1574 template<class M0t, class M1t, class M2t, class M3t, 1575 class M4t, class M5t> 1576 bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, |
1575 const M4t &M4, const M5t &M5) : Option(ZeroOrMore | NotHidden) { | 1577 const M4t &M4, const M5t &M5) : Option(ZeroOrMore, NotHidden) { |
1576 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1577 apply(M4, this); apply(M5, this); 1578 done(); 1579 } 1580 // Seven options... 1581 template<class M0t, class M1t, class M2t, class M3t, 1582 class M4t, class M5t, class M6t> 1583 bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, 1584 const M4t &M4, const M5t &M5, const M6t &M6) | 1578 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1579 apply(M4, this); apply(M5, this); 1580 done(); 1581 } 1582 // Seven options... 1583 template<class M0t, class M1t, class M2t, class M3t, 1584 class M4t, class M5t, class M6t> 1585 bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, 1586 const M4t &M4, const M5t &M5, const M6t &M6) |
1585 : Option(ZeroOrMore | NotHidden) { | 1587 : Option(ZeroOrMore, NotHidden) { |
1586 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1587 apply(M4, this); apply(M5, this); apply(M6, this); 1588 done(); 1589 } 1590 // Eight options... 1591 template<class M0t, class M1t, class M2t, class M3t, 1592 class M4t, class M5t, class M6t, class M7t> 1593 bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, 1594 const M4t &M4, const M5t &M5, const M6t &M6, | 1588 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1589 apply(M4, this); apply(M5, this); apply(M6, this); 1590 done(); 1591 } 1592 // Eight options... 1593 template<class M0t, class M1t, class M2t, class M3t, 1594 class M4t, class M5t, class M6t, class M7t> 1595 bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, 1596 const M4t &M4, const M5t &M5, const M6t &M6, |
1595 const M7t &M7) : Option(ZeroOrMore | NotHidden) { | 1597 const M7t &M7) : Option(ZeroOrMore, NotHidden) { |
1596 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1597 apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); 1598 done(); 1599 } 1600}; 1601 1602//===----------------------------------------------------------------------===// 1603// Aliased command line option (alias this name to a preexisting name) --- 23 unchanged lines hidden (view full) --- 1627 void setAliasFor(Option &O) { 1628 if (AliasFor) 1629 error("cl::alias must only have one cl::aliasopt(...) specified!"); 1630 AliasFor = &O; 1631 } 1632 1633 // One option... 1634 template<class M0t> | 1598 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1599 apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); 1600 done(); 1601 } 1602}; 1603 1604//===----------------------------------------------------------------------===// 1605// Aliased command line option (alias this name to a preexisting name) --- 23 unchanged lines hidden (view full) --- 1629 void setAliasFor(Option &O) { 1630 if (AliasFor) 1631 error("cl::alias must only have one cl::aliasopt(...) specified!"); 1632 AliasFor = &O; 1633 } 1634 1635 // One option... 1636 template<class M0t> |
1635 explicit alias(const M0t &M0) : Option(Optional | Hidden), AliasFor(0) { | 1637 explicit alias(const M0t &M0) : Option(Optional, Hidden), AliasFor(0) { |
1636 apply(M0, this); 1637 done(); 1638 } 1639 // Two options... 1640 template<class M0t, class M1t> | 1638 apply(M0, this); 1639 done(); 1640 } 1641 // Two options... 1642 template<class M0t, class M1t> |
1641 alias(const M0t &M0, const M1t &M1) : Option(Optional | Hidden), AliasFor(0) { | 1643 alias(const M0t &M0, const M1t &M1) : Option(Optional, Hidden), AliasFor(0) { |
1642 apply(M0, this); apply(M1, this); 1643 done(); 1644 } 1645 // Three options... 1646 template<class M0t, class M1t, class M2t> 1647 alias(const M0t &M0, const M1t &M1, const M2t &M2) | 1644 apply(M0, this); apply(M1, this); 1645 done(); 1646 } 1647 // Three options... 1648 template<class M0t, class M1t, class M2t> 1649 alias(const M0t &M0, const M1t &M1, const M2t &M2) |
1648 : Option(Optional | Hidden), AliasFor(0) { | 1650 : Option(Optional, Hidden), AliasFor(0) { |
1649 apply(M0, this); apply(M1, this); apply(M2, this); 1650 done(); 1651 } 1652 // Four options... 1653 template<class M0t, class M1t, class M2t, class M3t> 1654 alias(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) | 1651 apply(M0, this); apply(M1, this); apply(M2, this); 1652 done(); 1653 } 1654 // Four options... 1655 template<class M0t, class M1t, class M2t, class M3t> 1656 alias(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) |
1655 : Option(Optional | Hidden), AliasFor(0) { | 1657 : Option(Optional, Hidden), AliasFor(0) { |
1656 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1657 done(); 1658 } 1659}; 1660 1661// aliasfor - Modifier to set the option an alias aliases. 1662struct aliasopt { 1663 Option &Opt; --- 24 unchanged lines hidden --- | 1658 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); 1659 done(); 1660 } 1661}; 1662 1663// aliasfor - Modifier to set the option an alias aliases. 1664struct aliasopt { 1665 Option &Opt; --- 24 unchanged lines hidden --- |