[clang] [clang] Enable making `CompilerInstance` diagnostics thread-safe (PR #136601)

Cyndy Ishida via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 21 13:39:04 PDT 2025


================
@@ -861,9 +864,13 @@ class CompilerInstance : public ModuleLoader {
   ///
   /// Explicitly-specified \c VFS takes precedence over the VFS of this instance
   /// when creating the clone and also prevents \c FileManager sharing.
-  std::unique_ptr<CompilerInstance> cloneForModuleCompile(
-      SourceLocation ImportLoc, Module *Module, StringRef ModuleFileName,
-      IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
+  /// Explicitly-specified \c DiagConsumer takes precedence over forwarding to
+  /// this instance.
+  std::unique_ptr<CompilerInstance>
+  cloneForModuleCompile(SourceLocation ImportLoc, Module *Module,
+                        StringRef ModuleFileName,
+                        IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr,
+                        DiagnosticConsumer *DiagConsumer = nullptr);
----------------
cyndyishida wrote:

Would it ever make sense to explicitly pass a `VFS` but not a `DiagConsumer`? or vice-versa? If not, maybe an assert should make that explicit. 

https://github.com/llvm/llvm-project/pull/136601


More information about the cfe-commits mailing list