diff options
author | Justin Bogner <mail@justinbogner.com> | 2014-01-29 21:31:34 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2014-01-29 21:31:34 +0000 |
commit | 5119fd5e0f1771a2ad52a33d7b3b2de3c1e38934 (patch) | |
tree | 7d17f44dbd3973a7b6c3c78df63f897fad870f1c /tools/llvm-cov | |
parent | 94b3a88395ff0ea6c253efe5dd2b9d400ffe7c9d (diff) | |
download | llvm-5119fd5e0f1771a2ad52a33d7b3b2de3c1e38934.tar.gz llvm-5119fd5e0f1771a2ad52a33d7b3b2de3c1e38934.tar.bz2 llvm-5119fd5e0f1771a2ad52a33d7b3b2de3c1e38934.tar.xz |
llvm-cov: Expect a source file as a positional parameter
Currently, llvm-cov isn't command-line compatible with gcov, which
accepts a source file name as its first parameter and infers the gcno
and gcda file names from that. This change keeps our -gcda and -gcno
options available for convenience in overriding this behaviour, but
adds the required parameter and inference behaviour as a compatible
default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200417 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-cov')
-rw-r--r-- | tools/llvm-cov/llvm-cov.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/tools/llvm-cov/llvm-cov.cpp b/tools/llvm-cov/llvm-cov.cpp index 31f6ad0058..177c99d896 100644 --- a/tools/llvm-cov/llvm-cov.cpp +++ b/tools/llvm-cov/llvm-cov.cpp @@ -21,6 +21,9 @@ #include "llvm/Support/system_error.h" using namespace llvm; +static cl::opt<std::string> SourceFile(cl::Positional, cl::Required, + cl::desc("SOURCEFILE")); + static cl::opt<bool> DumpGCOV("dump", cl::init(false), cl::desc("dump gcov file")); @@ -56,9 +59,12 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, "llvm coverage tool\n"); - GCOVFile GF; if (InputGCNO.empty()) - errs() << " " << argv[0] << ": No gcov input file!\n"; + InputGCNO = SourceFile.substr(0, SourceFile.rfind(".")) + ".gcno"; + if (InputGCDA.empty()) + InputGCDA = SourceFile.substr(0, SourceFile.rfind(".")) + ".gcda"; + + GCOVFile GF; OwningPtr<MemoryBuffer> GCNO_Buff; if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCNO, GCNO_Buff)) { @@ -71,17 +77,15 @@ int main(int argc, char **argv) { return 1; } - if (!InputGCDA.empty()) { - OwningPtr<MemoryBuffer> GCDA_Buff; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCDA, GCDA_Buff)) { - errs() << InputGCDA << ": " << ec.message() << "\n"; - return 1; - } - GCOVBuffer GCDA_GB(GCDA_Buff.get()); - if (!GF.readGCDA(GCDA_GB)) { - errs() << "Invalid .gcda File!\n"; - return 1; - } + OwningPtr<MemoryBuffer> GCDA_Buff; + if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCDA, GCDA_Buff)) { + errs() << InputGCDA << ": " << ec.message() << "\n"; + return 1; + } + GCOVBuffer GCDA_GB(GCDA_Buff.get()); + if (!GF.readGCDA(GCDA_GB)) { + errs() << "Invalid .gcda File!\n"; + return 1; } if (DumpGCOV) |