Index: test/tools/llvm-ar/case-detection.test =================================================================== --- test/tools/llvm-ar/case-detection.test +++ test/tools/llvm-ar/case-detection.test @@ -0,0 +1,11 @@ +-- Test CamelCase tool name to ensure detection works properly + +RUN: yaml2obj %S/Inputs/coff.yaml -o %t.obj +RUN: rm -rf %t1 +RUN: mkdir %t1 +RUN: cp llvm-ar %t1/Lib +RUN: %t1/Lib /OUT:%t.lib %t.obj | FileCheck %s -allow-empty +RUN: cp llvm-ar %t1/Ar +RUN: %t1/Ar crs %t.ar %t.obj | FileCheck %s -allow-empty + +CHECK-NOT: OVERVIEW: LLVM Archiver (llvm-ar) Index: tools/llvm-ar/llvm-ar.cpp =================================================================== --- tools/llvm-ar/llvm-ar.cpp +++ tools/llvm-ar/llvm-ar.cpp @@ -26,6 +26,7 @@ #include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" +#include "llvm/Support/FormatVariadic.h" #include "llvm/Support/LineIterator.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" @@ -57,7 +58,7 @@ This program generates an index to speed access to archives -USAGE: llvm-ranlib +USAGE: {0} OPTIONS: -help - Display available options @@ -69,7 +70,7 @@ This program archives bitcode files into single libraries -USAGE: llvm-ar [options] [relpos] [count] [members]... +USAGE: {0} [options] [relpos] [count] [members]... OPTIONS: -M - @@ -109,10 +110,10 @@ )"; void printHelpMessage() { - if (Stem.find("ranlib") != StringRef::npos) - outs() << RanlibHelp; - else if (Stem.find("ar") != StringRef::npos) - outs() << ArHelp; + if (Stem.find_lower("ranlib") != StringRef::npos) + outs() << formatv(RanlibHelp, Stem); + else if (Stem.find_lower("ar") != StringRef::npos) + outs() << formatv(ArHelp, Stem); } // Show the error message and exit. @@ -960,16 +961,16 @@ llvm::InitializeAllAsmParsers(); Stem = sys::path::stem(ToolName); - if (Stem.find("dlltool") != StringRef::npos) + if (Stem.find_lower("dlltool") != StringRef::npos) return dlltoolDriverMain(makeArrayRef(argv, argc)); - if (Stem.find("ranlib") != StringRef::npos) + if (Stem.find_lower("ranlib") != StringRef::npos) return ranlib_main(argc, argv); - if (Stem.find("lib") != StringRef::npos) + if (Stem.find_lower("lib") != StringRef::npos) return libDriverMain(makeArrayRef(argv, argc)); - if (Stem.find("ar") != StringRef::npos) + if (Stem.find_lower("ar") != StringRef::npos) return ar_main(argc, argv); fail("Not ranlib, ar, lib or dlltool!"); }