summaryrefslogtreecommitdiff
path: root/tools/llvm-cov/llvm-cov.cpp
diff options
context:
space:
mode:
authorYuchen Wu <yuchenericwu@hotmail.com>2013-11-05 01:20:41 +0000
committerYuchen Wu <yuchenericwu@hotmail.com>2013-11-05 01:20:41 +0000
commitd8acf0078cf363252727acff00f85ae8074f95b3 (patch)
treec5d934ebade933a197f6e70eefacfe2e6035efac /tools/llvm-cov/llvm-cov.cpp
parente85959cb2cb6f82959b3cf1a9ef59c6d793a2556 (diff)
downloadllvm-d8acf0078cf363252727acff00f85ae8074f95b3.tar.gz
llvm-d8acf0078cf363252727acff00f85ae8074f95b3.tar.bz2
llvm-d8acf0078cf363252727acff00f85ae8074f95b3.tar.xz
llvm-cov: Added command-line option to change dir.
This will allow for much easier testing when the input files are in a different folder from the test script. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194034 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-cov/llvm-cov.cpp')
-rw-r--r--tools/llvm-cov/llvm-cov.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/llvm-cov/llvm-cov.cpp b/tools/llvm-cov/llvm-cov.cpp
index ad6c671815..18277737b6 100644
--- a/tools/llvm-cov/llvm-cov.cpp
+++ b/tools/llvm-cov/llvm-cov.cpp
@@ -20,6 +20,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/system_error.h"
+#include <unistd.h>
using namespace llvm;
static cl::opt<bool>
@@ -34,6 +35,9 @@ InputGCDA("gcda", cl::desc("<input gcda file>"), cl::init(""));
static cl::opt<std::string>
OutputFile("o", cl::desc("<output llvm-cov file>"), cl::init("-"));
+static cl::opt<std::string>
+WorkingDir("C", cl::desc("change path of working directory"),
+ cl::init(""));
//===----------------------------------------------------------------------===//
int main(int argc, char **argv) {
@@ -44,6 +48,13 @@ int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, "llvm coverage tool\n");
+ if (!WorkingDir.empty()) {
+ if (chdir(WorkingDir.c_str()) == -1) {
+ errs() << "Cannot change to directory: " << WorkingDir << ".\n";
+ return 1;
+ }
+ }
+
std::string ErrorInfo;
raw_fd_ostream OS(OutputFile.c_str(), ErrorInfo);
if (!ErrorInfo.empty())
@@ -77,7 +88,6 @@ int main(int argc, char **argv) {
}
}
-
if (DumpGCOV)
GF.dump();