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/FrontendAction.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/FrontendAction.cpp')
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index dc4dd89371a..dfe3d85ba73 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -211,30 +211,13 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, return true; } - if (!CI.getHeaderSearchOpts().VFSOverlayFiles.empty()) { - IntrusiveRefCntPtr<vfs::OverlayFileSystem> - Overlay(new vfs::OverlayFileSystem(vfs::getRealFileSystem())); - // earlier vfs files are on the bottom - const std::vector<std::string> &Files = - CI.getHeaderSearchOpts().VFSOverlayFiles; - for (std::vector<std::string>::const_iterator I = Files.begin(), - E = Files.end(); - I != E; ++I) { - std::unique_ptr<llvm::MemoryBuffer> Buffer; - if (llvm::errc::success != llvm::MemoryBuffer::getFile(*I, Buffer)) { - CI.getDiagnostics().Report(diag::err_missing_vfs_overlay_file) << *I; - goto failure; - } - - IntrusiveRefCntPtr<vfs::FileSystem> FS = - vfs::getVFSFromYAML(Buffer.release(), /*DiagHandler*/ 0); - if (!FS.getPtr()) { - CI.getDiagnostics().Report(diag::err_invalid_vfs_overlay) << *I; - goto failure; - } - Overlay->pushOverlay(FS); - } - CI.setVirtualFileSystem(Overlay); + if (!CI.hasVirtualFileSystem()) { + if (IntrusiveRefCntPtr<vfs::FileSystem> VFS = + createVFSFromCompilerInvocation(CI.getInvocation(), + CI.getDiagnostics())) + CI.setVirtualFileSystem(VFS); + else + goto failure; } // Set up the file and source managers, if needed. |