aboutsummaryrefslogtreecommitdiff
path: root/lld/lib
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2018-10-10 00:15:36 +0000
committerFangrui Song <maskray@google.com>2018-10-10 00:15:36 +0000
commit2043a58abeacda130b01fba8f53aacc0915e6b25 (patch)
tree5bcf4e0157763c9036b7fdc200c938d2d78e2d22 /lld/lib
parentd0028238302d6b673ac693cada423c77a1531e0b (diff)
downloadllvm-project-2043a58abeacda130b01fba8f53aacc0915e6b25.tar.gz
Adapt OptTable::PrintHelp change in D51009
Summary: Before, OptTable::PrintHelp append "[options] <inputs>" to its parameter `Help`. It is more flexible to change its semantic to `Usage` and let user customize the usage line. Reviewers: rupprecht, ruiu, espindola Reviewed By: rupprecht Subscribers: emaste, sbc100, arichardson, aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D53054 llvm-svn: 344099
Diffstat (limited to 'lld/lib')
-rw-r--r--lld/lib/Driver/DarwinLdDriver.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index 289b3007b265..7521d6e57a24 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -44,6 +44,7 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
@@ -382,10 +383,13 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx) {
if (arch == MachOLinkingContext::arch_unknown &&
!parsedArgs.getLastArg(OPT_test_file_usage)) {
// If no -arch and no options at all, print usage message.
- if (parsedArgs.size() == 0)
- table.PrintHelp(llvm::outs(), args[0], "LLVM Linker", false);
- else
+ if (parsedArgs.size() == 0) {
+ std::string Usage =
+ llvm::formatv("{0} [options] file...", args[0]).str();
+ table.PrintHelp(llvm::outs(), Usage.c_str(), "LLVM Linker", false);
+ } else {
error("-arch not specified and could not be inferred");
+ }
return false;
}
}