Fix error handling in Options::Parse

Moved `if (error.Fail())` to correct place to catch all faulty cases such as
"unknown or ambiguous option" which was ignored before.

llvm-svn: 354883
This commit is contained in:
Tatyana Krasnukha 2019-02-26 14:50:40 +00:00
parent 8cb497027d
commit f388d17d7c
1 changed files with 3 additions and 2 deletions

View File

@ -1436,10 +1436,11 @@ llvm::Expected<Args> Options::Parse(const Args &args,
} else {
error.SetErrorStringWithFormat("invalid option with value '%i'", val);
}
if (error.Fail())
return error.ToError();
}
if (error.Fail())
return error.ToError();
argv.erase(argv.begin(), argv.begin() + OptionParser::GetOptionIndex());
return ReconstituteArgsAfterParsing(argv, args);
}