summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/FrontendAction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp26
1 files changed, 26 insertions, 0 deletions
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();
OpenPOWER on IntegriCloud