Index: llvm/trunk/include/llvm/Option/OptTable.h =================================================================== --- llvm/trunk/include/llvm/Option/OptTable.h +++ llvm/trunk/include/llvm/Option/OptTable.h @@ -217,8 +217,8 @@ /// Render the help text for an option table. /// /// \param OS - The stream to write the help text to. - /// \param Name - The name to use in the usage line. - /// \param Title - The title to use in the usage line. + /// \param Usage - USAGE: Usage + /// \param Title - OVERVIEW: Title /// \param FlagsToInclude - If non-zero, only include options with any /// of these flags set. /// \param FlagsToExclude - Exclude options with any of these flags set. @@ -226,11 +226,11 @@ /// that don't have help texts. By default, we display /// only options that are not hidden and have help /// texts. - void PrintHelp(raw_ostream &OS, const char *Name, const char *Title, + void PrintHelp(raw_ostream &OS, const char *Usage, const char *Title, unsigned FlagsToInclude, unsigned FlagsToExclude, bool ShowAllAliases) const; - void PrintHelp(raw_ostream &OS, const char *Name, const char *Title, + void PrintHelp(raw_ostream &OS, const char *Usage, const char *Title, bool ShowHidden = false, bool ShowAllAliases = false) const; }; Index: llvm/trunk/lib/Option/OptTable.cpp =================================================================== --- llvm/trunk/lib/Option/OptTable.cpp +++ llvm/trunk/lib/Option/OptTable.cpp @@ -521,19 +521,17 @@ return getOptionHelpGroup(Opts, GroupID); } -void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title, +void OptTable::PrintHelp(raw_ostream &OS, const char *Usage, const char *Title, bool ShowHidden, bool ShowAllAliases) const { - PrintHelp(OS, Name, Title, /*Include*/ 0, /*Exclude*/ + PrintHelp(OS, Usage, Title, /*Include*/ 0, /*Exclude*/ (ShowHidden ? 0 : HelpHidden), ShowAllAliases); } -void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title, +void OptTable::PrintHelp(raw_ostream &OS, const char *Usage, const char *Title, unsigned FlagsToInclude, unsigned FlagsToExclude, bool ShowAllAliases) const { - OS << "OVERVIEW: " << Title << "\n"; - OS << '\n'; - OS << "USAGE: " << Name << " [options] \n"; - OS << '\n'; + OS << "OVERVIEW: " << Title << "\n\n"; + OS << "USAGE: " << Usage << "\n\n"; // Render help text into a map of group-name to a list of (option, help) // pairs. Index: llvm/trunk/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp =================================================================== --- llvm/trunk/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp +++ llvm/trunk/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp @@ -96,7 +96,8 @@ // Handle when no input or output is specified if (Args.hasArgNoClaim(OPT_INPUT) || (!Args.hasArgNoClaim(OPT_d) && !Args.hasArgNoClaim(OPT_l))) { - Table.PrintHelp(outs(), ArgsArr[0], "dlltool", false); + Table.PrintHelp(outs(), "llvm-dlltool [options] file...", "llvm-dlltool", + false); llvm::outs() << "\nTARGETS: i386, i386:x86-64, arm, arm64\n"; return 1; } Index: llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp =================================================================== --- llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -123,7 +123,7 @@ // Handle /help if (Args.hasArg(OPT_help)) { - Table.PrintHelp(outs(), ArgsArr[0], "LLVM Lib"); + Table.PrintHelp(outs(), "llvm-lib [options] file...", "LLVM Lib"); return 0; } Index: llvm/trunk/test/tools/llvm-cvtres/help.test =================================================================== --- llvm/trunk/test/tools/llvm-cvtres/help.test +++ llvm/trunk/test/tools/llvm-cvtres/help.test @@ -2,7 +2,7 @@ ; RUN: FileCheck -input-file=%t %s -check-prefix=HELP_TEST ; HELP_TEST: OVERVIEW: Resource Converter -; HELP_TEST-DAG: USAGE: cvtres [options] +; HELP_TEST-DAG: USAGE: llvm-cvtres [options] file... ; HELP_TEST-DAG: OPTIONS: ; HELP_TEST-NEXT: /DEFINE:symbol ; HELP_TEST-NEXT: /FOLDDUPS: Index: llvm/trunk/test/tools/llvm-rc/helpmsg.test =================================================================== --- llvm/trunk/test/tools/llvm-rc/helpmsg.test +++ llvm/trunk/test/tools/llvm-rc/helpmsg.test @@ -4,7 +4,7 @@ ; RUN: FileCheck -input-file=%t1 %s ; CHECK: OVERVIEW: Resource Converter -; CHECK-DAG: USAGE: rc [options] +; CHECK-DAG: USAGE: rc [options] file... ; CHECK-DAG: OPTIONS: ; CHECK-NEXT: /? Display this help and exit. ; CHECK-NEXT: /C Set the codepage used for input strings. Index: llvm/trunk/tools/llvm-cvtres/llvm-cvtres.cpp =================================================================== --- llvm/trunk/tools/llvm-cvtres/llvm-cvtres.cpp +++ llvm/trunk/tools/llvm-cvtres/llvm-cvtres.cpp @@ -103,7 +103,7 @@ opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC); if (InputArgs.hasArg(OPT_HELP)) { - T.PrintHelp(outs(), "cvtres", "Resource Converter", false); + T.PrintHelp(outs(), "llvm-cvtres [options] file...", "Resource Converter", false); return 0; } Index: llvm/trunk/tools/llvm-mt/llvm-mt.cpp =================================================================== --- llvm/trunk/tools/llvm-mt/llvm-mt.cpp +++ llvm/trunk/tools/llvm-mt/llvm-mt.cpp @@ -115,7 +115,7 @@ } if (InputArgs.hasArg(OPT_help)) { - T.PrintHelp(outs(), "mt", "Manifest Tool", false); + T.PrintHelp(outs(), "llvm-mt [options] file...", "Manifest Tool", false); return 0; } Index: llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp =================================================================== --- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp +++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp @@ -897,12 +897,12 @@ T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount); if (InputArgs.size() == 0) { - T.PrintHelp(errs(), "llvm-objcopy [ ]", "objcopy tool"); + T.PrintHelp(errs(), "llvm-objcopy input [output]", "objcopy tool"); exit(1); } if (InputArgs.hasArg(OBJCOPY_help)) { - T.PrintHelp(outs(), "llvm-objcopy [ ]", "objcopy tool"); + T.PrintHelp(outs(), "llvm-objcopy input [output]", "objcopy tool"); exit(0); } @@ -1039,13 +1039,14 @@ llvm::opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount); + static const char Usage[] = "llvm-strip [options] file..."; if (InputArgs.size() == 0) { - T.PrintHelp(errs(), "llvm-strip", "strip tool"); + T.PrintHelp(errs(), Usage, "strip tool"); exit(1); } if (InputArgs.hasArg(STRIP_help)) { - T.PrintHelp(outs(), "llvm-strip", "strip tool"); + T.PrintHelp(outs(), Usage, "strip tool"); exit(0); } Index: llvm/trunk/tools/llvm-rc/llvm-rc.cpp =================================================================== --- llvm/trunk/tools/llvm-rc/llvm-rc.cpp +++ llvm/trunk/tools/llvm-rc/llvm-rc.cpp @@ -90,7 +90,7 @@ // The tool prints nothing when invoked with no command-line arguments. if (InputArgs.hasArg(OPT_HELP)) { - T.PrintHelp(outs(), "rc", "Resource Converter", false); + T.PrintHelp(outs(), "rc [options] file...", "Resource Converter", false); return 0; } Index: llvm/trunk/unittests/Option/OptionParsingTest.cpp =================================================================== --- llvm/trunk/unittests/Option/OptionParsingTest.cpp +++ llvm/trunk/unittests/Option/OptionParsingTest.cpp @@ -97,6 +97,10 @@ T.PrintHelp(RSO, "test", "title!"); EXPECT_NE(std::string::npos, Help.find("-A")); + // Check usage line. + T.PrintHelp(RSO, "name [options] file...", "title!"); + EXPECT_NE(std::string::npos, Help.find("USAGE: name [options] file...\n")); + // Test aliases. auto Cs = AL.filtered(OPT_C); ASSERT_NE(Cs.begin(), Cs.end());