diff options
| author | Ben Langmuir <blangmuir@apple.com> | 2014-04-15 18:16:25 +0000 |
|---|---|---|
| committer | Ben Langmuir <blangmuir@apple.com> | 2014-04-15 18:16:25 +0000 |
| commit | 8832c066a23eb7df33b025bcf7e8fe7199ad3aae (patch) | |
| tree | 923753afcf173f06cba5d014e2e8e1b51dda2b5d /clang/lib/Frontend/ASTUnit.cpp | |
| parent | be4fe32eb8ad20e47fecf7e85e57c7e522ec5143 (diff) | |
| download | bcm5719-llvm-8832c066a23eb7df33b025bcf7e8fe7199ad3aae.tar.gz bcm5719-llvm-8832c066a23eb7df33b025bcf7e8fe7199ad3aae.zip | |
Honour -ivfsoverlay in ASTUnit to match clang
This allows code indexing, etc. to use the VFS in the same way as the
compiler.
llvm-svn: 206309
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
| -rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index c4f7596e003..5035dac53cf 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -692,7 +692,8 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, AST->OnlyLocalDecls = OnlyLocalDecls; AST->CaptureDiagnostics = CaptureDiagnostics; AST->Diagnostics = Diags; - AST->FileMgr = new FileManager(FileSystemOpts); + IntrusiveRefCntPtr<vfs::FileSystem> VFS = vfs::getRealFileSystem(); + AST->FileMgr = new FileManager(FileSystemOpts, VFS); AST->UserFilesAreVolatile = UserFilesAreVolatile; AST->SourceMgr = new SourceManager(AST->getDiagnostics(), AST->getFileManager(), @@ -1093,10 +1094,9 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) { "IR inputs not support here!"); // Configure the various subsystems. - // FIXME: Should we retain the previous file manager? LangOpts = &Clang->getLangOpts(); FileSystemOpts = Clang->getFileSystemOpts(); - FileMgr = new FileManager(FileSystemOpts); + // Re-use the existing FileManager SourceMgr = new SourceManager(getDiagnostics(), *FileMgr, UserFilesAreVolatile); TheSema.reset(); @@ -1598,9 +1598,14 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( TopLevelDecls.clear(); TopLevelDeclsInPreamble.clear(); PreambleDiagnostics.clear(); - + + IntrusiveRefCntPtr<vfs::FileSystem> VFS = + createVFSFromCompilerInvocation(Clang->getInvocation(), getDiagnostics()); + if (!VFS) + return nullptr; + // Create a file manager object to provide access to and cache the filesystem. - Clang->setFileManager(new FileManager(Clang->getFileSystemOpts())); + Clang->setFileManager(new FileManager(Clang->getFileSystemOpts(), VFS)); // Create the source manager. Clang->setSourceManager(new SourceManager(getDiagnostics(), @@ -1758,7 +1763,11 @@ ASTUnit *ASTUnit::create(CompilerInvocation *CI, AST->Diagnostics = Diags; AST->Invocation = CI; AST->FileSystemOpts = CI->getFileSystemOpts(); - AST->FileMgr = new FileManager(AST->FileSystemOpts); + IntrusiveRefCntPtr<vfs::FileSystem> VFS = + createVFSFromCompilerInvocation(*CI, *Diags); + if (!VFS) + return nullptr; + AST->FileMgr = new FileManager(AST->FileSystemOpts, VFS); AST->UserFilesAreVolatile = UserFilesAreVolatile; AST->SourceMgr = new SourceManager(AST->getDiagnostics(), *AST->FileMgr, UserFilesAreVolatile); @@ -1781,6 +1790,8 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction( // Create the AST unit. OwnAST.reset(create(CI, Diags, CaptureDiagnostics, UserFilesAreVolatile)); AST = OwnAST.get(); + if (!AST) + return nullptr; } if (!ResourceFilesPath.empty()) { @@ -1950,7 +1961,11 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocation(CompilerInvocation *CI, = IncludeBriefCommentsInCodeCompletion; AST->Invocation = CI; AST->FileSystemOpts = CI->getFileSystemOpts(); - AST->FileMgr = new FileManager(AST->FileSystemOpts); + IntrusiveRefCntPtr<vfs::FileSystem> VFS = + createVFSFromCompilerInvocation(*CI, *Diags); + if (!VFS) + return nullptr; + AST->FileMgr = new FileManager(AST->FileSystemOpts, VFS); AST->UserFilesAreVolatile = UserFilesAreVolatile; // Recover resources if we crash before exiting this method. @@ -2017,7 +2032,11 @@ ASTUnit *ASTUnit::LoadFromCommandLine( AST->Diagnostics = Diags; Diags = 0; // Zero out now to ease cleanup during crash recovery. AST->FileSystemOpts = CI->getFileSystemOpts(); - AST->FileMgr = new FileManager(AST->FileSystemOpts); + IntrusiveRefCntPtr<vfs::FileSystem> VFS = + createVFSFromCompilerInvocation(*CI, *Diags); + if (!VFS) + return nullptr; + AST->FileMgr = new FileManager(AST->FileSystemOpts, VFS); AST->OnlyLocalDecls = OnlyLocalDecls; AST->CaptureDiagnostics = CaptureDiagnostics; AST->TUKind = TUKind; |

