mirror of
https://github.com/apple/swift.git
synced 2026-09-28 10:03:29 +02:00
This PR adds a command-line flag and the supporting types for SARIF as an alternative to the binary `.dia` format for serializing diagnostics. Nothing writes a SARIF file yet. - Adds `-serialize-diagnostics=<format>`, accepting `dia` (the existing binary format, and the default) or `sarif`. An unknown format is an error. The flag turns serialization on by itself, so a separate `-serialize-diagnostics` is not needed. - Adds a `sarif-diagnostics` file type with a `.sarif` extension, and a matching supplementary output path next to the existing bitcode one. - Computes that path when `sarif` is requested, and leaves the `.dia` path empty in that case, so the compiler only reports the output it will actually write. - Renames the bitcode path and enum case to `LLVMBitcodeDiagnosticsPath` and `SerializedFormat::LLVMBitcode`, so that the two formats read as a symmetric pair rather than implying SARIF is not serialized. This is mechanical, and accounts for the changes to `Frontend.cpp` and `DiagnosticHelper.cpp`. `CompilerInvocation::getSerializedDiagnosticsPathForAtMostOnePrimary` keeps its name: it is bitcode-only by design, since dependency scanning has no SARIF path. - Adds the three `TY_SARIFDiagnostics` cases the driver's exhaustive switches require. These are enum bookkeeping only; the driver does not act on the new format until a later PR.