diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/VirtualFileSystem.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 26 |
3 files changed, 31 insertions, 1 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index 881e1663953..539cbb74097 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -761,7 +761,7 @@ error_code VFSFromYAML::openFileForRead(const Twine &Path, if (!F) // FIXME: errc::not_a_file? return error_code(errc::invalid_argument, system_category()); - return ExternalFS->openFileForRead(Path, Result); + return ExternalFS->openFileForRead(F->getExternalContentsPath(), Result); } IntrusiveRefCntPtr<FileSystem> diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 4ef5cfef7c0..ad2d37cc297 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1020,6 +1020,10 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) { I != E; ++I) Opts.AddSystemHeaderPrefix((*I)->getValue(), (*I)->getOption().matches(OPT_isystem_prefix)); + + for (arg_iterator I = Args.filtered_begin(OPT_ivfsoverlay), + E = Args.filtered_end(); I != E; ++I) + Opts.AddVFSOverlayFile((*I)->getValue()); } void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 72377d84572..6cfa12168db 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -211,6 +211,32 @@ 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) { + OwningPtr<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.take(), /*DiagHandler*/0); + if (!FS.getPtr()) { + CI.getDiagnostics().Report(diag::err_invalid_vfs_overlay) << *I; + goto failure; + } + Overlay->pushOverlay(FS); + } + CI.setVirtualFileSystem(Overlay); + } + // Set up the file and source managers, if needed. if (!CI.hasFileManager()) CI.createFileManager(); |