diff options
author | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-01-27 09:02:46 +0000 |
---|---|---|
committer | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-01-27 09:02:46 +0000 |
commit | 5cb1193075d5837b0c7ce8252c10c29b14a59773 (patch) | |
tree | 70f0dbb8db1679cfb642900efc4029b14ef1478e /llvm/lib/Support/CommandLine.cpp | |
parent | 447abc57c554fd8fff14a52d32e68dff9a47cc5b (diff) | |
download | llvm-5cb1193075d5837b0c7ce8252c10c29b14a59773.zip llvm-5cb1193075d5837b0c7ce8252c10c29b14a59773.tar.gz llvm-5cb1193075d5837b0c7ce8252c10c29b14a59773.tar.bz2 |
Revert "Add support for prefix-only CLI options"
This reverts commit r351038.
llvm-svn: 352310
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 271a628..f8bc6a8 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -425,17 +425,12 @@ Option *CommandLineParser::LookupOption(SubCommand &Sub, StringRef &Arg, return I != Sub.OptionsMap.end() ? I->second : nullptr; } - // If the argument before the = is a valid option name and the option allows - // non-prefix form (ie is not AlwaysPrefix), we match. If not, signal match - // failure by returning nullptr. + // If the argument before the = is a valid option name, we match. If not, + // return Arg unmolested. auto I = Sub.OptionsMap.find(Arg.substr(0, EqualPos)); if (I == Sub.OptionsMap.end()) return nullptr; - auto O = I->second; - if (O->getFormattingFlag() == cl::AlwaysPrefix) - return nullptr; - Value = Arg.substr(EqualPos + 1); Arg = Arg.substr(0, EqualPos); return I->second; @@ -543,9 +538,7 @@ static inline bool ProvideOption(Option *Handler, StringRef ArgName, switch (Handler->getValueExpectedFlag()) { case ValueRequired: if (!Value.data()) { // No value specified? - // If no other argument or the option only supports prefix form, we - // cannot look at the next argument. - if (i + 1 >= argc || Handler->getFormattingFlag() == cl::AlwaysPrefix) + if (i + 1 >= argc) return Handler->error("requires a value!"); // Steal the next argument, like for '-o filename' assert(argv && "null check"); @@ -603,8 +596,7 @@ static inline bool isGrouping(const Option *O) { return O->getFormattingFlag() == cl::Grouping; } static inline bool isPrefixedOrGrouping(const Option *O) { - return isGrouping(O) || O->getFormattingFlag() == cl::Prefix || - O->getFormattingFlag() == cl::AlwaysPrefix; + return isGrouping(O) || O->getFormattingFlag() == cl::Prefix; } // getOptionPred - Check to see if there are any options that satisfy the @@ -654,8 +646,7 @@ HandlePrefixedOrGroupedOption(StringRef &Arg, StringRef &Value, // If the option is a prefixed option, then the value is simply the // rest of the name... so fall through to later processing, by // setting up the argument name flags and value fields. - if (PGOpt->getFormattingFlag() == cl::Prefix || - PGOpt->getFormattingFlag() == cl::AlwaysPrefix) { + if (PGOpt->getFormattingFlag() == cl::Prefix) { Value = Arg.substr(Length); Arg = Arg.substr(0, Length); assert(OptionsMap.count(Arg) && OptionsMap.find(Arg)->second == PGOpt); |