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,8 @@ -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 +CHECK: nonexistent.profdata: Could not read profile data + +RUN: not llvm-cov export -instr-profile=%t.nonexistent.profdata %t.nonexistent 2>&1 | FileCheck %s +CHECK: nonexistent.profdata: Could not read profile data + +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 @@ -26,6 +26,7 @@ #include "llvm/ProfileData/Coverage/CoverageMapping.h" #include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Error.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" #include "llvm/Support/MemoryBuffer.h" @@ -1053,7 +1054,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 +1171,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 +1226,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");