[clang] [clang][diagnostics] Add `-fdiagnostics-add-output` switch for SARIF (PR #185201)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri May 22 06:35:11 PDT 2026


================
@@ -58,8 +58,13 @@ class SARIFDiagnosticPrinter : public DiagnosticConsumer {
   void HandleDiagnostic(DiagnosticsEngine::Level Level,
                         const Diagnostic &Info) override;
 
+  static std::unique_ptr<SARIFDiagnosticPrinter>
+  create(ArrayRef<std::pair<StringRef, StringRef>> Config,
+         DiagnosticOptions &DiagOpts, DiagnosticsEngine &Diags);
+
 private:
-  raw_ostream &OS;
+  std::string FilePath;
----------------
AaronBallman wrote:

I guess I would have expected the printer object to have the stream we're printing to instead of having to do path management (I was expecting the places using the diagnostic printer would be responsible for figuring out what to open).

This way the caller can handle failures from things like file permissions, etc instead of making the printer do it. WDYT?

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


More information about the cfe-commits mailing list