aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-20 01:53:12 +0000
committerChris Lattner <sabre@nondot.org>2009-09-20 01:53:12 +0000
commit4e247ec4952db1e39b4cc074a38b9f1d52cdaa28 (patch)
tree4593c6365ecf1a96a7b08a80691199b04eb9c77e /lib/Support
parent341620b2762e604fbf8c75913a1cc5b9c9297b7d (diff)
downloadexternal_llvm-4e247ec4952db1e39b4cc074a38b9f1d52cdaa28.zip
external_llvm-4e247ec4952db1e39b4cc074a38b9f1d52cdaa28.tar.gz
external_llvm-4e247ec4952db1e39b4cc074a38b9f1d52cdaa28.tar.bz2
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
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/CommandLine.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index eb49153..f44ed41 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -151,7 +151,7 @@ static void GetOptionInfo(std::vector<Option*> &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<Option*> &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...