diff --git a/llvm/test/tools/llvm-cov/misssing-profdata.test b/llvm/test/tools/llvm-cov/misssing-profdata.test --- a/llvm/test/tools/llvm-cov/misssing-profdata.test +++ b/llvm/test/tools/llvm-cov/misssing-profdata.test @@ -1,2 +1,5 @@ -RUN: not llvm-cov show -instr-profile=%t.nonexistent %t.nonexistent 2>&1 | FileCheck %s -CHECK: Could not read profile data +RUN: not llvm-cov show -instr-profile=%t.nonexistent.profdata %t.nonexistent 2>&1 | FileCheck %s +RUN: not llvm-cov export -instr-profile=%t.nonexistent.profdata %t.nonexistent 2>&1 | FileCheck %s +RUN: not llvm-cov report -instr-profile=%t.nonexistent.profdata %t.nonexistent 2>&1 | FileCheck %s + +CHECK: nonexistent.profdata: Could not read profile data! diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -1053,7 +1053,7 @@ sys::fs::file_status Status; if (std::error_code EC = sys::fs::status(PGOFilename, Status)) { - error("Could not read profile data!", EC.message()); + error("Could not read profile data!" + EC.message(), PGOFilename); return 1; } @@ -1170,6 +1170,12 @@ return 1; } + sys::fs::file_status Status; + if (std::error_code EC = sys::fs::status(PGOFilename, Status)) { + error("Could not read profile data!" + EC.message(), PGOFilename); + return 1; + } + auto Coverage = load(); if (!Coverage) return 1; @@ -1219,6 +1225,12 @@ return 1; } + sys::fs::file_status Status; + if (std::error_code EC = sys::fs::status(PGOFilename, Status)) { + error("Could not read profile data!" + EC.message(), PGOFilename); + return 1; + } + auto Coverage = load(); if (!Coverage) { error("Could not load coverage information");