diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Basic/VirtualFileSystem.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Basic/VirtualFileSystem.cpp | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/contrib/llvm/tools/clang/lib/Basic/VirtualFileSystem.cpp b/contrib/llvm/tools/clang/lib/Basic/VirtualFileSystem.cpp index 50fcb22..f5db717 100644 --- a/contrib/llvm/tools/clang/lib/Basic/VirtualFileSystem.cpp +++ b/contrib/llvm/tools/clang/lib/Basic/VirtualFileSystem.cpp @@ -27,13 +27,6 @@ #include <memory> #include <utility> -// For chdir. -#ifdef LLVM_ON_WIN32 -# include <direct.h> -#else -# include <unistd.h> -#endif - using namespace clang; using namespace clang::vfs; using namespace llvm; @@ -235,11 +228,7 @@ std::error_code RealFileSystem::setCurrentWorkingDirectory(const Twine &Path) { // difference for example on network filesystems, where symlinks might be // switched during runtime of the tool. Fixing this depends on having a // file system abstraction that allows openat() style interactions. - SmallString<256> Storage; - StringRef Dir = Path.toNullTerminatedStringRef(Storage); - if (int Err = ::chdir(Dir.data())) - return std::error_code(Err, std::generic_category()); - return std::error_code(); + return llvm::sys::fs::set_current_path(Path); } IntrusiveRefCntPtr<FileSystem> vfs::getRealFileSystem() { @@ -249,16 +238,13 @@ IntrusiveRefCntPtr<FileSystem> vfs::getRealFileSystem() { namespace { class RealFSDirIter : public clang::vfs::detail::DirIterImpl { - std::string Path; llvm::sys::fs::directory_iterator Iter; public: - RealFSDirIter(const Twine &_Path, std::error_code &EC) - : Path(_Path.str()), Iter(Path, EC) { + RealFSDirIter(const Twine &Path, std::error_code &EC) : Iter(Path, EC) { if (!EC && Iter != llvm::sys::fs::directory_iterator()) { llvm::sys::fs::file_status S; EC = Iter->status(S); - if (!EC) - CurrentEntry = Status::copyWithNewName(S, Iter->path()); + CurrentEntry = Status::copyWithNewName(S, Iter->path()); } } @@ -1869,7 +1855,7 @@ vfs::recursive_directory_iterator::recursive_directory_iterator(FileSystem &FS_, std::error_code &EC) : FS(&FS_) { directory_iterator I = FS->dir_begin(Path, EC); - if (!EC && I != directory_iterator()) { + if (I != directory_iterator()) { State = std::make_shared<IterState>(); State->push(I); } @@ -1882,8 +1868,6 @@ recursive_directory_iterator::increment(std::error_code &EC) { vfs::directory_iterator End; if (State->top()->isDirectory()) { vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); - if (EC) - return *this; if (I != End) { State->push(I); return *this; |