From 00a7b52385a25ab8cd412ce4c0f0ce11176b6793 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 8 Apr 2009 03:43:51 +0000 Subject: [PATCH] Remove AllowInverse: it leaks memory and is not the right abstraction for CommandLine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68588 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/CommandLine.html | 17 +---------------- include/llvm/Support/CommandLine.h | 6 +----- lib/Support/CommandLine.cpp | 21 --------------------- 3 files changed, 2 insertions(+), 42 deletions(-) diff --git a/docs/CommandLine.html b/docs/CommandLine.html index 013ff27d192..74cf389894a 100644 --- a/docs/CommandLine.html +++ b/docs/CommandLine.html @@ -1447,17 +1447,6 @@ unrecognized option strings to it as values instead of signaling an error. As with cl::CommaSeparated, this modifier only makes sense with a cl::list option. -
  • The cl::AllowInverse -modifier can be used on options that have the form -fopt to -automatically create a corresponding --fno-opt option. The f can be any single -character, and the opt can be any one or more characters. -The value of the created option is the logical complement of the value -that would have been used if the base form of the option was used. -This modifier only makes sense with an option that uses -a bool parser.
  • - -

    So far, these are the only three miscellaneous option modifiers.

    @@ -1755,11 +1744,7 @@ for any data type.
  • The parser<bool> specialization is used to convert boolean strings to a boolean value. Currently accepted strings are "true", "TRUE", "True", "1", -"false", "FALSE", "False", and "0". The -cl::AllowInverse modifier can be used on an option of the form --fopt that uses the parser<bool> specialization -to create a corresponding option with the form -fno-opt. See -cl::AllowInverse for details.
  • +"false", "FALSE", "False", and "0".
  • The parser<boolOrDefault> specialization is used for cases where the value is boolean, diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 6b05e602eff..1b625588d28 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -127,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. }; @@ -538,17 +537,14 @@ struct basic_parser : public basic_parser_impl { // template<> class parser : public basic_parser { - bool IsInvertible; // Should we synthesize a -xno- style option? const char *ArgStr; public: - void getExtraOptionNames(std::vector &OptionNames); // parse - Return true on error. bool parse(Option &O, const char *ArgName, const std::string &Arg, bool &Val); template void initialize(Opt &O) { - IsInvertible = (O.getMiscFlags() & llvm::cl::AllowInverse); ArgStr = O.ArgStr; } diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 710b210ab99..e4f65ba1de9 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -872,30 +872,9 @@ bool parser::parse(Option &O, const char *ArgName, return O.error(": '" + Arg + "' is invalid value for boolean argument! Try 0 or 1"); } - if (IsInvertible && strncmp(ArgName+1, "no-", 3) == 0) - Value = !Value; return false; } -void parser::getExtraOptionNames(std::vector &OptionNames) { - if (!IsInvertible) - return; - - char *s = new char [strlen(ArgStr) + 3 + 1]; - s[0] = ArgStr[0]; - if (strncmp(ArgStr+1, "no-", 3) == 0) - strcpy(&s[1], &ArgStr[4]); - else { - s[1] = 'n'; - s[2] = 'o'; - s[3] = '-'; - strcpy(&s[4], ArgStr+1); - } - OptionNames.push_back(s); -} - - - // parser implementation // bool parser::parse(Option &O, const char *ArgName,