diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 14 |
2 files changed, 11 insertions, 13 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 5c1678262c1..d97ebb0a0e4 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -300,12 +300,16 @@ CompilerInstance::createDiagnostics(DiagnosticOptions *Opts, // File Manager -void CompilerInstance::createFileManager() { +FileManager *CompilerInstance::createFileManager() { if (!hasVirtualFileSystem()) { - // TODO: choose the virtual file system based on the CompilerInvocation. - setVirtualFileSystem(vfs::getRealFileSystem()); + if (IntrusiveRefCntPtr<vfs::FileSystem> VFS = + createVFSFromCompilerInvocation(getInvocation(), getDiagnostics())) + setVirtualFileSystem(VFS); + else + return nullptr; } FileMgr = new FileManager(getFileSystemOpts(), VirtualFileSystem); + return FileMgr.get(); } // Source Manager diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 52e2799deb5..12226b23141 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -633,18 +633,12 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, return true; } - if (!CI.hasVirtualFileSystem()) { - if (IntrusiveRefCntPtr<vfs::FileSystem> VFS = - createVFSFromCompilerInvocation(CI.getInvocation(), - CI.getDiagnostics())) - CI.setVirtualFileSystem(VFS); - else + // Set up the file and source managers, if needed. + if (!CI.hasFileManager()) { + if (!CI.createFileManager()) { goto failure; + } } - - // Set up the file and source managers, if needed. - if (!CI.hasFileManager()) - CI.createFileManager(); if (!CI.hasSourceManager()) CI.createSourceManager(CI.getFileManager()); |