summaryrefslogtreecommitdiff
path: root/lib/Support
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-08-04 00:36:06 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-08-04 00:36:06 +0000
commit69105f33c190621a6b1ad61f925b1a9e6b0512af (patch)
treeadf2dc18b8b556c43e9617329029746ef2be32d8 /lib/Support
parent2b51a0806db1a717090cb2a2afc3e9634d536f09 (diff)
downloadllvm-69105f33c190621a6b1ad61f925b1a9e6b0512af.tar.gz
llvm-69105f33c190621a6b1ad61f925b1a9e6b0512af.tar.bz2
llvm-69105f33c190621a6b1ad61f925b1a9e6b0512af.tar.xz
Add a --version option for every tool that prints out:
Low Level Virtual Machine ($PACKAGE_NAME) $PACKAGE_VERSION git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15454 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/CommandLine.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index 0e0cad96ea..131b95a75c 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -16,6 +16,7 @@
//
//===----------------------------------------------------------------------===//
+#include "Config/config.h"
#include "Support/CommandLine.h"
#include <algorithm>
#include <map>
@@ -176,7 +177,7 @@ static bool EatsUnboundedNumberOfValues(const Option *O) {
/// 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 @@ public:
}
};
+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 @@ cl::opt<HelpPrinter, true, parser<bool> >
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