[clang] [clang-tools-extra] [clang-tidy] Add SARIF output to clang-tidy (PR #219182)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 28 06:45:36 PDT 2026
================
@@ -652,6 +659,18 @@ int clangTidyMain(int argc, const char **argv) {
FileName = PathList.front();
const SmallString<256> FilePath = makeAbsolute(FileName);
+
+ std::unique_ptr<llvm::raw_fd_ostream> SarifOS;
+ if (!ExportSarif.empty()) {
+ std::error_code EC;
+ SarifOS = std::make_unique<llvm::raw_fd_ostream>(ExportSarif, EC,
----------------
matthew-j-code wrote:
I've created a new flag ExportSarifToStdout, so when "-" is set, DiagPrinter is now set to an IgnoringDiagConsumer instead of a TextDiagnosticPrinter. IgnoringDiagConsumer overrides HandleDiagnostic() to do nothing, so it silently discards every diagnostic instead of printing it to stdout.
`2 warnings generated.
{
"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/cos02/schemas/sarif-schema-2.1.0.json",
"runs": [
{
"artifacts": [
{
"length": 46,`
Please let me know what you think.
https://github.com/llvm/llvm-project/pull/219182
More information about the cfe-commits
mailing list