[llvm] r238897 - llvm-cov: Make llvm-cov --version DTRT

Justin Bogner mail at justinbogner.com
Tue Jun 2 19:48:09 PDT 2015


Author: bogner
Date: Tue Jun  2 21:48:09 2015
New Revision: 238897

URL: http://llvm.org/viewvc/llvm-project?rev=238897&view=rev
Log:
llvm-cov: Make llvm-cov --version DTRT

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.

Modified:
    llvm/trunk/tools/llvm-cov/llvm-cov.cpp

Modified: llvm/trunk/tools/llvm-cov/llvm-cov.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/llvm-cov.cpp?rev=238897&r1=238896&r2=238897&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/llvm-cov.cpp (original)
+++ llvm/trunk/tools/llvm-cov/llvm-cov.cpp Tue Jun  2 21:48:09 2015
@@ -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
   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) {





More information about the llvm-commits mailing list