Add PrintVersionMessage() that tools can use to print version number
authorDevang Patel <dpatel@apple.com>
Thu, 1 Feb 2007 01:43:37 +0000 (01:43 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 1 Feb 2007 01:43:37 +0000 (01:43 +0000)
without exiting program.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33737 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/CommandLine.h
lib/Support/CommandLine.cpp

index 662c935c44129660181274edb44243167e1bd883..f9cf3be99463be0f90f6989e60dfbc4903471cfd 100644 (file)
@@ -1281,6 +1281,7 @@ struct extrahelp {
   extrahelp(const char* help);
 };
 
+void PrintVersionMessage();
 // This function just prints the help message, exactly the same way as if the
 // --help option had been given on the command line.
 // NOTE: THIS FUNCTION TERMINATES THE PROGRAM!
index 012f759d4f65ca4bd0617ca16137bf97193a7bcf..e556d76f96580c7e872cd84ae622e69e4404d84d 100644 (file)
@@ -980,9 +980,7 @@ static void (*OverrideVersionPrinter)() = 0;
 namespace {
 class VersionPrinter {
 public:
-  void operator=(bool OptionWasSpecified) {
-    if (OptionWasSpecified) {
-      if (OverrideVersionPrinter == 0) {
+  void print() {
         cout << "Low Level Virtual Machine (http://llvm.org/):\n";
         cout << "  " << PACKAGE_NAME << " version " << PACKAGE_VERSION;
 #ifdef LLVM_VERSION_INFO
@@ -998,6 +996,11 @@ public:
         cout << " with assertions";
 #endif
         cout << ".\n";
+  }
+  void operator=(bool OptionWasSpecified) {
+    if (OptionWasSpecified) {
+      if (OverrideVersionPrinter == 0) {
+        print();
         Options->clear();  // Don't bother making option dtors remove from map.
         exit(1);
       } else {
@@ -1028,6 +1031,11 @@ void cl::PrintHelpMessage() {
   NormalPrinter = true;
 }
 
+/// Utility function for printing version number.
+void cl::PrintVersionMessage() {
+  VersionPrinterInstance.print();
+}
+
 void cl::SetVersionPrinter(void (*func)()) {
   OverrideVersionPrinter = func;
 }