[PATCH] llvm-cov: Removed output to STDOUT/specified file.
Justin Bogner
mail at justinbogner.com
Mon Dec 2 14:31:25 PST 2013
LGTM
Yuchen Wu <yuchenericwu at hotmail.com> writes:
> llvm-cov: Removed output to STDOUT/specified file.
>
> Instead of asking the user to specify a single file to output coverage
> info to and defaulting to STDOUT, llvm-cov now creates files for each
> source file with a naming system of: <source filename> + ".llcov"
>
> This is what gcov does and although it can clutter the working directory
> with numerous coverage files, it will be easier to hook the llvm-cov
> output to tools which operate on this assumption (such as lcov).
>
> Also updated test.
>
> From d71aae088741a3b4d333d49e5b4549707dbf0e08 Mon Sep 17 00:00:00 2001
> From: Yuchen Wu <yuchen_wu at apple.com>
> Date: Fri, 15 Nov 2013 16:07:49 -0800
> Subject: [PATCH 27/29] llvm-cov: Removed output to STDOUT/specified file.
>
> Instead of asking the user to specify a single file to output coverage
> info to and defaulting to STDOUT, llvm-cov now creates files for each
> source file with a naming system of: <source filename> + ".llcov".
>
> This is what gcov does and although it can clutter the working directory
> with numerous coverage files, it will be easier to hook the llvm-cov
> output to tools which operate on this assumption (such as lcov).
>
> Also updated test.
> ---
> include/llvm/Support/GCOV.h | 2 +-
> lib/IR/GCOV.cpp | 10 ++++++++--
> test/tools/llvm-cov/llvm-cov.test | 5 +++--
> tools/llvm-cov/llvm-cov.cpp | 12 +-----------
> 4 files changed, 13 insertions(+), 16 deletions(-)
>
> diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h
> index 3bbc0ad..3298132 100644
> --- a/include/llvm/Support/GCOV.h
> +++ b/include/llvm/Support/GCOV.h
> @@ -282,7 +282,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<LineData> LineInfo;
> uint32_t RunCount;
> diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp
> index 99e9156..885a4a2 100644
> --- a/lib/IR/GCOV.cpp
> +++ b/lib/IR/GCOV.cpp
> @@ -18,6 +18,7 @@
> #include "llvm/ADT/STLExtras.h"
> #include "llvm/Support/Format.h"
> #include "llvm/Support/MemoryObject.h"
> +#include "llvm/Support/raw_ostream.h"
> #include "llvm/Support/system_error.h"
> using namespace llvm;
>
> @@ -352,8 +353,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<LineData>::const_iterator I = LineInfo.begin(),
> E = LineInfo.end(); I != E; ++I) {
> StringRef Filename = I->first();
> @@ -364,6 +364,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/test/tools/llvm-cov/llvm-cov.test b/test/tools/llvm-cov/llvm-cov.test
> index 12c21ef..97404aa 100644
> --- a/test/tools/llvm-cov/llvm-cov.test
> +++ b/test/tools/llvm-cov/llvm-cov.test
> @@ -1,7 +1,8 @@
> RUN: cd %p/Inputs
>
> -RUN: llvm-cov -gcno=test.gcno -gcda=test.gcda \
> -RUN: | diff 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/tools/llvm-cov/llvm-cov.cpp b/tools/llvm-cov/llvm-cov.cpp
> index 5f6999e..7f4d53e 100644
> --- a/tools/llvm-cov/llvm-cov.cpp
> +++ b/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("<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) {
> // 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;
> }
More information about the llvm-commits
mailing list