aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Option.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-06-09 18:49:38 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-06-09 18:49:38 +0000
commit312a8b726e24078d3bd3b2328f9f895d1407cdb7 (patch)
tree5170f5e2111c978f108af2f284cfcceeee5a125c /lib/Driver/Option.cpp
parenta3f28c341a1b69fc1b8deefb4f9abd64ac949ec1 (diff)
Driver: Add an explicit offset to JoinedArg and JoinedAndSeparateArg, so that
they can be independent of the exact option that created them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105739 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Option.cpp')
-rw-r--r--lib/Driver/Option.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Driver/Option.cpp b/lib/Driver/Option.cpp
index 17d00f50aa..5a967ea3df 100644
--- a/lib/Driver/Option.cpp
+++ b/lib/Driver/Option.cpp
@@ -133,7 +133,7 @@ JoinedOption::JoinedOption(OptSpecifier ID, const char *Name,
Arg *JoinedOption::accept(const InputArgList &Args, unsigned &Index) const {
// Always matches.
- return new JoinedArg(this, Index++);
+ return new JoinedArg(this, Index++, strlen(getName()));
}
CommaJoinedOption::CommaJoinedOption(OptSpecifier ID, const char *Name,
@@ -191,7 +191,8 @@ Arg *MultiArgOption::accept(const InputArgList &Args, unsigned &Index) const {
return new SeparateArg(this, Index - 1 - NumArgs, NumArgs);
}
-JoinedOrSeparateOption::JoinedOrSeparateOption(OptSpecifier ID, const char *Name,
+JoinedOrSeparateOption::JoinedOrSeparateOption(OptSpecifier ID,
+ const char *Name,
const OptionGroup *Group,
const Option *Alias)
: Option(Option::JoinedOrSeparateClass, ID, Name, Group, Alias) {
@@ -202,7 +203,7 @@ Arg *JoinedOrSeparateOption::accept(const InputArgList &Args,
// If this is not an exact match, it is a joined arg.
// FIXME: Avoid strlen.
if (strlen(getName()) != strlen(Args.getArgString(Index)))
- return new JoinedArg(this, Index++);
+ return new JoinedArg(this, Index++, strlen(getName()));
// Otherwise it must be separate.
Index += 2;
@@ -227,6 +228,6 @@ Arg *JoinedAndSeparateOption::accept(const InputArgList &Args,
if (Index > Args.getNumInputArgStrings())
return 0;
- return new JoinedAndSeparateArg(this, Index - 2);
+ return new JoinedAndSeparateArg(this, Index - 2, strlen(getName()));
}