Recommit virtual file system
Previously reverted in r201755 due to causing an assertion failure.
I've removed the offending assertion, and taught the CompilerInstance to
create a default virtual file system inside createFileManager. In the
future, we should be able to reach into the CompilerInvocation to
customize this behaviour without breaking clients that don't care.
llvm-svn: 201818
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 61fe26c..df00952 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -79,6 +79,10 @@
void CompilerInstance::setFileManager(FileManager *Value) {
FileMgr = Value;
+ if (Value)
+ VirtualFileSystem = Value->getVirtualFileSystem();
+ else
+ VirtualFileSystem.reset();
}
void CompilerInstance::setSourceManager(SourceManager *Value) {
@@ -197,7 +201,11 @@
// File Manager
void CompilerInstance::createFileManager() {
- FileMgr = new FileManager(getFileSystemOpts());
+ if (!hasVirtualFileSystem()) {
+ // TODO: choose the virtual file system based on the CompilerInvocation.
+ setVirtualFileSystem(vfs::getRealFileSystem());
+ }
+ FileMgr = new FileManager(getFileSystemOpts(), VirtualFileSystem);
}
// Source Manager
@@ -867,6 +875,8 @@
ImportingInstance.getDiagnosticClient()),
/*ShouldOwnClient=*/true);
+ Instance.setVirtualFileSystem(&ImportingInstance.getVirtualFileSystem());
+
// Note that this module is part of the module build stack, so that we
// can detect cycles in the module graph.
Instance.createFileManager(); // FIXME: Adopt file manager from importer?