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-
stderr
is the default option, and will tell the compiler to write to standard error, as it does today -
file-overwrite
will write to a specified file, and overwrite the file if it exists -
file-append
will 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 notstderr
. It’s intended to be an error to set-fdiagnostics-output-path
in the event of-fdiagnostics-output=stderr
.
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.