diff options
author | Max Moroz <mmoroz@chromium.org> | 2018-04-04 19:47:25 +0000 |
---|---|---|
committer | Max Moroz <mmoroz@chromium.org> | 2018-04-04 19:47:25 +0000 |
commit | e097567006e234209ef2d821f3a58158358fd370 (patch) | |
tree | f4df4377097df7e6c344f509800a5f68984fc52f /clang/lib/Basic/VirtualFileSystem.cpp | |
parent | e6cf0a3d9f056074247e8f75fda041684f896557 (diff) | |
download | llvm-e097567006e234209ef2d821f3a58158358fd370.zip llvm-e097567006e234209ef2d821f3a58158358fd370.tar.gz llvm-e097567006e234209ef2d821f3a58158358fd370.tar.bz2 |
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
Diffstat (limited to 'clang/lib/Basic/VirtualFileSystem.cpp')
-rw-r--r-- | clang/lib/Basic/VirtualFileSystem.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index a854576..413d439 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -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; } |