[PATCH] D69007: [llvm-ar] Implement the V modifier as an alias for --version

Jordan Rupprecht via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 11:43:03 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rGa86bd2251595: [llvm-ar] Implement the V modifier as an alias for --version (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69007/new/

https://reviews.llvm.org/D69007

Files:
  llvm/test/tools/llvm-ar/help-message.test
  llvm/test/tools/llvm-ar/version.test
  llvm/tools/llvm-ar/llvm-ar.cpp


Index: llvm/tools/llvm-ar/llvm-ar.cpp
===================================================================
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -100,6 +100,7 @@
   [b] - put [files] before [relpos] (same as [i])
   [c] - do not warn if archive had to be created
   [D] - use zero for timestamps and uids/gids (default)
+  [h] - display this help and exit
   [i] - put [files] before [relpos] (same as [b])
   [l] - ignored for compatibility
   [L] - add archive's contents
@@ -112,6 +113,7 @@
   [u] - update only [files] newer than archive contents
   [U] - use actual timestamps and uids/gids
   [v] - be verbose about actions taken
+  [V] - display the version and exit
 )";
 
 void printHelpMessage() {
@@ -381,6 +383,12 @@
     case 'L':
       AddLibrary = true;
       break;
+    case 'V':
+      cl::PrintVersionMessage();
+      exit(0);
+    case 'h':
+      printHelpMessage();
+      exit(0);
     default:
       fail(std::string("unknown option ") + Options[i]);
     }
@@ -1063,7 +1071,7 @@
 }
 
 static bool handleGenericOption(StringRef arg) {
-  if (arg == "h" || arg.startswith("-h") || arg == "--help") {
+  if (arg == "-help" || arg == "--help") {
     printHelpMessage();
     return true;
   }
Index: llvm/test/tools/llvm-ar/version.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-ar/version.test
@@ -0,0 +1,11 @@
+## Show that the version for llvm-ar can be printed with either the long flag
+## -version or with the V modifier.
+
+RUN: llvm-ar V | FileCheck %s
+RUN: llvm-ar xV | FileCheck %s
+RUN: llvm-ar -V | FileCheck %s
+RUN: llvm-ar -xV | FileCheck %s
+RUN: llvm-ar -version | FileCheck %s
+RUN: llvm-ar --version | FileCheck %s
+
+CHECK: version
Index: llvm/test/tools/llvm-ar/help-message.test
===================================================================
--- llvm/test/tools/llvm-ar/help-message.test
+++ llvm/test/tools/llvm-ar/help-message.test
@@ -1,5 +1,10 @@
+## Show that the help message for llvm-ar can be printed with either the long
+## flag -help or with the h modifier.
+
 # RUN: llvm-ar h | FileCheck %s
+# RUN: llvm-ar xh | FileCheck %s
 # RUN: llvm-ar -h | FileCheck %s
+# RUN: llvm-ar -xh | FileCheck %s
 # RUN: llvm-ar -help | FileCheck %s
 # RUN: llvm-ar --help | FileCheck %s
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69007.225281.patch
Type: text/x-patch
Size: 2337 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191016/7e87c4de/attachment.bin>


More information about the llvm-commits mailing list