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
diff --git a/lib/Driver/Option.cpp b/lib/Driver/Option.cpp
index 17d00f5..5a967ea 100644
--- a/lib/Driver/Option.cpp
+++ b/lib/Driver/Option.cpp
@@ -133,7 +133,7 @@
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 @@
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 @@
// 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 @@
if (Index > Args.getNumInputArgStrings())
return 0;
- return new JoinedAndSeparateArg(this, Index - 2);
+ return new JoinedAndSeparateArg(this, Index - 2, strlen(getName()));
}