Skip to content

Commit 04acb60

Browse files
committed
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375044 91177308-0d34-0410-b5e6-96231b3b80d8 (cherry picked from commit aa4a46afe84f5f3609fb3b44e7d79a4c3d1e1f25) apple-llvm-split-commit: 4eb7e49ed665e6c93119f6c71d49b1c326cd1f61 apple-llvm-split-dir: llvm/
1 parent 3a7a5bf commit 04acb60

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

llvm/test/tools/dsymutil/cmdline.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ HELP-NOT: -reverse-iterate
2626

2727
RUN: dsymutil --version 2>&1 | FileCheck --check-prefix=VERSION %s
2828
VERSION: {{ version }}
29+
30+
RUN: not dsymutil 2>&1 | FileCheck --check-prefix=NOINPUT %s
31+
NOINPUT: error: no input files specified
32+
33+
RUN: dsymutil -bogus -help 2>&1 | FileCheck --check-prefix=BOGUS %s
34+
BOGUS: warning: ignoring unknown option: -bogus

llvm/tools/dsymutil/dsymutil.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ static Expected<std::vector<std::string>> getInputs(opt::InputArgList &Args,
148148

149149
// Verify that the given combination of options makes sense.
150150
static Error verifyOptions(const DsymutilOptions &Options) {
151+
if (Options.InputFiles.empty()) {
152+
return make_error<StringError>("no input files specified",
153+
errc::invalid_argument);
154+
}
155+
151156
if (Options.LinkOpts.Update &&
152157
std::find(Options.InputFiles.begin(), Options.InputFiles.end(), "-") !=
153158
Options.InputFiles.end()) {
@@ -440,6 +445,11 @@ int main(int argc, char **argv) {
440445
std::string SDKPath = sys::fs::getMainExecutable(argv[0], P);
441446
SDKPath = sys::path::parent_path(SDKPath);
442447

448+
for (auto *Arg : Args.filtered(OPT_UNKNOWN)) {
449+
WithColor::warning() << "ignoring unknown option: " << Arg->getSpelling()
450+
<< '\n';
451+
}
452+
443453
if (Args.hasArg(OPT_help)) {
444454
T.PrintHelp(
445455
outs(), (std::string(argv[0]) + " [options] <input files>").c_str(),

0 commit comments

Comments
 (0)