aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Support/CommandLine.h1
-rw-r--r--lib/Support/CommandLine.cpp14
2 files changed, 12 insertions, 3 deletions
diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h
index 662c935c44..f9cf3be994 100644
--- a/include/llvm/Support/CommandLine.h
+++ b/include/llvm/Support/CommandLine.h
@@ -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!
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;
}