aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm-cov/llvm-cov.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-cov/llvm-cov.cpp')
-rw-r--r--tools/llvm-cov/llvm-cov.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/llvm-cov/llvm-cov.cpp b/tools/llvm-cov/llvm-cov.cpp
index 7b21c5b..5f6999e 100644
--- a/tools/llvm-cov/llvm-cov.cpp
+++ b/tools/llvm-cov/llvm-cov.cpp
@@ -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())
@@ -49,7 +58,7 @@ int main(int argc, char **argv) {
errs() << InputGCNO << ": " << ec.message() << "\n";
return 1;
}
- GCOVBuffer GCNO_GB(GCNO_Buff.take());
+ GCOVBuffer GCNO_GB(GCNO_Buff.get());
if (!GF.read(GCNO_GB)) {
errs() << "Invalid .gcno File!\n";
return 1;
@@ -61,7 +70,7 @@ int main(int argc, char **argv) {
errs() << InputGCDA << ": " << ec.message() << "\n";
return 1;
}
- GCOVBuffer GCDA_GB(GCDA_Buff.take());
+ GCOVBuffer GCDA_GB(GCDA_Buff.get());
if (!GF.read(GCDA_GB)) {
errs() << "Invalid .gcda File!\n";
return 1;
@@ -74,5 +83,6 @@ int main(int argc, char **argv) {
FileInfo FI;
GF.collectLineCounts(FI);
+ FI.print(OS, InputGCNO, InputGCDA);
return 0;
}