diff --git a/llvm/include/llvm/Support/GCOV.h b/llvm/include/llvm/Support/GCOV.h index c709af5d502c..9aa44139f0b1 100644 --- a/llvm/include/llvm/Support/GCOV.h +++ b/llvm/include/llvm/Support/GCOV.h @@ -279,7 +279,7 @@ public: } void setRunCount(uint32_t Runs) { RunCount = Runs; } void setProgramCount(uint32_t Programs) { ProgramCount = Programs; } - void print(raw_fd_ostream &OS, StringRef gcnoFile, StringRef gcdaFile) const; + void print(StringRef gcnoFile, StringRef gcdaFile) const; private: StringMap LineInfo; uint32_t RunCount; diff --git a/llvm/lib/IR/GCOV.cpp b/llvm/lib/IR/GCOV.cpp index bcc62b11d5fd..394c683cee2c 100644 --- a/llvm/lib/IR/GCOV.cpp +++ b/llvm/lib/IR/GCOV.cpp @@ -317,8 +317,7 @@ void GCOVBlock::dump() const { // FileInfo implementation. /// print - Print source files with collected line count information. -void FileInfo::print(raw_fd_ostream &OS, StringRef gcnoFile, - StringRef gcdaFile) const { +void FileInfo::print(StringRef gcnoFile, StringRef gcdaFile) const { for (StringMap::const_iterator I = LineInfo.begin(), E = LineInfo.end(); I != E; ++I) { StringRef Filename = I->first(); @@ -329,6 +328,12 @@ void FileInfo::print(raw_fd_ostream &OS, StringRef gcnoFile, } StringRef AllLines = Buff->getBuffer(); + std::string CovFilename = Filename.str() + ".llcov"; + std::string ErrorInfo; + raw_fd_ostream OS(CovFilename.c_str(), ErrorInfo); + if (!ErrorInfo.empty()) + errs() << ErrorInfo << "\n"; + OS << " -: 0:Source:" << Filename << "\n"; OS << " -: 0:Graph:" << gcnoFile << "\n"; OS << " -: 0:Data:" << gcdaFile << "\n"; diff --git a/llvm/test/tools/llvm-cov/llvm-cov.test b/llvm/test/tools/llvm-cov/llvm-cov.test index 39f112e8d290..55af86e85125 100644 --- a/llvm/test/tools/llvm-cov/llvm-cov.test +++ b/llvm/test/tools/llvm-cov/llvm-cov.test @@ -2,8 +2,9 @@ RUN: cd %p/Inputs # "cd" is unsupported in lit internal runner. REQUIRES: shell -RUN: llvm-cov -gcno=test.gcno -gcda=test.gcda \ -RUN: | diff -aub test.cpp.gcov - +RUN: llvm-cov -gcno=test.gcno -gcda=test.gcda +RUN: diff test.cpp.gcov test.cpp.llcov +RUN: rm test.cpp.llcov RUN: not llvm-cov -gcno=test_read_fail.gcno -gcda=test.gcda diff --git a/llvm/tools/llvm-cov/llvm-cov.cpp b/llvm/tools/llvm-cov/llvm-cov.cpp index 5f6999e90564..7f4d53e848b9 100644 --- a/llvm/tools/llvm-cov/llvm-cov.cpp +++ b/llvm/tools/llvm-cov/llvm-cov.cpp @@ -17,7 +17,6 @@ #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; @@ -31,10 +30,6 @@ InputGCNO("gcno", cl::desc(""), cl::init("")); static cl::opt InputGCDA("gcda", cl::desc(""), cl::init("")); -static cl::opt -OutputFile("o", cl::desc(""), cl::init("-")); - - //===----------------------------------------------------------------------===// int main(int argc, char **argv) { // Print a stack trace if we signal out. @@ -44,11 +39,6 @@ int main(int argc, char **argv) { 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()) errs() << " " << argv[0] << ": No gcov input file!\n"; @@ -83,6 +73,6 @@ int main(int argc, char **argv) { FileInfo FI; GF.collectLineCounts(FI); - FI.print(OS, InputGCNO, InputGCDA); + FI.print(InputGCNO, InputGCDA); return 0; }