diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-05 06:38:47 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-05 06:38:47 +0000 |
commit | 0648262df75d97b464c2be0ed867da3615659785 (patch) | |
tree | 1e1849d82dde933f81af038abce15e470f1dfcad /lib/Driver/Option.cpp | |
parent | f27893a1a17dbde417dc7bccbbd25992c33215f9 (diff) |
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
Diffstat (limited to 'lib/Driver/Option.cpp')
-rw-r--r-- | lib/Driver/Option.cpp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/lib/Driver/Option.cpp b/lib/Driver/Option.cpp index 43d7e9e476..73cef25a55 100644 --- a/lib/Driver/Option.cpp +++ b/lib/Driver/Option.cpp @@ -127,7 +127,7 @@ Arg *FlagOption::accept(const ArgList &Args, unsigned &Index) const { 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 @@ Arg *CommaJoinedOption::accept(const ArgList &Args, unsigned &Index) const { // 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, |