diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-09-07 23:30:48 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-09-07 23:30:48 +0000 |
commit | 39c150eecbc1cf83836c59a516ee9aa1795a189c (patch) | |
tree | c7143559b7d4b1446f922dc039f5a9dcb23ae2d2 /llvm/lib/Support/CommandLine.cpp | |
parent | 975293f0e593761a5d2d4446463fecd14b425aff (diff) | |
download | bcm5719-llvm-39c150eecbc1cf83836c59a516ee9aa1795a189c.tar.gz bcm5719-llvm-39c150eecbc1cf83836c59a516ee9aa1795a189c.zip |
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
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 8fb01211e97..0d662cb0375 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -1758,7 +1758,13 @@ public: void operator=(bool Value) { if (!Value) return; + printHelp(); + // Halt the program since help information was printed + exit(0); + } + + void printHelp() { SubCommand *Sub = GlobalParser->getActiveSubCommand(); auto &OptionsMap = Sub->OptionsMap; auto &PositionalOpts = Sub->PositionalOpts; @@ -1826,9 +1832,6 @@ public: for (auto I : GlobalParser->MoreHelp) outs() << I; 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. 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) - UncategorizedNormalPrinter = true; + UncategorizedNormalPrinter.printHelp(); else if (!Hidden && Categorized) - CategorizedNormalPrinter = true; + CategorizedNormalPrinter.printHelp(); else if (Hidden && !Categorized) - UncategorizedHiddenPrinter = true; + UncategorizedHiddenPrinter.printHelp(); else - CategorizedHiddenPrinter = true; + CategorizedHiddenPrinter.printHelp(); } /// Utility function for printing version number. |