From 0f90a7b323bcaa087be31aa135b71694db2d5ff9 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Tue, 29 Apr 2025 10:24:38 -0700 Subject: [clang] Enable making the `CompilerInstance` module dependency collector thread-safe (#137227) The same principle as #135473, #135737, #136178, #136601 & #137059. --- clang/lib/Frontend/CompilerInstance.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'clang/lib/Frontend/CompilerInstance.cpp') diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 2d6ab87..cbc9c9d 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -1257,10 +1257,14 @@ std::unique_ptr CompilerInstance::cloneForModuleCompileImpl( Instance.GetDependencyDirectives = GetDependencyDirectives->cloneFor(Instance.getFileManager()); - // If we're collecting module dependencies, we need to share a collector - // between all of the module CompilerInstances. Other than that, we don't - // want to produce any dependency output from the module build. - Instance.setModuleDepCollector(getModuleDepCollector()); + if (ThreadSafeConfig) { + Instance.setModuleDepCollector(ThreadSafeConfig->getModuleDepCollector()); + } else { + // If we're collecting module dependencies, we need to share a collector + // between all of the module CompilerInstances. Other than that, we don't + // want to produce any dependency output from the module build. + Instance.setModuleDepCollector(getModuleDepCollector()); + } Inv.getDependencyOutputOpts() = DependencyOutputOptions(); return InstancePtr; -- cgit v1.1