From b171a59bfd152346ca068c73ccb61fe28643d024 Mon Sep 17 00:00:00 2001 From: Bruno Cardoso Lopes Date: Mon, 16 May 2016 16:46:01 +0000 Subject: [Modules] Use vfs for (recursive) directory iteration Clang performs directory walk while searching headers inside modules by using the ::sys::fs instead of ::vfs. This prevents any code that uses the VFS (e.g, reproducer scripts) to actually find such headers, since the VFS will never be searched for those. Change these places to use vfs::recursive_directory_iterator and vfs::directory_iterator instead. Differential Revision: http://reviews.llvm.org/D20266 rdar://problem/25880368 llvm-svn: 269661 --- clang/lib/Lex/ModuleMap.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'clang/lib/Lex/ModuleMap.cpp') diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index be3b1d9..5147718 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -711,13 +711,15 @@ Module *ModuleMap::inferFrameworkModule(const DirectoryEntry *FrameworkDir, = StringRef(FrameworkDir->getName()); llvm::sys::path::append(SubframeworksDirName, "Frameworks"); llvm::sys::path::native(SubframeworksDirName); - for (llvm::sys::fs::directory_iterator Dir(SubframeworksDirName, EC), DirEnd; + vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem(); + for (vfs::directory_iterator Dir = FS.dir_begin(SubframeworksDirName, EC), + DirEnd; Dir != DirEnd && !EC; Dir.increment(EC)) { - if (!StringRef(Dir->path()).endswith(".framework")) + if (!StringRef(Dir->getName()).endswith(".framework")) continue; - if (const DirectoryEntry *SubframeworkDir - = FileMgr.getDirectory(Dir->path())) { + if (const DirectoryEntry *SubframeworkDir = + FileMgr.getDirectory(Dir->getName())) { // Note: as an egregious but useful hack, we use the real path here and // check whether it is actually a subdirectory of the parent directory. // This will not be the case if the 'subframework' is actually a symlink @@ -1931,11 +1933,13 @@ void ModuleMapParser::parseUmbrellaDirDecl(SourceLocation UmbrellaLoc) { // uncommonly used Tcl module on Darwin platforms. std::error_code EC; SmallVector Headers; - for (llvm::sys::fs::recursive_directory_iterator I(Dir->getName(), EC), E; + vfs::FileSystem &FS = *SourceMgr.getFileManager().getVirtualFileSystem(); + for (vfs::recursive_directory_iterator I(FS, Dir->getName(), EC), E; I != E && !EC; I.increment(EC)) { - if (const FileEntry *FE = SourceMgr.getFileManager().getFile(I->path())) { + if (const FileEntry *FE = + SourceMgr.getFileManager().getFile(I->getName())) { - Module::Header Header = {I->path(), FE}; + Module::Header Header = {I->getName(), FE}; Headers.push_back(std::move(Header)); } } -- cgit v1.1