X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSupport%2FCommandLine.h;h=3ae50136e4a9d38ae2d0b87c3a4351d98463ffde;hb=0eac0164c259fb4a9d824361029f175e3eeede5c;hp=def5ce750140931b2fab777b771dc9f3cc5c3f70;hpb=d64e0eb094a108bdcdf51328425904042aa6122b;p=oota-llvm.git diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index def5ce75014..3ae50136e4a 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -25,6 +25,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/ADT/SmallVector.h" #include +#include #include #include #include @@ -126,8 +127,7 @@ enum MiscFlags { // Miscellaneous flags to adjust argument CommaSeparated = 0x200, // Should this cl::list split between commas? PositionalEatsArgs = 0x400, // Should this positional cl::list eat -args? Sink = 0x800, // Should this cl::list eat all unknown options? - AllowInverse = 0x1000, // Can this option take a -Xno- form? - MiscMask = 0x1E00 // Union of the above flags. + MiscMask = 0xE00 // Union of the above flags. }; @@ -537,30 +537,14 @@ struct basic_parser : public basic_parser_impl { // template<> class parser : public basic_parser { - bool IsInvertable; // Should we synthezise a -xno- style option? const char *ArgStr; public: - void getExtraOptionNames(std::vector &OptionNames) { - if (IsInvertable) { - char *s = new char [strlen(ArgStr) + 3 + 1]; - s[0] = ArgStr[0]; - s[1] = 'n'; - s[2] = 'o'; - s[3] = '-'; - strcpy(&s[4], ArgStr+1); - OptionNames.push_back(s); - } - } // parse - Return true on error. bool parse(Option &O, const char *ArgName, const std::string &Arg, bool &Val); template void initialize(Opt &O) { - if (O.getMiscFlags() & llvm::cl::AllowInverse) - IsInvertable = true; - else - IsInvertable = false; ArgStr = O.ArgStr; } @@ -695,6 +679,28 @@ public: EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); +//-------------------------------------------------- +// parser +// +template<> +class parser : public basic_parser { +public: + // parse - Return true on error. + bool parse(Option &, const char *, const std::string &Arg, + char &Value) { + Value = Arg[0]; + return false; + } + + // getValueName - Overload in subclass to provide a better default value. + virtual const char *getValueName() const { return "char"; } + + // An out-of-line virtual method to provide a 'home' for this class. + virtual void anchor(); +}; + +EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); + //===----------------------------------------------------------------------===// // applicator class - This class is used because we must use partial // specialization to handle literal string arguments specially (const char* does @@ -754,7 +760,7 @@ template class opt_storage { DataType *Location; // Where to store the object... - void check() { + void check() const { assert(Location != 0 && "cl::location(...) not specified for a command " "line option with external storage, " "or cl::init specified before cl::location()!!"); @@ -833,8 +839,8 @@ class opt : public Option, typename ParserClass::parser_data_type(); if (Parser.parse(*this, ArgName, Arg, Val)) return true; // Parse error! - setValue(Val); - setPosition(pos); + this->setValue(Val); + this->setPosition(pos); return false; } @@ -939,6 +945,7 @@ public: EXTERN_TEMPLATE_INSTANTIATION(class opt); EXTERN_TEMPLATE_INSTANTIATION(class opt); EXTERN_TEMPLATE_INSTANTIATION(class opt); +EXTERN_TEMPLATE_INSTANTIATION(class opt); EXTERN_TEMPLATE_INSTANTIATION(class opt); //===----------------------------------------------------------------------===// @@ -1098,7 +1105,7 @@ public: } }; -// multi_arg - Modifier to set the number of additional values. +// multi_val - Modifier to set the number of additional values. struct multi_val { unsigned AdditionalVals; explicit multi_val(unsigned N) : AdditionalVals(N) {} @@ -1122,7 +1129,7 @@ class bits_storage { template static unsigned Bit(const T &V) { unsigned BitPos = reinterpret_cast(V); - assert(BitPos < sizeof(unsigned) * 8 && + assert(BitPos < sizeof(unsigned) * CHAR_BIT && "enum exceeds width of bit vector!"); return 1 << BitPos; } @@ -1163,7 +1170,7 @@ class bits_storage { template static unsigned Bit(const T &V) { unsigned BitPos = reinterpret_cast(V); - assert(BitPos < sizeof(unsigned) * 8 && + assert(BitPos < sizeof(unsigned) * CHAR_BIT && "enum exceeds width of bit vector!"); return 1 << BitPos; }