Don't crash sancov if file is unreadable.

Summary:
Caller can provides the list of .so files where some files are
unreadable (e.g linux-vdso.so.1). It's more convenient to handler this in
sancov with warning then making all callers to check files.

Reviewers: aizatsky

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D18103

llvm-svn: 263307
This commit is contained in:
Mike Aizatsky 2016-03-11 23:26:41 +00:00
parent 5c605d7943
commit 22973fd00e
1 changed files with 10 additions and 6 deletions

View File

@ -98,10 +98,9 @@ static cl::opt<bool> ClUseDefaultBlacklist(
"use_default_blacklist", cl::init(true), cl::Hidden,
cl::desc("Controls if default blacklist should be used."));
static const char *const DefaultBlacklistStr =
"fun:__sanitizer_.*\n"
"src:/usr/include/.*\n"
"src:.*/libc\\+\\+/.*\n";
static const char *const DefaultBlacklistStr = "fun:__sanitizer_.*\n"
"src:/usr/include/.*\n"
"src:.*/libc\\+\\+/.*\n";
// --------- FORMAT SPECIFICATION ---------
@ -491,8 +490,12 @@ static std::string escapeHtml(const std::string &S) {
static ErrorOr<bool> isCoverageFile(std::string FileName) {
ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr =
MemoryBuffer::getFile(FileName);
if (!BufOrErr)
if (!BufOrErr) {
errs() << "Warning: " << BufOrErr.getError().message() << "("
<< BufOrErr.getError().value()
<< "), filename: " << llvm::sys::path::filename(FileName) << "\n";
return BufOrErr.getError();
}
std::unique_ptr<MemoryBuffer> Buf = std::move(BufOrErr.get());
if (Buf->getBufferSize() < 8) {
return false;
@ -940,7 +943,8 @@ public:
// Partition input values into coverage/object files.
for (const auto &FileName : FileNames) {
auto ErrorOrIsCoverage = isCoverageFile(FileName);
FailIfError(ErrorOrIsCoverage);
if (!ErrorOrIsCoverage)
continue;
if (ErrorOrIsCoverage.get()) {
CovFiles.insert(FileName);
} else {