mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Don't call exit from cl::PrintHelpMessage.
Most callers were not expecting the exit(0) and trying to exit with a different value. This also adds back the call to cl::PrintHelpMessage in llvm-ar. llvm-svn: 312761
This commit is contained in:
parent
d3b4cc91a1
commit
4f9f7452be
@ -1762,8 +1762,6 @@ void PrintVersionMessage();
|
|||||||
/// This function just prints the help message, exactly the same way as if the
|
/// This function just prints the help message, exactly the same way as if the
|
||||||
/// -help or -help-hidden option had been given on the command line.
|
/// -help or -help-hidden option had been given on the command line.
|
||||||
///
|
///
|
||||||
/// NOTE: THIS FUNCTION TERMINATES THE PROGRAM!
|
|
||||||
///
|
|
||||||
/// \param Hidden if true will print hidden options
|
/// \param Hidden if true will print hidden options
|
||||||
/// \param Categorized if true print options in categories
|
/// \param Categorized if true print options in categories
|
||||||
void PrintHelpMessage(bool Hidden = false, bool Categorized = false);
|
void PrintHelpMessage(bool Hidden = false, bool Categorized = false);
|
||||||
|
@ -1758,7 +1758,13 @@ public:
|
|||||||
void operator=(bool Value) {
|
void operator=(bool Value) {
|
||||||
if (!Value)
|
if (!Value)
|
||||||
return;
|
return;
|
||||||
|
printHelp();
|
||||||
|
|
||||||
|
// Halt the program since help information was printed
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void printHelp() {
|
||||||
SubCommand *Sub = GlobalParser->getActiveSubCommand();
|
SubCommand *Sub = GlobalParser->getActiveSubCommand();
|
||||||
auto &OptionsMap = Sub->OptionsMap;
|
auto &OptionsMap = Sub->OptionsMap;
|
||||||
auto &PositionalOpts = Sub->PositionalOpts;
|
auto &PositionalOpts = Sub->PositionalOpts;
|
||||||
@ -1826,9 +1832,6 @@ public:
|
|||||||
for (auto I : GlobalParser->MoreHelp)
|
for (auto I : GlobalParser->MoreHelp)
|
||||||
outs() << I;
|
outs() << I;
|
||||||
GlobalParser->MoreHelp.clear();
|
GlobalParser->MoreHelp.clear();
|
||||||
|
|
||||||
// Halt the program since help information was printed
|
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2098,21 +2101,14 @@ static cl::opt<VersionPrinter, true, parser<bool>>
|
|||||||
|
|
||||||
// Utility function for printing the help message.
|
// Utility function for printing the help message.
|
||||||
void cl::PrintHelpMessage(bool Hidden, bool Categorized) {
|
void cl::PrintHelpMessage(bool Hidden, bool Categorized) {
|
||||||
// This looks weird, but it actually prints the help message. The Printers are
|
|
||||||
// types of HelpPrinter and the help gets printed when its operator= is
|
|
||||||
// invoked. That's because the "normal" usages of the help printer is to be
|
|
||||||
// assigned true/false depending on whether -help or -help-hidden was given or
|
|
||||||
// not. Since we're circumventing that we have to make it look like -help or
|
|
||||||
// -help-hidden were given, so we assign true.
|
|
||||||
|
|
||||||
if (!Hidden && !Categorized)
|
if (!Hidden && !Categorized)
|
||||||
UncategorizedNormalPrinter = true;
|
UncategorizedNormalPrinter.printHelp();
|
||||||
else if (!Hidden && Categorized)
|
else if (!Hidden && Categorized)
|
||||||
CategorizedNormalPrinter = true;
|
CategorizedNormalPrinter.printHelp();
|
||||||
else if (Hidden && !Categorized)
|
else if (Hidden && !Categorized)
|
||||||
UncategorizedHiddenPrinter = true;
|
UncategorizedHiddenPrinter.printHelp();
|
||||||
else
|
else
|
||||||
CategorizedHiddenPrinter = true;
|
CategorizedHiddenPrinter.printHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Utility function for printing version number.
|
/// Utility function for printing version number.
|
||||||
|
@ -2,3 +2,4 @@ Test that llvm-ar exits with 1 when there is an error.
|
|||||||
|
|
||||||
RUN: not llvm-ar e 2>&1 | FileCheck %s
|
RUN: not llvm-ar e 2>&1 | FileCheck %s
|
||||||
CHECK: unknown option e.
|
CHECK: unknown option e.
|
||||||
|
CHECK: OVERVIEW: LLVM Archiver (llvm-ar)
|
||||||
|
@ -253,8 +253,10 @@ int main(int argc, char **argv) {
|
|||||||
"for the executable <input file> by using debug symbols information\n"
|
"for the executable <input file> by using debug symbols information\n"
|
||||||
"contained in its symbol table.\n");
|
"contained in its symbol table.\n");
|
||||||
|
|
||||||
if (Help)
|
if (Help) {
|
||||||
PrintHelpMessage();
|
PrintHelpMessage();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (Version) {
|
if (Version) {
|
||||||
llvm::cl::PrintVersionMessage();
|
llvm::cl::PrintVersionMessage();
|
||||||
|
@ -54,8 +54,7 @@ static StringRef ToolName;
|
|||||||
// Show the error message and exit.
|
// Show the error message and exit.
|
||||||
LLVM_ATTRIBUTE_NORETURN static void fail(Twine Error) {
|
LLVM_ATTRIBUTE_NORETURN static void fail(Twine Error) {
|
||||||
errs() << ToolName << ": " << Error << ".\n";
|
errs() << ToolName << ": " << Error << ".\n";
|
||||||
// FIXME: Other ar implementations will print the command line help in here.
|
cl::PrintHelpMessage();
|
||||||
// Unfortunately cl::PrintHelpMessage() exits with 0, so we can't call it.
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,8 +514,10 @@ int main(int argc, const char **argv) {
|
|||||||
"A tool to generate an optimization report from YAML optimization"
|
"A tool to generate an optimization report from YAML optimization"
|
||||||
" record files.\n");
|
" record files.\n");
|
||||||
|
|
||||||
if (Help)
|
if (Help) {
|
||||||
cl::PrintHelpMessage();
|
cl::PrintHelpMessage();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
LocationInfoTy LocationInfo;
|
LocationInfoTy LocationInfo;
|
||||||
if (!readLocationInfo(LocationInfo))
|
if (!readLocationInfo(LocationInfo))
|
||||||
|
@ -46,4 +46,5 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// If all else fails, we still print the usage message.
|
// If all else fails, we still print the usage message.
|
||||||
cl::PrintHelpMessage(false, true);
|
cl::PrintHelpMessage(false, true);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user