llvm-cov: Make llvm-cov --version DTRT
authorJustin Bogner <mail@justinbogner.com>
Wed, 3 Jun 2015 02:48:09 +0000 (02:48 +0000)
committerJustin Bogner <mail@justinbogner.com>
Wed, 3 Jun 2015 02:48:09 +0000 (02:48 +0000)
In r233132 we started requiring a subcommand in llvm-cov, but this
made `llvm-cov --version` invalid, which is kind of silly. Print
version information in this case, as most people would expect.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238897 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-cov/llvm-cov.cpp

index bf66f583a5282eea59091e482cc0ff076ceb5688..8c5acaef63b2561ca8518d57fc1a7c22fd708727 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/raw_ostream.h"
@@ -43,6 +44,12 @@ static int helpMain(int argc, const char *argv[]) {
   return 0;
 }
 
+/// \brief Top level version information.
+static int versionMain(int argc, const char *argv[]) {
+  cl::PrintVersionMessage();
+  return 0;
+}
+
 int main(int argc, const char **argv) {
   // If argv[0] is or ends with 'gcov', always be gcov compatible
   if (sys::path::stem(argv[0]).endswith_lower("gcov"))
@@ -57,6 +64,7 @@ int main(int argc, const char **argv) {
                             .Case("report", reportMain)
                             .Case("show", showMain)
                             .Cases("-h", "-help", "--help", helpMain)
+                            .Cases("-version", "--version", versionMain)
                             .Default(nullptr);
 
     if (Func) {