aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/ModuleMap.cpp
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2016-05-16 16:46:01 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2016-05-16 16:46:01 +0000
commitb171a59bfd152346ca068c73ccb61fe28643d024 (patch)
treefed5cea8a881988c786113364d0e70e4b86f6e99 /clang/lib/Lex/ModuleMap.cpp
parentf3c7a3523857a4b8d6aa50bcc14e4a379d6388c7 (diff)
downloadllvm-b171a59bfd152346ca068c73ccb61fe28643d024.zip
llvm-b171a59bfd152346ca068c73ccb61fe28643d024.tar.gz
llvm-b171a59bfd152346ca068c73ccb61fe28643d024.tar.bz2
[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
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r--clang/lib/Lex/ModuleMap.cpp18
1 files changed, 11 insertions, 7 deletions
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<Module::Header, 6> 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));
}
}