summaryrefslogtreecommitdiff
path: root/tools/llvm-cov/llvm-cov.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-02-04 06:41:43 +0000
committerJustin Bogner <mail@justinbogner.com>2014-02-04 06:41:43 +0000
commite2d1c6c19d8f643edffca86e2944f1aba4c9feea (patch)
tree9c5c1eff41b846d7fa77ef8221d44f3b3beb7ba4 /tools/llvm-cov/llvm-cov.cpp
parent9433c770f7cd72882fa33edf3b53dd62a23abc21 (diff)
downloadllvm-e2d1c6c19d8f643edffca86e2944f1aba4c9feea.tar.gz
llvm-e2d1c6c19d8f643edffca86e2944f1aba4c9feea.tar.bz2
llvm-e2d1c6c19d8f643edffca86e2944f1aba4c9feea.tar.xz
llvm-cov: Implement the object-directory flag
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200741 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-cov/llvm-cov.cpp')
-rw-r--r--tools/llvm-cov/llvm-cov.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/llvm-cov/llvm-cov.cpp b/tools/llvm-cov/llvm-cov.cpp
index be8d1c9036..61bee43d82 100644
--- a/tools/llvm-cov/llvm-cov.cpp
+++ b/tools/llvm-cov/llvm-cov.cpp
@@ -12,10 +12,12 @@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/OwningPtr.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/GCOV.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryObject.h"
+#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/system_error.h"
@@ -41,6 +43,10 @@ static cl::opt<bool> FuncSummary("f", cl::init(false),
cl::desc("Show coverage for each function"));
static cl::alias FuncSummaryA("function-summaries", cl::aliasopt(FuncSummary));
+static cl::opt<std::string> ObjectDir("o", cl::value_desc("DIR"), cl::init(""),
+ cl::desc("Search for objects in DIR"));
+static cl::alias ObjectDirA("object-directory", cl::aliasopt(ObjectDir));
+
static cl::opt<bool> UncondBranch("u", cl::init(false),
cl::desc("Display unconditional branch info "
"(requires -b)"));
@@ -64,10 +70,15 @@ int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, "LLVM code coverage tool\n");
+ SmallString<128> CoverageFileStem(ObjectDir);
+ if (CoverageFileStem.empty())
+ CoverageFileStem = sys::path::parent_path(SourceFile);
+ sys::path::append(CoverageFileStem, sys::path::stem(SourceFile));
+
if (InputGCNO.empty())
- InputGCNO = SourceFile.substr(0, SourceFile.rfind(".")) + ".gcno";
+ InputGCNO = (CoverageFileStem.str() + ".gcno").str();
if (InputGCDA.empty())
- InputGCDA = SourceFile.substr(0, SourceFile.rfind(".")) + ".gcda";
+ InputGCDA = (CoverageFileStem.str() + ".gcda").str();
GCOVFile GF;