Skip to content

Commit 1ecba6f

Browse files
committed
[llvm-ar] Parse 'h' and '-h': display help and exit
Support `llvm-ar h` and `llvm-ar -h` because they may be what users try at first. Note, operation 'h' is undocumented in GNU ar. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D67560 llvm-svn: 372088
1 parent de1bef0 commit 1ecba6f

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# RUN: llvm-ar h | FileCheck %s
2+
# RUN: llvm-ar -h | FileCheck %s
3+
# RUN: llvm-ar -help | FileCheck %s
4+
# RUN: llvm-ar --help | FileCheck %s
5+
6+
# CHECK: USAGE: llvm-ar

llvm/tools/llvm-ar/llvm-ar.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ USAGE: llvm-ar [options] [-]<operation>[modifiers] [relpos] [count] <archive> [f
7070
llvm-ar -M [<mri-script]
7171
7272
OPTIONS:
73-
--format - Archive format to create
73+
--format - archive format to create
7474
=default - default
7575
=gnu - gnu
7676
=darwin - darwin
7777
=bsd - bsd
78-
--plugin=<string> - Ignored for compatibility
79-
--help - Display available options
80-
--version - Display the version of this program
78+
--plugin=<string> - ignored for compatibility
79+
-h --help - display this help and exit
80+
--version - print the version and exit
8181
@<file> - read options from <file>
8282
8383
OPERATIONS:
@@ -1030,7 +1030,7 @@ static void runMRIScript() {
10301030
}
10311031

10321032
static bool handleGenericOption(StringRef arg) {
1033-
if (arg == "-help" || arg == "--help") {
1033+
if (arg == "h" || arg.startswith("-h") || arg == "--help") {
10341034
printHelpMessage();
10351035
return true;
10361036
}

0 commit comments

Comments
 (0)