From 8832c066a23eb7df33b025bcf7e8fe7199ad3aae Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Tue, 15 Apr 2014 18:16:25 +0000 Subject: 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 --- clang/lib/Frontend/FrontendAction.cpp | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'clang/lib/Frontend/FrontendAction.cpp') 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 - Overlay(new vfs::OverlayFileSystem(vfs::getRealFileSystem())); - // earlier vfs files are on the bottom - const std::vector &Files = - CI.getHeaderSearchOpts().VFSOverlayFiles; - for (std::vector::const_iterator I = Files.begin(), - E = Files.end(); - I != E; ++I) { - std::unique_ptr Buffer; - if (llvm::errc::success != llvm::MemoryBuffer::getFile(*I, Buffer)) { - CI.getDiagnostics().Report(diag::err_missing_vfs_overlay_file) << *I; - goto failure; - } - - IntrusiveRefCntPtr 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 = + createVFSFromCompilerInvocation(CI.getInvocation(), + CI.getDiagnostics())) + CI.setVirtualFileSystem(VFS); + else + goto failure; } // Set up the file and source managers, if needed. -- cgit v1.2.3