[dsymutil] Print warning/error for unknown/missing arguments.

After changing dsymutil to use libOption, we lost error reporting for
missing required arguments (input files). Additionally, we stopped
complaining about unknown arguments. This patch fixes both and adds a
test.

llvm-svn: 375044
This commit is contained in:
Jonas Devlieghere 2019-10-16 21:48:41 +00:00
parent ebf24ce8e1
commit 490dcffb69
2 changed files with 16 additions and 0 deletions

View File

@ -26,3 +26,9 @@ HELP-NOT: -reverse-iterate
RUN: dsymutil --version 2>&1 | FileCheck --check-prefix=VERSION %s
VERSION: {{ version }}
RUN: not dsymutil 2>&1 | FileCheck --check-prefix=NOINPUT %s
NOINPUT: error: no input files specified
RUN: dsymutil -bogus -help 2>&1 | FileCheck --check-prefix=BOGUS %s
BOGUS: warning: ignoring unknown option: -bogus

View File

@ -148,6 +148,11 @@ static Expected<std::vector<std::string>> getInputs(opt::InputArgList &Args,
// Verify that the given combination of options makes sense.
static Error verifyOptions(const DsymutilOptions &Options) {
if (Options.InputFiles.empty()) {
return make_error<StringError>("no input files specified",
errc::invalid_argument);
}
if (Options.LinkOpts.Update &&
std::find(Options.InputFiles.begin(), Options.InputFiles.end(), "-") !=
Options.InputFiles.end()) {
@ -440,6 +445,11 @@ int main(int argc, char **argv) {
std::string SDKPath = sys::fs::getMainExecutable(argv[0], P);
SDKPath = sys::path::parent_path(SDKPath);
for (auto *Arg : Args.filtered(OPT_UNKNOWN)) {
WithColor::warning() << "ignoring unknown option: " << Arg->getSpelling()
<< '\n';
}
if (Args.hasArg(OPT_help)) {
T.PrintHelp(
outs(), (std::string(argv[0]) + " [options] <input files>").c_str(),