diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 1afaaba79105b..6ea6e2e47e639 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1635,7 +1635,7 @@ void Driver::PrintHelp(bool ShowHidden) const { ExcludedFlagsBitmask |= options::FlangOnlyOption; std::string Usage = llvm::formatv("{0} [options] file...", Name).str(); - getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(), + getOpts().printHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(), IncludedFlagsBitmask, ExcludedFlagsBitmask, /*ShowAllAliases=*/false); } diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index ac64e1708da6c..b95851e380d28 100644 --- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -187,7 +187,7 @@ CreateFrontendAction(CompilerInstance &CI) { bool ExecuteCompilerInvocation(CompilerInstance *Clang) { // Honor -help. if (Clang->getFrontendOpts().ShowHelp) { - driver::getDriverOptTable().PrintHelp( + driver::getDriverOptTable().printHelp( llvm::outs(), "clang -cc1 [options] file...", "LLVM 'Clang' Compiler: http://clang.llvm.org", /*Include=*/driver::options::CC1Option, diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp index 9f6a58b634b4b..086ce0ea77875 100644 --- a/clang/tools/driver/cc1as_main.cpp +++ b/clang/tools/driver/cc1as_main.cpp @@ -585,7 +585,7 @@ int cc1as_main(ArrayRef Argv, const char *Argv0, void *MainAddr) { return 1; if (Asm.ShowHelp) { - getDriverOptTable().PrintHelp( + getDriverOptTable().printHelp( llvm::outs(), "clang -cc1as [options] file...", "Clang Integrated Assembler", /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0, diff --git a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index e53f652d3b2c4..243e25163dc05 100644 --- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -103,7 +103,7 @@ std::unique_ptr CreateFrontendAction(CompilerInstance &ci) { bool ExecuteCompilerInvocation(CompilerInstance *flang) { // Honor -help. if (flang->frontendOpts().showHelp_) { - clang::driver::getDriverOptTable().PrintHelp(llvm::outs(), + clang::driver::getDriverOptTable().printHelp(llvm::outs(), "flang-new -fc1 [options] file...", "LLVM 'Flang' Compiler", /*Include=*/clang::driver::options::FC1Option, /*Exclude=*/llvm::opt::DriverFlag::HelpHidden, diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp index d6261209a9c1c..b5abe8b1196d9 100644 --- a/lld/COFF/DriverUtils.cpp +++ b/lld/COFF/DriverUtils.cpp @@ -933,7 +933,7 @@ std::vector ArgParser::tokenize(StringRef s) { } void printHelp(const char *argv0) { - optTable.PrintHelp(lld::outs(), + optTable.printHelp(lld::outs(), (std::string(argv0) + " [options] file...").c_str(), "LLVM Linker", false); } diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp index a3fc522c708c2..f49deb9012b28 100644 --- a/lld/ELF/DriverUtils.cpp +++ b/lld/ELF/DriverUtils.cpp @@ -145,7 +145,7 @@ opt::InputArgList ELFOptTable::parse(ArrayRef argv) { } void elf::printHelp() { - ELFOptTable().PrintHelp( + ELFOptTable().printHelp( lld::outs(), (config->progName + " [options] file...").str().c_str(), "lld", false /*ShowHidden*/, true /*ShowAllAliases*/); lld::outs() << "\n"; diff --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp index 55582731aab94..33c235ba2ece6 100644 --- a/lld/MachO/DriverUtils.cpp +++ b/lld/MachO/DriverUtils.cpp @@ -107,8 +107,9 @@ InputArgList MachOOptTable::parse(ArrayRef argv) { } void MachOOptTable::printHelp(const char *argv0, bool showHidden) const { - PrintHelp(lld::outs(), (std::string(argv0) + " [options] file...").c_str(), - "LLVM Linker", showHidden); + OptTable::printHelp(lld::outs(), + (std::string(argv0) + " [options] file...").c_str(), + "LLVM Linker", showHidden); lld::outs() << "\n"; } diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp index 79a62d68dab7e..734f4092a666f 100644 --- a/lld/MinGW/Driver.cpp +++ b/lld/MinGW/Driver.cpp @@ -83,7 +83,7 @@ class MinGWOptTable : public opt::OptTable { } // namespace static void printHelp(const char *argv0) { - MinGWOptTable().PrintHelp( + MinGWOptTable().printHelp( lld::outs(), (std::string(argv0) + " [options] file...").c_str(), "lld", false /*ShowHidden*/, true /*ShowAllAliases*/); lld::outs() << "\n"; diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp index f2fbb2aa6896b..21d1257261927 100644 --- a/lld/lib/Driver/DarwinLdDriver.cpp +++ b/lld/lib/Driver/DarwinLdDriver.cpp @@ -383,7 +383,7 @@ bool parse(llvm::ArrayRef args, MachOLinkingContext &ctx) { !parsedArgs.getLastArg(OPT_test_file_usage)) { // If no -arch and no options at all, print usage message. if (parsedArgs.size() == 0) { - table.PrintHelp(llvm::outs(), + table.printHelp(llvm::outs(), (std::string(args[0]) + " [options] file...").c_str(), "LLVM Linker", false); } else { diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp index c5db63e3507ec..206fde64dabb3 100644 --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -823,7 +823,7 @@ void LinkerDriver::linkerMain(ArrayRef argsArr) { // Handle --help if (args.hasArg(OPT_help)) { - parser.PrintHelp(lld::outs(), + parser.printHelp(lld::outs(), (std::string(argsArr[0]) + " [options] file...").c_str(), "LLVM Linker", false); return; diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index bfd1347dca2a1..b8c5aec5fd80b 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -740,7 +740,7 @@ void reproducer_handler(void *finalize_cmd) { static void printHelp(LLDBOptTable &table, llvm::StringRef tool_name) { std::string usage_str = tool_name.str() + " [options]"; - table.PrintHelp(llvm::outs(), usage_str.c_str(), "LLDB", false); + table.printHelp(llvm::outs(), usage_str.c_str(), "LLDB", false); std::string examples = R"___( EXAMPLES: diff --git a/lldb/tools/lldb-server/lldb-gdbserver.cpp b/lldb/tools/lldb-server/lldb-gdbserver.cpp index f0146461f36e0..888ba728fa911 100644 --- a/lldb/tools/lldb-server/lldb-gdbserver.cpp +++ b/lldb/tools/lldb-server/lldb-gdbserver.cpp @@ -356,7 +356,7 @@ class LLGSOptTable : public opt::OptTable { void PrintHelp(llvm::StringRef Name) { std::string Usage = (Name + " [options] [[host]:port] [[--] program args...]").str(); - OptTable::PrintHelp(llvm::outs(), Usage.c_str(), "lldb-server"); + OptTable::printHelp(llvm::outs(), Usage.c_str(), "lldb-server"); llvm::outs() << R"( DESCRIPTION lldb-server connects to the LLDB client, which drives the debugging session. diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp index 4ac96166aa246..9ab13cf140c6d 100644 --- a/lldb/tools/lldb-vscode/lldb-vscode.cpp +++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -3046,7 +3046,7 @@ void RegisterRequestCallbacks() { static void printHelp(LLDBVSCodeOptTable &table, llvm::StringRef tool_name) { std::string usage_str = tool_name.str() + " options"; - table.PrintHelp(llvm::outs(), usage_str.c_str(), "LLDB VSCode", false); + table.printHelp(llvm::outs(), usage_str.c_str(), "LLDB VSCode", false); std::string examples = R"___( EXAMPLES: diff --git a/llvm/include/llvm/Option/OptTable.h b/llvm/include/llvm/Option/OptTable.h index 58c09b23d237c..ca2013ee6f045 100644 --- a/llvm/include/llvm/Option/OptTable.h +++ b/llvm/include/llvm/Option/OptTable.h @@ -249,11 +249,11 @@ class OptTable { /// 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 *Usage, 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 *Usage, const char *Title, + void printHelp(raw_ostream &OS, const char *Usage, const char *Title, bool ShowHidden = false, bool ShowAllAliases = false) const; }; diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp index 41bd440fe1a30..f5bf166e9e65b 100644 --- a/llvm/lib/Option/OptTable.cpp +++ b/llvm/lib/Option/OptTable.cpp @@ -618,13 +618,13 @@ static const char *getOptionHelpGroup(const OptTable &Opts, OptSpecifier Id) { return getOptionHelpGroup(Opts, GroupID); } -void OptTable::PrintHelp(raw_ostream &OS, const char *Usage, const char *Title, +void OptTable::printHelp(raw_ostream &OS, const char *Usage, const char *Title, bool ShowHidden, bool ShowAllAliases) const { - PrintHelp(OS, Usage, Title, /*Include*/ 0, /*Exclude*/ + printHelp(OS, Usage, Title, /*Include*/ 0, /*Exclude*/ (ShowHidden ? 0 : HelpHidden), ShowAllAliases); } -void OptTable::PrintHelp(raw_ostream &OS, const char *Usage, 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\n"; diff --git a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp index ed5f870b57e3a..961577f126bac 100644 --- a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp +++ b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp @@ -122,7 +122,7 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef ArgsArr) { // Handle when no input or output is specified if (Args.hasArgNoClaim(OPT_INPUT) || (!Args.hasArgNoClaim(OPT_d) && !Args.hasArgNoClaim(OPT_l))) { - Table.PrintHelp(outs(), "llvm-dlltool [options] file...", "llvm-dlltool", + Table.printHelp(outs(), "llvm-dlltool [options] file...", "llvm-dlltool", false); llvm::outs() << "\nTARGETS: i386, i386:x86-64, arm, arm64\n"; return 1; diff --git a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp index 80d3033244de4..8f69282d3443c 100644 --- a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -287,7 +287,7 @@ int llvm::libDriverMain(ArrayRef ArgsArr) { // Handle /help if (Args.hasArg(OPT_help)) { - Table.PrintHelp(outs(), "llvm-lib [options] file...", "LLVM Lib"); + Table.printHelp(outs(), "llvm-lib [options] file...", "LLVM Lib"); return 0; } diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp index f615d36b55fda..2a8e317bef6de 100644 --- a/llvm/tools/dsymutil/dsymutil.cpp +++ b/llvm/tools/dsymutil/dsymutil.cpp @@ -498,7 +498,7 @@ int main(int argc, char **argv) { } if (Args.hasArg(OPT_help)) { - T.PrintHelp( + T.printHelp( outs(), (std::string(argv[0]) + " [options] ").c_str(), "manipulate archived DWARF debug symbol files.\n\n" "dsymutil links the DWARF debug information found in the object files\n" diff --git a/llvm/tools/llvm-cvtres/llvm-cvtres.cpp b/llvm/tools/llvm-cvtres/llvm-cvtres.cpp index a77d5f1126a07..24b3c6528240e 100644 --- a/llvm/tools/llvm-cvtres/llvm-cvtres.cpp +++ b/llvm/tools/llvm-cvtres/llvm-cvtres.cpp @@ -123,7 +123,7 @@ int main(int Argc, const char **Argv) { opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC); if (InputArgs.hasArg(OPT_HELP)) { - T.PrintHelp(outs(), "llvm-cvtres [options] file...", "Resource Converter"); + T.printHelp(outs(), "llvm-cvtres [options] file...", "Resource Converter"); return 0; } diff --git a/llvm/tools/llvm-lipo/llvm-lipo.cpp b/llvm/tools/llvm-lipo/llvm-lipo.cpp index 7452ecafcfc02..d099ea1c2224f 100644 --- a/llvm/tools/llvm-lipo/llvm-lipo.cpp +++ b/llvm/tools/llvm-lipo/llvm-lipo.cpp @@ -159,14 +159,14 @@ static Config parseLipoOptions(ArrayRef ArgsArr) { " option"); if (InputArgs.size() == 0) { - // PrintHelp does not accept Twine. - T.PrintHelp(errs(), "llvm-lipo input[s] option[s]", "llvm-lipo"); + // printHelp does not accept Twine. + T.printHelp(errs(), "llvm-lipo input[s] option[s]", "llvm-lipo"); exit(EXIT_FAILURE); } if (InputArgs.hasArg(LIPO_help)) { - // PrintHelp does not accept Twine. - T.PrintHelp(outs(), "llvm-lipo input[s] option[s]", "llvm-lipo"); + // printHelp does not accept Twine. + T.printHelp(outs(), "llvm-lipo input[s] option[s]", "llvm-lipo"); exit(EXIT_SUCCESS); } diff --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp index 1a6686253ff24..dee5f6ff4e513 100644 --- a/llvm/tools/llvm-ml/llvm-ml.cpp +++ b/llvm/tools/llvm-ml/llvm-ml.cpp @@ -220,7 +220,7 @@ int main(int Argc, char **Argv) { if (InputArgs.hasArg(OPT_help)) { std::string Usage = llvm::formatv("{0} [ /options ] file", ProgName).str(); - T.PrintHelp(outs(), Usage.c_str(), "LLVM MASM Assembler", + T.printHelp(outs(), Usage.c_str(), "LLVM MASM Assembler", /*ShowHidden=*/false); return 0; } else if (InputFilename.empty()) { diff --git a/llvm/tools/llvm-mt/llvm-mt.cpp b/llvm/tools/llvm-mt/llvm-mt.cpp index 997e5acbe23e6..6f26765331ba0 100644 --- a/llvm/tools/llvm-mt/llvm-mt.cpp +++ b/llvm/tools/llvm-mt/llvm-mt.cpp @@ -109,7 +109,7 @@ int main(int Argc, const char **Argv) { } if (InputArgs.hasArg(OPT_help)) { - T.PrintHelp(outs(), "llvm-mt [options] file...", "Manifest Tool", false); + T.printHelp(outs(), "llvm-mt [options] file...", "Manifest Tool", false); return 0; } diff --git a/llvm/tools/llvm-objcopy/ConfigManager.cpp b/llvm/tools/llvm-objcopy/ConfigManager.cpp index 39c5857e2c3f3..70939ee896678 100644 --- a/llvm/tools/llvm-objcopy/ConfigManager.cpp +++ b/llvm/tools/llvm-objcopy/ConfigManager.cpp @@ -459,7 +459,7 @@ static void printHelp(const opt::OptTable &OptTable, raw_ostream &OS, HelpText = " [options] input"; break; } - OptTable.PrintHelp(OS, (ToolName + HelpText).str().c_str(), + OptTable.printHelp(OS, (ToolName + HelpText).str().c_str(), (ToolName + " tool").str().c_str()); // TODO: Replace this with libOption call once it adds extrahelp support. // The CommandLine library has a cl::extrahelp class to support this, diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 2f0e05e3d267f..b0ca095db381e 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -99,8 +99,8 @@ class CommonOptTable : public opt::OptTable { void printHelp(StringRef Argv0, bool ShowHidden = false) const { Argv0 = sys::path::filename(Argv0); - PrintHelp(outs(), (Argv0 + Usage).str().c_str(), Description, ShowHidden, - ShowHidden); + opt::OptTable::printHelp(outs(), (Argv0 + Usage).str().c_str(), Description, + ShowHidden, ShowHidden); // TODO Replace this with OptTable API once it adds extrahelp support. outs() << "\nPass @FILE as argument to read options from FILE.\n"; } diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp index 33d94c37cedd9..dc01fd0c2e9f0 100644 --- a/llvm/tools/llvm-rc/llvm-rc.cpp +++ b/llvm/tools/llvm-rc/llvm-rc.cpp @@ -347,7 +347,7 @@ RcOptions parseWindresOptions(ArrayRef ArgsArr, // The tool prints nothing when invoked with no command-line arguments. if (InputArgs.hasArg(WINDRES_help)) { - T.PrintHelp(outs(), "windres [options] file...", + T.printHelp(outs(), "windres [options] file...", "LLVM windres (GNU windres compatible)", false, true); exit(0); } @@ -494,7 +494,7 @@ RcOptions parseRcOptions(ArrayRef ArgsArr, // The tool prints nothing when invoked with no command-line arguments. if (InputArgs.hasArg(OPT_help)) { - T.PrintHelp(outs(), "rc [options] file...", "Resource Converter", false); + T.printHelp(outs(), "rc [options] file...", "Resource Converter", false); exit(0); } diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp index cc816c024391a..2359e5d2b4587 100644 --- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -196,7 +196,7 @@ static void symbolizeInput(const opt::InputArgList &Args, uint64_t AdjustVMA, static void printHelp(StringRef ToolName, const SymbolizerOptTable &Tbl, raw_ostream &OS) { const char HelpText[] = " [options] addresses..."; - Tbl.PrintHelp(OS, (ToolName + HelpText).str().c_str(), + Tbl.printHelp(OS, (ToolName + HelpText).str().c_str(), ToolName.str().c_str()); // TODO Replace this with OptTable API once it adds extrahelp support. OS << "\nPass @FILE as argument to read options from FILE.\n"; diff --git a/llvm/unittests/Option/OptionParsingTest.cpp b/llvm/unittests/Option/OptionParsingTest.cpp index feeb3b7866cda..f0299d2d58922 100644 --- a/llvm/unittests/Option/OptionParsingTest.cpp +++ b/llvm/unittests/Option/OptionParsingTest.cpp @@ -93,11 +93,11 @@ TEST(Option, OptionParsing) { // Check the help text. std::string Help; raw_string_ostream RSO(Help); - T.PrintHelp(RSO, "test", "title!"); + T.printHelp(RSO, "test", "title!"); EXPECT_NE(std::string::npos, Help.find("-A")); // Check usage line. - T.PrintHelp(RSO, "name [options] file...", "title!"); + T.printHelp(RSO, "name [options] file...", "title!"); EXPECT_NE(std::string::npos, Help.find("USAGE: name [options] file...\n")); // Test aliases.