summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2016-07-15 01:53:39 +0000
committerVedant Kumar <vsk@apple.com>2016-07-15 01:53:39 +0000
commitb95dc4608d70887a5efc1db5301539b3b38fe8cc (patch)
tree77804acee003279917ab500d00fb0012c4809f6f /llvm
parentfa0f2a0dcff94b1c746937e805b9e78a6efeb6ef (diff)
downloadbcm5719-llvm-b95dc4608d70887a5efc1db5301539b3b38fe8cc.tar.gz
bcm5719-llvm-b95dc4608d70887a5efc1db5301539b3b38fe8cc.zip
[llvm-cov] Improve error messages
While we're at it, extend an existing test to make sure that error messages look reasonable. llvm-svn: 275520
Diffstat (limited to 'llvm')
-rw-r--r--llvm/test/tools/llvm-cov/double_dots.c5
-rw-r--r--llvm/tools/llvm-cov/CodeCoverage.cpp8
2 files changed, 9 insertions, 4 deletions
diff --git a/llvm/test/tools/llvm-cov/double_dots.c b/llvm/test/tools/llvm-cov/double_dots.c
index 47224bf9ade..adfd9f7f353 100644
--- a/llvm/test/tools/llvm-cov/double_dots.c
+++ b/llvm/test/tools/llvm-cov/double_dots.c
@@ -15,3 +15,8 @@ int main() {}
// RUN: FileCheck -check-prefix=REL-INDEX -input-file %t.dir/index.txt %s
// REL-INDEX-NOT: %t.dir
+
+// Check that we get the right error when writing to an invalid path:
+
+// RUN: not llvm-cov show %S/Inputs/double_dots.covmapping -instr-profile=%t.profdata -o /dev/null 2>&1 | FileCheck %s -check-prefix=ERROR-MESSAGE
+// ERROR-MESSAGE: error: Not a directory: Could not create index file!
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index 621f8d7825a..ed48c28c0fc 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -117,7 +117,7 @@ static std::string getErrorString(const Twine &Message, StringRef Whence,
std::string Str = (Warning ? "warning" : "error");
Str += ": ";
if (!Whence.empty())
- Str += Whence;
+ Str += Whence.str() + ": ";
Str += Message.str() + "\n";
return Str;
}
@@ -504,7 +504,7 @@ int CodeCoverageTool::show(int argc, const char **argv,
if (!Filters.empty()) {
auto OSOrErr = Printer->createViewFile("functions", /*InToplevel=*/true);
if (Error E = OSOrErr.takeError()) {
- error(toString(std::move(E)));
+ error("Could not create view file!", toString(std::move(E)));
return 1;
}
auto OS = std::move(OSOrErr.get());
@@ -540,7 +540,7 @@ int CodeCoverageTool::show(int argc, const char **argv,
// Create an index out of the source files.
if (ViewOpts.hasOutputDirectory()) {
if (Error E = Printer->createIndexFile(SourceFiles)) {
- error(toString(std::move(E)));
+ error("Could not create index file!", toString(std::move(E)));
return 1;
}
}
@@ -561,7 +561,7 @@ int CodeCoverageTool::show(int argc, const char **argv,
auto OSOrErr = Printer->createViewFile(SourceFile, /*InToplevel=*/false);
if (Error E = OSOrErr.takeError()) {
- deferError(toString(std::move(E)));
+ deferError("Could not create view file!", toString(std::move(E)));
return;
}
auto OS = std::move(OSOrErr.get());
OpenPOWER on IntegriCloud