Driver: Basic argument parsing.
- Add Driver::ParseArgStrings.
- Store values directly in CommaJoinedArg to support simple access.
- Add FlagArg class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66142 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Option.cpp b/lib/Driver/Option.cpp
index 43d7e9e..73cef25 100644
--- a/lib/Driver/Option.cpp
+++ b/lib/Driver/Option.cpp
@@ -127,7 +127,7 @@
if (strlen(getName()) != strlen(Args.getArgString(Index)))
return 0;
- return new PositionalArg(this, Index++);
+ return new FlagArg(this, Index++);
}
JoinedOption::JoinedOption(options::ID ID, const char *Name,
@@ -153,14 +153,7 @@
// Get the suffix string.
// FIXME: Avoid strlen, and move to helper method?
const char *Suffix = Args.getArgString(Index) + strlen(getName());
- const char *SuffixEnd = Suffix + strlen(Suffix);
-
- // Degenerate case, exact match has no values.
- if (Suffix == SuffixEnd)
- return new CommaJoinedArg(this, Index++, 0);
-
- return new CommaJoinedArg(this, Index++,
- std::count(Suffix, SuffixEnd, ',') + 1);
+ return new CommaJoinedArg(this, Index++, Suffix);
}
SeparateOption::SeparateOption(options::ID ID, const char *Name,