[PATCH] D124445: [llvm-ar] Modify usage printouts to use the correct toolname
Chris Jackson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 26 04:28:58 PDT 2022
chrisjackson updated this revision to Diff 425178.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124445/new/
https://reviews.llvm.org/D124445
Files:
llvm/test/tools/llvm-ar/tool-name.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
@@ -62,25 +62,21 @@
// The basename of this program.
static StringRef Stem;
-const char RanlibHelp[] = R"(OVERVIEW: LLVM Ranlib (llvm-ranlib)
-
- This program generates an index to speed access to archives
-
-USAGE: llvm-ranlib <archive-file>
-
-OPTIONS:
- -h --help - Display available options
- -v --version - Display the version of this program
- -D - Use zero for timestamps and uids/gids (default)
- -U - Use actual timestamps and uids/gids
-)";
-
-const char ArHelp[] = R"(OVERVIEW: LLVM Archiver
-
-USAGE: llvm-ar [options] [-]<operation>[modifiers] [relpos] [count] <archive> [files]
- llvm-ar -M [<mri-script]
+static void printRanLibHelp(StringRef ToolName) {
+ outs() << "OVERVIEW: LLVM Ranlib (" + ToolName + ")\n\n"
+ << "This program generates an index to speed access to archives\n\n"
+ << "USAGE: " + ToolName + " <archive-file>\n\n"
+ << "OPTIONS:\n"
+ << " -h --help - Display available options\n"
+ << " -v --version - Display the version of this program\n"
+ << " -D - Use zero for timestamps and uids/gids "
+ "(default)\n"
+ << " -U - Use actual timestamps and uids/gids\n";
+}
-OPTIONS:
+static void printArHelp(StringRef ToolName) {
+ const char ArOptions[] =
+ R"(OPTIONS:
--format - archive format to create
=default - default
=gnu - gnu
@@ -127,11 +123,20 @@
[V] - display the version and exit
)";
+ outs() << "OVERVIEW: LLVM Archiver\n\n"
+ << "USAGE: " + ToolName +
+ " [options] [-]<operation>[modifiers] [relpos] "
+ "[count] <archive> [files]\n"
+ << " " + ToolName + " -M [<mri-script]\n\n";
+
+ outs() << ArOptions;
+}
+
static void printHelpMessage() {
if (Stem.contains_insensitive("ranlib"))
- outs() << RanlibHelp;
+ printRanLibHelp(Stem);
else if (Stem.contains_insensitive("ar"))
- outs() << ArHelp;
+ printArHelp(Stem);
}
static unsigned MRILineNumber;
Index: llvm/test/tools/llvm-ar/tool-name.test
===================================================================
--- llvm/test/tools/llvm-ar/tool-name.test
+++ llvm/test/tools/llvm-ar/tool-name.test
@@ -7,9 +7,12 @@
# RUN: ln -s llvm-ar %t/ar.exe
# RUN: ln -s llvm-ar %t/arm-pokymllib32-linux-gnueabi-llvm-ar-9
-# RUN: llvm-ar h | FileCheck %s
-# RUN: %t/llvm-ar-9 h | FileCheck %s
-# RUN: %t/ar.exe h | FileCheck %s
-# RUN: %t/arm-pokymllib32-linux-gnueabi-llvm-ar-9 h | FileCheck %s
+# RUN: llvm-ar h | FileCheck %s --check-prefix=DEFAULT
+# RUN: %t/llvm-ar-9 h | FileCheck %s --check-prefix=VERSION
+# RUN: %t/ar.exe h | FileCheck %s --check-prefix=SUFFIX
+# RUN: %t/arm-pokymllib32-linux-gnueabi-llvm-ar-9 h | FileCheck %s --check-prefix=ARM
-# CHECK: USAGE: llvm-ar
+# DEFAULT: USAGE: llvm-ar
+# VERSION: USAGE: llvm-ar-9
+# SUFFIX: USAGE: ar
+# ARM: arm-pokymllib32-linux-gnueabi-llvm-ar-9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124445.425178.patch
Type: text/x-patch
Size: 3225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220426/c82930bd/attachment.bin>
More information about the llvm-commits
mailing list