[lld] r262168 - ELF: Add --help option.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 27 19:18:10 PST 2016
Author: ruiu
Date: Sat Feb 27 21:18:09 2016
New Revision: 262168
URL: http://llvm.org/viewvc/llvm-project?rev=262168&view=rev
Log:
ELF: Add --help option.
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Driver.h
lld/trunk/ELF/DriverUtils.cpp
lld/trunk/ELF/Options.td
lld/trunk/test/ELF/driver.test
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=262168&r1=262167&r2=262168&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Sat Feb 27 21:18:09 2016
@@ -41,7 +41,7 @@ bool elf::link(ArrayRef<const char *> Ar
Config = &C;
Driver = &D;
Script = &LS;
- Driver->main(Args.slice(1));
+ Driver->main(Args);
return !HasError;
}
@@ -163,7 +163,11 @@ static bool hasZOption(opt::InputArgList
void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
initSymbols();
- opt::InputArgList Args = parseArgs(&Alloc, ArgsArr);
+ opt::InputArgList Args = parseArgs(&Alloc, ArgsArr.slice(1));
+ if (Args.hasArg(OPT_help)) {
+ printHelp(ArgsArr[0]);
+ return;
+ }
if (Args.hasArg(OPT_version)) {
printVersion();
return;
Modified: lld/trunk/ELF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.h?rev=262168&r1=262167&r2=262168&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.h (original)
+++ lld/trunk/ELF/Driver.h Sat Feb 27 21:18:09 2016
@@ -53,6 +53,7 @@ enum {
#undef OPTION
};
+void printHelp(const char *Argv0);
void printVersion();
std::string findFromSearchPaths(StringRef Path);
Modified: lld/trunk/ELF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=262168&r1=262167&r2=262168&view=diff
==============================================================================
--- lld/trunk/ELF/DriverUtils.cpp (original)
+++ lld/trunk/ELF/DriverUtils.cpp Sat Feb 27 21:18:09 2016
@@ -79,6 +79,11 @@ opt::InputArgList elf::parseArgs(llvm::B
return Args;
}
+void elf::printHelp(const char *Argv0) {
+ ELFOptTable Table;
+ Table.PrintHelp(outs(), Argv0, "lld", false);
+}
+
void elf::printVersion() {
outs() << "LLD " << getLLDVersion();
std::string S = getLLDRepositoryVersion();
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=262168&r1=262167&r2=262168&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Sat Feb 27 21:18:09 2016
@@ -57,6 +57,9 @@ def fini : Separate<["-"], "fini">, Meta
def hash_style : Separate<["--", "-"], "hash-style">,
HelpText<"Specify hash style (sysv, gnu or both)">;
+def help : Flag<["--", "-"], "help">,
+ HelpText<"Print option help">;
+
def icf : Flag<["--"], "icf=all">,
HelpText<"Enable Identical Code Folding.">;
Modified: lld/trunk/test/ELF/driver.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/driver.test?rev=262168&r1=262167&r2=262168&view=diff
==============================================================================
--- lld/trunk/test/ELF/driver.test (original)
+++ lld/trunk/test/ELF/driver.test Sat Feb 27 21:18:09 2016
@@ -14,6 +14,9 @@
# RUN: not ld.lld %t -o /no/such/file 2>&1 | FileCheck -check-prefix=MISSING %s
# MISSING: failed to open /no/such/file
+# RUN: ld.lld --help 2>&1 | FileCheck -check-prefix=HELP %s
+# HELP: USAGE:
+
# RUN: ld.lld --version 2>&1 | FileCheck -check-prefix=VERSION %s
# VERSION: LLD
More information about the llvm-commits
mailing list