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
This commit is contained in:
Ben Langmuir
2014-02-20 21:59:23 +00:00
parent 37eb422f69
commit c8130a74f4
17 changed files with 711 additions and 109 deletions

View File

@@ -79,6 +79,10 @@ void CompilerInstance::setTarget(TargetInfo *Value) {
void CompilerInstance::setFileManager(FileManager *Value) {
FileMgr = Value;
if (Value)
VirtualFileSystem = Value->getVirtualFileSystem();
else
VirtualFileSystem.reset();
}
void CompilerInstance::setSourceManager(SourceManager *Value) {
@@ -197,7 +201,11 @@ CompilerInstance::createDiagnostics(DiagnosticOptions *Opts,
// 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 @@ static void compileModule(CompilerInstance &ImportingInstance,
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?