From 4e247ec4952db1e39b4cc074a38b9f1d52cdaa28 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 20 Sep 2009 01:53:12 +0000 Subject: [PATCH] convert 'Value' to StringRef which makes it easier to maintain the "null is unspecified, empty is empty" semantics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82351 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index eb49153e7d0..f44ed41aa3b 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -151,7 +151,7 @@ static void GetOptionInfo(std::vector &PositionalOpts, /// LookupOption - Lookup the option specified by the specified option on the /// command line. If there is a value specified (after an equal sign) return /// that as well. -static Option *LookupOption(const char *&Arg, const char *&Value, +static Option *LookupOption(const char *&Arg, StringRef &Value, StringMap &OptionsMap) { while (*Arg == '-') ++Arg; // Eat leading dashes @@ -159,9 +159,9 @@ static Option *LookupOption(const char *&Arg, const char *&Value, while (*ArgEnd && *ArgEnd != '=') ++ArgEnd; // Scan till end of argument name. - if (*ArgEnd == '=') // If we have an equals sign... - Value = ArgEnd+1; // Get the value, not the equals - + // If we have an equals sign, remember the value. + if (*ArgEnd == '=') + Value = ArgEnd+1; if (*Arg == 0) return 0; @@ -485,7 +485,7 @@ void cl::ParseCommandLineOptions(int argc, char **argv, bool DashDashFound = false; // Have we read '--'? for (int i = 1; i < argc; ++i) { Option *Handler = 0; - const char *Value = 0; + StringRef Value; const char *ArgName = ""; // If the option list changed, this means that some command line @@ -606,7 +606,7 @@ void cl::ParseCommandLineOptions(int argc, char **argv, // Check to see if this option accepts a comma separated list of values. If // it does, we have to split up the value into multiple values. - if (Value && Handler->getMiscFlags() & CommaSeparated) { + if (Handler->getMiscFlags() & CommaSeparated) { StringRef Val(Value); StringRef::size_type Pos = Val.find(','); @@ -616,7 +616,7 @@ void cl::ParseCommandLineOptions(int argc, char **argv, argc, argv, i); // Erase the portion before the comma, AND the comma. Val = Val.substr(Pos+1); - Value += Pos+1; // Increment the original value pointer as well. + Value.substr(Pos+1); // Increment the original value pointer as well. // Check for another comma. Pos = Val.find(','); @@ -627,12 +627,8 @@ void cl::ParseCommandLineOptions(int argc, char **argv, // active one... if (Handler->getFormattingFlag() == cl::Positional) ActivePositionalArg = Handler; - else if (Value) - ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); else - ErrorParsing |= ProvideOption(Handler, ArgName, StringRef(), - argc, argv, i); - + ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); } // Check and handle positional arguments now... -- 2.34.1