From aed293dfba04b07a867491c11dfff4bf3eb6bddd Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Thu, 1 Feb 2007 01:43:37 +0000 Subject: Add PrintVersionMessage() that tools can use to print version number without exiting program. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33737 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 012f759d4f..e556d76f96 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -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; } -- cgit v1.2.3-18-g5258