[llvm] 9eb1b41 - [llvm-cov] Improve error message for missing profdata

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 30 12:54:29 PDT 2020


Author: Eli Friedman
Date: 2020-03-30T12:54:07-07:00
New Revision: 9eb1b41811c76eec35c5feafb2fdc781f356bf48

URL: https://github.com/llvm/llvm-project/commit/9eb1b41811c76eec35c5feafb2fdc781f356bf48
DIFF: https://github.com/llvm/llvm-project/commit/9eb1b41811c76eec35c5feafb2fdc781f356bf48.diff

LOG: [llvm-cov] Improve error message for missing profdata

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

Added: 
    llvm/test/tools/llvm-cov/misssing-profdata.test

Modified: 
    llvm/tools/llvm-cov/CodeCoverage.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-cov/misssing-profdata.test b/llvm/test/tools/llvm-cov/misssing-profdata.test
new file mode 100644
index 000000000000..44faeac74071
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/misssing-profdata.test
@@ -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

diff  --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index 625e2342e4bb..b2024e9ee331 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -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;
   }
 


        


More information about the llvm-commits mailing list