Fixes errors with FS iterators caused by https://reviews.llvm.org/D44960

Summary:
In https://reviews.llvm.org/D44960, file status check is executed every
time a real file system directory iterator is constructed or
incremented, and emits an error code. This change list fixes the errors
in VirtualFileSystem caused by https://reviews.llvm.org/D44960.

Patch by Yuke Liao (@liaoyuke).

Reviewers: vsk, pcc, zturner, liaoyuke

Reviewed By: vsk

Subscribers: mgrang, cfe-commits

Differential Revision: https://reviews.llvm.org/D45178

llvm-svn: 329223
This commit is contained in:
Max Moroz
2018-04-04 19:47:25 +00:00
parent e6cf0a3d9f
commit e097567006
2 changed files with 25 additions and 15 deletions

View File

@@ -286,24 +286,26 @@ class RealFSDirIter : public clang::vfs::detail::DirIterImpl {
public:
RealFSDirIter(const Twine &Path, std::error_code &EC) : Iter(Path, EC) {
if (!EC && Iter != llvm::sys::fs::directory_iterator()) {
if (Iter != llvm::sys::fs::directory_iterator()) {
llvm::sys::fs::file_status S;
EC = llvm::sys::fs::status(Iter->path(), S, true);
std::error_code ErrorCode = llvm::sys::fs::status(Iter->path(), S, true);
CurrentEntry = Status::copyWithNewName(S, Iter->path());
if (!EC)
EC = ErrorCode;
}
}
std::error_code increment() override {
std::error_code EC;
Iter.increment(EC);
if (EC) {
return EC;
} else if (Iter == llvm::sys::fs::directory_iterator()) {
if (Iter == llvm::sys::fs::directory_iterator()) {
CurrentEntry = Status();
} else {
llvm::sys::fs::file_status S;
EC = llvm::sys::fs::status(Iter->path(), S, true);
std::error_code ErrorCode = llvm::sys::fs::status(Iter->path(), S, true);
CurrentEntry = Status::copyWithNewName(S, Iter->path());
if (!EC)
EC = ErrorCode;
}
return EC;
}