[Frontend] Use vfs for directory iteration while searching PCHs. NFCI

Use the vfs lookup instead of real filesytem and handle the case where
-include-pch is a directory and this dir is searched for a PCH.

llvm-svn: 289459
This commit is contained in:
Bruno Cardoso Lopes 2016-12-12 19:28:21 +00:00
parent 4b75b8726d
commit b4d56f1a4f
1 changed files with 4 additions and 3 deletions

View File

@ -288,14 +288,15 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
SmallString<128> DirNative; SmallString<128> DirNative;
llvm::sys::path::native(PCHDir->getName(), DirNative); llvm::sys::path::native(PCHDir->getName(), DirNative);
bool Found = false; bool Found = false;
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)) { Dir != DirEnd && !EC; Dir.increment(EC)) {
// Check whether this is an acceptable AST file. // Check whether this is an acceptable AST file.
if (ASTReader::isAcceptableASTFile( if (ASTReader::isAcceptableASTFile(
Dir->path(), FileMgr, CI.getPCHContainerReader(), Dir->getName(), FileMgr, CI.getPCHContainerReader(),
CI.getLangOpts(), CI.getTargetOpts(), CI.getPreprocessorOpts(), CI.getLangOpts(), CI.getTargetOpts(), CI.getPreprocessorOpts(),
SpecificModuleCachePath)) { SpecificModuleCachePath)) {
PPOpts.ImplicitPCHInclude = Dir->path(); PPOpts.ImplicitPCHInclude = Dir->getName();
Found = true; Found = true;
break; break;
} }