[OptTable] Rename PrintHelp to printHelp

To be consistent with other member functions and match the coding standard.
This commit is contained in:
Fangrui Song 2021-06-24 14:47:03 -07:00
parent 9ca0171a9f
commit f1e2d5851b
27 changed files with 38 additions and 37 deletions

View File

@ -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);
}

View File

@ -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,

View File

@ -585,7 +585,7 @@ int cc1as_main(ArrayRef<const char *> 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,

View File

@ -103,7 +103,7 @@ std::unique_ptr<FrontendAction> 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,

View File

@ -933,7 +933,7 @@ std::vector<const char *> 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);
}

View File

@ -145,7 +145,7 @@ opt::InputArgList ELFOptTable::parse(ArrayRef<const char *> 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";

View File

@ -107,8 +107,9 @@ InputArgList MachOOptTable::parse(ArrayRef<const char *> 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";
}

View File

@ -83,7 +83,7 @@ public:
} // 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";

View File

@ -383,7 +383,7 @@ bool parse(llvm::ArrayRef<const char *> 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 {

View File

@ -823,7 +823,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> 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;

View File

@ -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:

View File

@ -356,7 +356,7 @@ public:
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.

View File

@ -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:

View File

@ -249,11 +249,11 @@ public:
/// 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;
};

View File

@ -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";

View File

@ -122,7 +122,7 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef<const char *> 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;

View File

@ -287,7 +287,7 @@ int llvm::libDriverMain(ArrayRef<const char *> 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;
}

View File

@ -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] <input files>").c_str(),
"manipulate archived DWARF debug symbol files.\n\n"
"dsymutil links the DWARF debug information found in the object files\n"

View File

@ -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;
}

View File

@ -159,14 +159,14 @@ static Config parseLipoOptions(ArrayRef<const char *> 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);
}

View File

@ -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()) {

View File

@ -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;
}

View File

@ -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,

View File

@ -99,8 +99,8 @@ public:
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";
}

View File

@ -347,7 +347,7 @@ RcOptions parseWindresOptions(ArrayRef<const char *> 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<const char *> 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);
}

View File

@ -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";

View File

@ -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.