Clang has had support for SARIF for a bit, but there are two problems:
- Piping stderr to a requires manual editing before feeding to a SARIF consumer.
- There isn’t support for batching builds (e.g. using a build system).
I propose adding two flags to resolve this problem:
-fdiagnostics-output=(stderr|file-overwrite|file-append), which tells Clang how the user expects diagnostics to be written
stderris the default option, and will tell the compiler to write to standard error, as it does today
file-overwritewill write to a specified file, and overwrite the file if it exists
file-appendwill write to a specified file, and append the file if it exists
-fdiagnostics-output-path=, which tells Clang where to output diagnostics if the above option is not
stderr. It’s intended to be an error to set
-fdiagnostics-output-pathin the event of
It will then be up to build systems to provide support for using these flags with append mode. I suspect that handwritten Makefiles would need to have a clobber step for each invocation. Build system generators (CMake) and more intelligent build systems can probably do something a bit better.