summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cov/llvm-cov.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-01-29 21:31:34 +0000
committerJustin Bogner <mail@justinbogner.com>2014-01-29 21:31:34 +0000
commita99a3902a5c170a3ee184bd9e6efddd9dc604c9f (patch)
tree229fba3da7aef71e23c1b1d7c91321ccadc99039 /llvm/tools/llvm-cov/llvm-cov.cpp
parent0d35ed912ad74b7afb0510777240045a10a46c7f (diff)
downloadbcm5719-llvm-a99a3902a5c170a3ee184bd9e6efddd9dc604c9f.tar.gz
bcm5719-llvm-a99a3902a5c170a3ee184bd9e6efddd9dc604c9f.zip
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. llvm-svn: 200417
Diffstat (limited to 'llvm/tools/llvm-cov/llvm-cov.cpp')
-rw-r--r--llvm/tools/llvm-cov/llvm-cov.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/llvm/tools/llvm-cov/llvm-cov.cpp b/llvm/tools/llvm-cov/llvm-cov.cpp
index 31f6ad0058e..177c99d8968 100644
--- a/llvm/tools/llvm-cov/llvm-cov.cpp
+++ b/llvm/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)
OpenPOWER on IntegriCloud