diff options
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index bc663ac..de633f0 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -1153,7 +1153,7 @@ static Language getLanguageFromOptions(const LangOptions &LangOpts) { std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompileImpl( SourceLocation ImportLoc, StringRef ModuleName, FrontendInputFile Input, StringRef OriginalModuleMapFile, StringRef ModuleFileName, - IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) { + std::optional<ThreadSafeCloneConfig> ThreadSafeConfig) { // Construct a compiler invocation for creating this module. auto Invocation = std::make_shared<CompilerInvocation>(getInvocation()); @@ -1213,18 +1213,24 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompileImpl( auto &Inv = *Invocation; Instance.setInvocation(std::move(Invocation)); - if (VFS) { - Instance.createFileManager(std::move(VFS)); + if (ThreadSafeConfig) { + Instance.createFileManager(ThreadSafeConfig->getVFS()); } else if (FrontendOpts.ModulesShareFileManager) { Instance.setFileManager(&getFileManager()); } else { Instance.createFileManager(&getVirtualFileSystem()); } - Instance.createDiagnostics( - Instance.getVirtualFileSystem(), - new ForwardingDiagnosticConsumer(getDiagnosticClient()), - /*ShouldOwnClient=*/true); + if (ThreadSafeConfig) { + Instance.createDiagnostics(Instance.getVirtualFileSystem(), + &ThreadSafeConfig->getDiagConsumer(), + /*ShouldOwnClient=*/false); + } else { + Instance.createDiagnostics( + Instance.getVirtualFileSystem(), + new ForwardingDiagnosticConsumer(getDiagnosticClient()), + /*ShouldOwnClient=*/true); + } if (llvm::is_contained(DiagOpts.SystemHeaderWarningsModules, ModuleName)) Instance.getDiagnostics().setSuppressSystemWarnings(false); @@ -1322,7 +1328,7 @@ static OptionalFileEntryRef getPublicModuleMap(FileEntryRef File, std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompile( SourceLocation ImportLoc, Module *Module, StringRef ModuleFileName, - IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) { + std::optional<ThreadSafeCloneConfig> ThreadSafeConfig) { StringRef ModuleName = Module->getTopLevelModuleName(); InputKind IK(getLanguageFromOptions(getLangOpts()), InputKind::ModuleMap); @@ -1368,7 +1374,7 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompile( ImportLoc, ModuleName, FrontendInputFile(ModuleMapFilePath, IK, IsSystem), ModMap.getModuleMapFileForUniquing(Module)->getName(), ModuleFileName, - std::move(VFS)); + std::move(ThreadSafeConfig)); } // FIXME: We only need to fake up an input file here as a way of @@ -1386,7 +1392,7 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompile( ImportLoc, ModuleName, FrontendInputFile(FakeModuleMapFile, IK, +Module->IsSystem), ModMap.getModuleMapFileForUniquing(Module)->getName(), ModuleFileName, - std::move(VFS)); + std::move(ThreadSafeConfig)); std::unique_ptr<llvm::MemoryBuffer> ModuleMapBuffer = llvm::MemoryBuffer::getMemBufferCopy(InferredModuleMapContent); |