]> granicus.if.org Git - llvm/commitdiff
[llvm-cov] Improve error messages
authorVedant Kumar <vsk@apple.com>
Fri, 15 Jul 2016 01:53:39 +0000 (01:53 +0000)
committerVedant Kumar <vsk@apple.com>
Fri, 15 Jul 2016 01:53:39 +0000 (01:53 +0000)
While we're at it, extend an existing test to make sure that error
messages look reasonable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275520 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-cov/double_dots.c
tools/llvm-cov/CodeCoverage.cpp

index 47224bf9ade925c88064e3af5fa6f9c7e2b449fa..adfd9f7f35305090bd6e40676ac384fc8a35f08f 100644 (file)
@@ -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!
index 621f8d7825a9c647aaea0a8d32fdb5c0750b48b6..ed48c28c0fc7faf0e463b32d52f267f591f16387 100644 (file)
@@ -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());