aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-06-05 16:22:56 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-06-05 16:22:56 +0000
commit515b5b379f3508f36f647bfdafce409e28a3d90b (patch)
treeeb8a8e442294845b00b76aaf162a969d9d7474ae /lib
parentcdb08a3691b0949ea9fea690571631e1a842bf3a (diff)
downloadexternal_llvm-515b5b379f3508f36f647bfdafce409e28a3d90b.zip
external_llvm-515b5b379f3508f36f647bfdafce409e28a3d90b.tar.gz
external_llvm-515b5b379f3508f36f647bfdafce409e28a3d90b.tar.bz2
Make it possible to override the standard version printer. Not all tools
built with CommandLine.h will want the --version option to report that the tool belongs to LLVM. To override simply pass a void func() to the cl::SetVersionPrinter() function and that void func() will be called when it is time to print the version information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28687 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Support/CommandLine.cpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index 90867e7..4b3a1d8 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -951,24 +951,6 @@ public:
}
};
-class VersionPrinter {
-public:
- void operator=(bool OptionWasSpecified) {
- if (OptionWasSpecified) {
- std::cout << "Low Level Virtual Machine (" << PACKAGE_NAME << ") "
- << PACKAGE_VERSION << " (see http://llvm.org/)";
-#ifndef NDEBUG
- std::cout << " ASSERTIONS ENABLED\n";
-#else
- std::cout << "\n";
-#endif
- getOpts().clear(); // Don't bother making option dtors remove from map.
- exit(1);
- }
- }
-};
-
-
// Define the two HelpPrinter instances that are used to print out help, or
// help-hidden...
//
@@ -983,6 +965,31 @@ cl::opt<HelpPrinter, true, parser<bool> >
HHOp("help-hidden", cl::desc("Display all available options"),
cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed);
+void (*OverrideVersionPrinter)() = 0;
+
+class VersionPrinter {
+public:
+ void operator=(bool OptionWasSpecified) {
+ if (OptionWasSpecified) {
+ if (OverrideVersionPrinter == 0) {
+ std::cout << "Low Level Virtual Machine (" << PACKAGE_NAME << ") "
+ << PACKAGE_VERSION << " (see http://llvm.org/)";
+#ifndef NDEBUG
+ std::cout << " ASSERTIONS ENABLED\n";
+#else
+ std::cout << "\n";
+#endif
+ getOpts().clear(); // Don't bother making option dtors remove from map.
+ exit(1);
+ } else {
+ (*OverrideVersionPrinter)();
+ exit(1);
+ }
+ }
+ }
+};
+
+
// Define the --version option that prints out the LLVM version for the tool
VersionPrinter VersionPrinterInstance;
cl::opt<VersionPrinter, true, parser<bool> >
@@ -1002,3 +1009,7 @@ void cl::PrintHelpMessage() {
// to make it look like --help was given, so we assign true.
NormalPrinter = true;
}
+
+void cl::SetVersionPrinter(void (*func)()) {
+ OverrideVersionPrinter = func;
+}