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
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 8fb0121..0d662cb 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -1758,7 +1758,13 @@
   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 @@
     for (auto I : GlobalParser->MoreHelp)
       outs() << I;
     GlobalParser->MoreHelp.clear();
-
-    // Halt the program since help information was printed
-    exit(0);
   }
 };
 
@@ -2098,21 +2101,14 @@
 
 // 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.