summaryrefslogtreecommitdiff
path: root/lib/Frontend/FrontendAction.cpp
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2014-02-25 18:23:47 +0000
committerBen Langmuir <blangmuir@apple.com>2014-02-25 18:23:47 +0000
commit89de580b52889e160a604bd735fc4e79147661cb (patch)
tree44fc8ba3a2075de87bb6d5a2e542543e8732820b /lib/Frontend/FrontendAction.cpp
parentee8d6b96cec22857c609a0ff439e237a6c4fccc5 (diff)
downloadclang-89de580b52889e160a604bd735fc4e79147661cb.tar.gz
Add a driver option -ivfsoverlay
Reads the description of a virtual filesystem from a file and overlays it over the real file system. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202176 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/FrontendAction.cpp')
-rw-r--r--lib/Frontend/FrontendAction.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp
index 72377d8457..6cfa12168d 100644
--- a/lib/Frontend/FrontendAction.cpp
+++ b/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();