[PATCH] D38972: Add the /v option which prints out the LLD version string.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 22 17:05:10 PDT 2017


ruiu updated this revision to Diff 119802.
ruiu added a comment.

Instead of including version information to the --help message, add the --version option.


https://reviews.llvm.org/D38972

Files:
  lld/COFF/Driver.cpp
  lld/COFF/Options.td
  lld/test/COFF/driver.test


Index: lld/test/COFF/driver.test
===================================================================
--- lld/test/COFF/driver.test
+++ lld/test/COFF/driver.test
@@ -1,3 +1,6 @@
 # RUN: not lld-link nosuchfile.obj >& %t.log
 # RUN: FileCheck -check-prefix=MISSING %s < %t.log
 MISSING: nosuchfile.obj: {{[Nn]}}o such file or directory
+
+# RUN: lld-link --version | FileCheck -check-prefix=VERSION %s
+VERSION: {{LLD [0-9]+\.[0-9]+}}
Index: lld/COFF/Options.td
===================================================================
--- lld/COFF/Options.td
+++ lld/COFF/Options.td
@@ -110,6 +110,8 @@
 def output_def : Joined<["/", "-"], "output-def:">;
 def rsp_quoting : Joined<["--"], "rsp-quoting=">,
   HelpText<"Quoting style for response files, 'windows' (default) or 'posix'">;
+def dash_dash_version : Flag<["--"], "version">,
+  HelpText<"Print version information">;
 
 // Flags for debugging
 def lldmap : F<"lldmap">;
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -17,6 +17,7 @@
 #include "Symbols.h"
 #include "Writer.h"
 #include "lld/Common/Driver.h"
+#include "lld/Common/Version.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/BinaryFormat/Magic.h"
@@ -730,6 +731,12 @@
     return;
   }
 
+  // Handle --version.
+  if (Args.hasArg(OPT_dash_dash_version)) {
+    outs() << getLLDVersion() << "\n";
+    return;
+  }
+
   // Handle /lldmingw early, since it can potentially affect how other
   // options are handled.
   Config->MinGW = Args.hasArg(OPT_lldmingw);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38972.119802.patch
Type: text/x-patch
Size: 1616 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171023/882a63c8/attachment.bin>


More information about the llvm-commits mailing list