[llvm-commits] CVS: llvm/lib/Support/CommandLine.cpp
Reid Spencer
reid at x10sys.com
Mon Jun 5 09:23:09 PDT 2006
Changes in directory llvm/lib/Support:
CommandLine.cpp updated: 1.67 -> 1.68
---
Log message:
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.
---
Diffs of the changes: (+29 -18)
CommandLine.cpp | 47 +++++++++++++++++++++++++++++------------------
1 files changed, 29 insertions(+), 18 deletions(-)
Index: llvm/lib/Support/CommandLine.cpp
diff -u llvm/lib/Support/CommandLine.cpp:1.67 llvm/lib/Support/CommandLine.cpp:1.68
--- llvm/lib/Support/CommandLine.cpp:1.67 Fri Apr 28 00:36:25 2006
+++ llvm/lib/Support/CommandLine.cpp Mon Jun 5 11:22:56 2006
@@ -951,24 +951,6 @@
}
};
-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 @@
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 @@
// to make it look like --help was given, so we assign true.
NormalPrinter = true;
}
+
+void cl::SetVersionPrinter(void (*func)()) {
+ OverrideVersionPrinter = func;
+}
More information about the llvm-commits
mailing list