[mach-o] Fix so no options causes usage message to be printed

llvm-svn: 217409
This commit is contained in:
Nick Kledzik 2014-09-09 00:45:35 +00:00
parent b7035ae367
commit 4ce63c2a54
2 changed files with 13 additions and 5 deletions

View File

@ -253,7 +253,11 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
break;
}
if (arch == MachOLinkingContext::arch_unknown) {
diagnostics << "error: -arch not specified and could not be inferred\n";
// If no -arch and no options at all, print usage message.
if (parsedArgs->size() == 0)
table.PrintHelp(llvm::outs(), argv[0], "LLVM Linker", false);
else
diagnostics << "error: -arch not specified and could not be inferred\n";
return false;
}
}
@ -635,10 +639,6 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
}
if (!inputGraph->size()) {
if (parsedArgs->size() == 0) {
table.PrintHelp(llvm::outs(), "lld", "LLVM Linker", false);
return false;
}
diagnostics << "No input files\n";
return false;
}

View File

@ -0,0 +1,8 @@
# RUN: not lld -flavor darwin | FileCheck %s
#
# Test that running darwin linker with no option prints out usage message.
#
# CHECK: USAGE:
# CHECK: -arch