[llvm-cov] Improve error message for missing profdata
authorEli Friedman <efriedma@quicinc.com>
Wed, 25 Mar 2020 19:28:47 +0000 (12:28 -0700)
committerEli Friedman <efriedma@quicinc.com>
Mon, 30 Mar 2020 19:54:07 +0000 (12:54 -0700)
I got a report recently that a user was having trouble interpreting the
meaning of the error message.  Hopefully this is more readable; produces
something like the following:

error: No such file or directory: Could not read profile data!

Differential Revision: https://reviews.llvm.org/D76796

llvm/test/tools/llvm-cov/misssing-profdata.test [new file with mode: 0644]
llvm/tools/llvm-cov/CodeCoverage.cpp

diff --git a/llvm/test/tools/llvm-cov/misssing-profdata.test b/llvm/test/tools/llvm-cov/misssing-profdata.test
new file mode 100644 (file)
index 0000000..44faeac
--- /dev/null
@@ -0,0 +1,2 @@
+RUN: not llvm-cov show -instr-profile=%t.nonexistent %t.nonexistent 2>&1 | FileCheck %s
+CHECK: Could not read profile data
index 625e234..b2024e9 100644 (file)
@@ -867,8 +867,8 @@ int CodeCoverageTool::doShow(int argc, const char **argv,
   }
 
   sys::fs::file_status Status;
-  if (sys::fs::status(PGOFilename, Status)) {
-    error("profdata file error: can not get the file status. \n");
+  if (std::error_code EC = sys::fs::status(PGOFilename, Status)) {
+    error("Could not read profile data!", EC.message());
     return 1;
   }