[PATCH] D44960: Prevent llvm-cov from hanging when a symblink doesn't exist.
Yuke Liao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 27 15:25:59 PDT 2018
liaoyuke created this revision.
liaoyuke added reviewers: Dor1s, vsk.
Previous code hangs indefinitely when trying to iterate through a
symbol link file that points to an non-exist directory. This change
fixes the bug to make the addCollectedPath function exit ealier and
print out correct warning messages.
Repository:
rL LLVM
https://reviews.llvm.org/D44960
Files:
include/llvm/Support/FileSystem.h
tools/llvm-cov/CodeCoverage.cpp
Index: tools/llvm-cov/CodeCoverage.cpp
===================================================================
--- tools/llvm-cov/CodeCoverage.cpp
+++ tools/llvm-cov/CodeCoverage.cpp
@@ -199,7 +199,7 @@
if (PathRemapping)
addCollectedPath(Path);
else
- error("Missing source file", Path);
+ warning("source file doesn't exit, proceeded by ignoring it.", Path);
return;
}
@@ -210,13 +210,17 @@
if (llvm::sys::fs::is_directory(Status)) {
std::error_code EC;
+ std::string path_before_error_occurs;
for (llvm::sys::fs::recursive_directory_iterator F(Path, EC), E;
F != E && !EC; F.increment(EC)) {
+ path_before_error_occurs = F->path();
if (llvm::sys::fs::is_regular_file(F->path()))
addCollectedPath(F->path());
}
- if (EC)
- warning(EC.message(), Path);
+ if (EC) {
+ warning(EC.message(), path_before_error_occurs);
+ warning("code coverage results may be incomplete.");
+ }
}
}
Index: include/llvm/Support/FileSystem.h
===================================================================
--- include/llvm/Support/FileSystem.h
+++ include/llvm/Support/FileSystem.h
@@ -1031,8 +1031,10 @@
State->HasNoPushRequest = false;
else {
ErrorOr<basic_file_status> st = State->Stack.top()->status();
- if (!st) return *this;
- if (is_directory(*st)) {
+ if (!st) {
+ ec = st.getError();
+ return *this;
+ } else if (is_directory(*st)) {
State->Stack.push(directory_iterator(*State->Stack.top(), ec, Follow));
if (ec) return *this;
if (State->Stack.top() != end_itr) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44960.140011.patch
Type: text/x-patch
Size: 1655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180327/a3a74356/attachment.bin>
More information about the llvm-commits
mailing list