Revert "llvm-cov: Added command-line option to change dir."
[oota-llvm.git] / tools / llvm-cov / llvm-cov.cpp
index 26aec4632b57ebfc1bb407e0d7f3b97725cfa46c..ad6c67181548b59fcdb93fe4f3e796c7af8673f6 100644 (file)
@@ -17,6 +17,7 @@
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryObject.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/system_error.h"
 using namespace llvm;
@@ -30,6 +31,9 @@ InputGCNO("gcno", cl::desc("<input gcno file>"), cl::init(""));
 static cl::opt<std::string>
 InputGCDA("gcda", cl::desc("<input gcda file>"), cl::init(""));
 
+static cl::opt<std::string>
+OutputFile("o", cl::desc("<output llvm-cov file>"), cl::init("-"));
+
 
 //===----------------------------------------------------------------------===//
 int main(int argc, char **argv) {
@@ -38,7 +42,12 @@ int main(int argc, char **argv) {
   PrettyStackTraceProgram X(argc, argv);
   llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
 
-  cl::ParseCommandLineOptions(argc, argv, "llvm cov\n");
+  cl::ParseCommandLineOptions(argc, argv, "llvm coverage tool\n");
+
+  std::string ErrorInfo;
+  raw_fd_ostream OS(OutputFile.c_str(), ErrorInfo);
+  if (!ErrorInfo.empty())
+    errs() << ErrorInfo << "\n";
 
   GCOVFile GF;
   if (InputGCNO.empty())
@@ -74,6 +83,6 @@ int main(int argc, char **argv) {
 
   FileInfo FI;
   GF.collectLineCounts(FI);
-  FI.print(InputGCNO, InputGCDA);
+  FI.print(OS, InputGCNO, InputGCDA);
   return 0;
 }