diff --git a/llvm/test/tools/llvm-ar/tool-name.test b/llvm/test/tools/llvm-ar/tool-name.test index cb656d3b47fef4..f91ef716d5c3ad 100644 --- a/llvm/test/tools/llvm-ar/tool-name.test +++ b/llvm/test/tools/llvm-ar/tool-name.test @@ -7,9 +7,14 @@ # 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 +## Ensure that the "lib" substring does not result in misidentification as the +## llvm-lib tool. +# 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: USAGE: arm-pokymllib32-linux-gnueabi-llvm-ar-9{{ }} diff --git a/llvm/test/tools/llvm-ranlib/tool-name.test b/llvm/test/tools/llvm-ranlib/tool-name.test index bd2b4965331534..d58783e4667b3f 100644 --- a/llvm/test/tools/llvm-ranlib/tool-name.test +++ b/llvm/test/tools/llvm-ranlib/tool-name.test @@ -6,8 +6,10 @@ # RUN: ln -s llvm-ranlib %t/llvm-ranlib-9 # RUN: ln -s llvm-ranlib %t/ranlib.exe -# RUN: llvm-ranlib -h | FileCheck %s -# RUN: %t/llvm-ranlib-9 -h | FileCheck %s -# RUN: %t/ranlib.exe -h | FileCheck %s +# RUN: llvm-ranlib -h | FileCheck %s --check-prefix=DEFAULT +# RUN: %t/llvm-ranlib-9 -h | FileCheck %s --check-prefix=VERSION +# RUN: %t/ranlib.exe -h | FileCheck %s --check-prefix=SUFFIX -# CHECK: USAGE: llvm-ranlib +# DEFAULT: USAGE: llvm-ranlib{{ }} +# VERSION: USAGE: llvm-ranlib-9{{ }} +# SUFFIX: USAGE: ranlib{{ }} diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp index 2b0288321834d8..81ac003e731416 100644 --- a/llvm/tools/llvm-ar/llvm-ar.cpp +++ b/llvm/tools/llvm-ar/llvm-ar.cpp @@ -62,25 +62,21 @@ static StringRef ToolName; // 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 - -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] [-][modifiers] [relpos] [count] [files] - llvm-ar -M [\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 @@ USAGE: llvm-ar [options] [-][modifiers] [relpos] [count] [f [V] - display the version and exit )"; + outs() << "OVERVIEW: LLVM Archiver\n\n" + << "USAGE: " + ToolName + + " [options] [-][modifiers] [relpos] " + "[count] [files]\n" + << " " + ToolName + " -M [