diff options
Diffstat (limited to 'llvm/lib/Option/OptTable.cpp')
-rw-r--r-- | llvm/lib/Option/OptTable.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp index a994a42..2770f4d41 100644 --- a/llvm/lib/Option/OptTable.cpp +++ b/llvm/lib/Option/OptTable.cpp @@ -376,14 +376,23 @@ Arg *OptTable::parseOneArgGrouped(InputArgList &Args, unsigned &Index) const { if (Fallback) { Option Opt(Fallback, this); if (Arg *A = Opt.accept(Args, Str.substr(0, 2), true, Index)) { - if (Str.size() == 2) - ++Index; - else - Args.replaceArgString(Index, Twine('-') + Str.substr(2)); + // Check that the last option isn't a flag wrongly given an argument. + if (Str[2] == '=') + return new Arg(getOption(TheUnknownOptionID), Str, Index++, CStr); + + Args.replaceArgString(Index, Twine('-') + Str.substr(2)); return A; } } + // In the case of an incorrect short option extract the character and move to + // the next one. + if (Str[1] != '-') { + CStr = Args.MakeArgString(Str.substr(0, 2)); + Args.replaceArgString(Index, Twine('-') + Str.substr(2)); + return new Arg(getOption(TheUnknownOptionID), CStr, Index, CStr); + } + return new Arg(getOption(TheUnknownOptionID), Str, Index++, CStr); } |