[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
Tue Oct 15 14:41:53 PDT 2019
rupprecht created this revision.
rupprecht added reviewers: MaskRay, gbreynoo.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Also update the help modifier (h) so that it works as a modifier and not just as a standalone `h`. For example, `llvm-ar h` prints the help message, but `llvm-ar xh` currently prints `unknown option h`.
Repository:
rG LLVM Github Monorepo
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
@@ -95,6 +95,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
@@ -107,6 +108,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() {
@@ -376,6 +378,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]);
}
@@ -1042,7 +1050,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.225119.patch
Type: text/x-patch
Size: 2335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191015/fc865962/attachment.bin>
More information about the llvm-commits
mailing list