summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/HeaderSearch.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/HeaderSearch.cpp
parentf3c7a3523857a4b8d6aa50bcc14e4a379d6388c7 (diff)
downloadbcm5719-llvm-b171a59bfd152346ca068c73ccb61fe28643d024.tar.gz
bcm5719-llvm-b171a59bfd152346ca068c73ccb61fe28643d024.zip
[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/HeaderSearch.cpp')
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index e989e3dcdd4..3bb7f8e0428 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1341,19 +1341,20 @@ void HeaderSearch::collectAllModules(SmallVectorImpl<Module *> &Modules) {
DirNative);
// Search each of the ".framework" directories to load them as modules.
- for (llvm::sys::fs::directory_iterator Dir(DirNative, EC), DirEnd;
+ vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
+ for (vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
- if (llvm::sys::path::extension(Dir->path()) != ".framework")
+ if (llvm::sys::path::extension(Dir->getName()) != ".framework")
continue;
const DirectoryEntry *FrameworkDir =
- FileMgr.getDirectory(Dir->path());
+ FileMgr.getDirectory(Dir->getName());
if (!FrameworkDir)
continue;
// Load this framework module.
- loadFrameworkModule(llvm::sys::path::stem(Dir->path()), FrameworkDir,
- IsSystem);
+ loadFrameworkModule(llvm::sys::path::stem(Dir->getName()),
+ FrameworkDir, IsSystem);
}
continue;
}
@@ -1408,11 +1409,13 @@ void HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir) {
std::error_code EC;
SmallString<128> DirNative;
llvm::sys::path::native(SearchDir.getDir()->getName(), DirNative);
- for (llvm::sys::fs::directory_iterator Dir(DirNative, EC), DirEnd;
+ vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
+ for (vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
- bool IsFramework = llvm::sys::path::extension(Dir->path()) == ".framework";
+ bool IsFramework =
+ llvm::sys::path::extension(Dir->getName()) == ".framework";
if (IsFramework == SearchDir.isFramework())
- loadModuleMapFile(Dir->path(), SearchDir.isSystemHeaderDirectory(),
+ loadModuleMapFile(Dir->getName(), SearchDir.isSystemHeaderDirectory(),
SearchDir.isFramework());
}
OpenPOWER on IntegriCloud