Author: Joseph Huber
Date: 2026-07-01T10:57:33-05:00
New Revision: 6bdb63f619111bcb6479beb1bfa8b48612ba1755

URL: 
https://github.com/llvm/llvm-project/commit/6bdb63f619111bcb6479beb1bfa8b48612ba1755
DIFF: 
https://github.com/llvm/llvm-project/commit/6bdb63f619111bcb6479beb1bfa8b48612ba1755.diff

LOG: [Clang] Try to fix data race on HasColors after #202441 (#206975)

Summary:
The clangd users call these functions in multi-thraeded contexts. The
raw_fd_stream has_colors query is cached, which was giving some data
races. Just use the process-level check for now.

Added: 
    

Modified: 
    clang/lib/Basic/Warnings.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp
index 8adf339b3e5eb..91cce2e45d5f4 100644
--- a/clang/lib/Basic/Warnings.cpp
+++ b/clang/lib/Basic/Warnings.cpp
@@ -21,15 +21,18 @@
 //
 // Remark options are also handled here, analogously, except that they are much
 // simpler because a remark can't be promoted to an error.
+
 #include "clang/Basic/AllDiagnostics.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticDriver.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstring>
+
 using namespace clang;
 
 // EmitUnknownDiagWarning - Emit a warning and typo hint for unknown warning
@@ -54,7 +57,8 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
 
   Diags.setElideType(Opts.ElideType);
   Diags.setPrintTemplateTree(Opts.ShowTemplateTree);
-  Diags.setShowColors(Opts.showColors(llvm::errs().has_colors()));
+  Diags.setShowColors(
+      Opts.showColors(llvm::sys::Process::StandardErrHasColors()));
 
   // Handle -ferror-limit
   if (Opts.ErrorLimit)


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to