[llvm-commits] CVS: llvm/lib/Support/CommandLine.cpp
Reid Spencer
reid at x10sys.com
Tue Aug 3 17:36:17 PDT 2004
Changes in directory llvm/lib/Support:
CommandLine.cpp updated: 1.46 -> 1.47
---
Log message:
Add a --version option for every tool that prints out:
Low Level Virtual Machine ($PACKAGE_NAME) $PACKAGE_VERSION
---
Diffs of the changes: (+18 -1)
Index: llvm/lib/Support/CommandLine.cpp
diff -u llvm/lib/Support/CommandLine.cpp:1.46 llvm/lib/Support/CommandLine.cpp:1.47
--- llvm/lib/Support/CommandLine.cpp:1.46 Sun Jul 18 16:56:20 2004
+++ llvm/lib/Support/CommandLine.cpp Tue Aug 3 19:36:06 2004
@@ -16,6 +16,7 @@
//
//===----------------------------------------------------------------------===//
+#include "Config/config.h"
#include "Support/CommandLine.h"
#include <algorithm>
#include <map>
@@ -176,7 +177,7 @@
/// them later.
///
static void ParseCStringVector (std::vector<char *> &output,
- const char *input) {
+ const char *input) {
// Characters which will be treated as token separators:
static const char *delims = " \v\f\t\r\n";
@@ -891,6 +892,16 @@
}
};
+class VersionPrinter {
+public:
+ void operator=(bool OptionWasSpecified) {
+ if (OptionWasSpecified) {
+ std::cerr << "Low Level Virtual Machine (" << PACKAGE_NAME << ") "
+ << PACKAGE_VERSION << " (see http://llvm.org/)\n";
+ exit(1);
+ }
+ }
+};
// Define the two HelpPrinter instances that are used to print out help, or
@@ -907,4 +918,10 @@
HHOp("help-hidden", cl::desc("display all available options"),
cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed);
+// Define the --version option that prints out the LLVM version for the tool
+VersionPrinter VersionPrinterInstance;
+cl::opt<VersionPrinter, true, parser<bool> >
+VersOp("version", cl::desc("display the version"),
+ cl::location(VersionPrinterInstance), cl::ValueDisallowed);
+
} // End anonymous namespace
More information about the llvm-commits
mailing list