From e2d1c6c19d8f643edffca86e2944f1aba4c9feea Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Tue, 4 Feb 2014 06:41:43 +0000 Subject: llvm-cov: Implement the object-directory flag git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200741 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-cov/llvm-cov.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'tools/llvm-cov') 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 FuncSummary("f", cl::init(false), cl::desc("Show coverage for each function")); static cl::alias FuncSummaryA("function-summaries", cl::aliasopt(FuncSummary)); +static cl::opt 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 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; -- cgit v1.2.3