Author: aaronballman Date: Thu Dec 13 12:55:34 2018 New Revision: 349082 URL: http://llvm.org/viewvc/llvm-project?rev=349082&view=rev Log: Update the scan-build to generate SARIF.
This updates the scan-build perl script to allow outputting to sarif in a more natural fashion by specifying -sarif as a command line argument, similar to how -plist is already supported. Modified: cfe/trunk/tools/scan-build/bin/scan-build cfe/trunk/tools/scan-build/libexec/ccc-analyzer Modified: cfe/trunk/tools/scan-build/bin/scan-build URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/bin/scan-build?rev=349082&r1=349081&r2=349082&view=diff ============================================================================== --- cfe/trunk/tools/scan-build/bin/scan-build (original) +++ cfe/trunk/tools/scan-build/bin/scan-build Thu Dec 13 12:55:34 2018 @@ -1193,6 +1193,11 @@ OPTIONS: Display the description of defects in the list + -sarif + + By default the output of scan-build is a set of HTML files. This option + outputs the results in SARIF format. + -plist By default the output of scan-build is a set of HTML files. This option @@ -1665,6 +1670,12 @@ sub ProcessArgs { next; } + if ($arg eq "-sarif") { + shift @$Args; + $Options{OutputFormat} = "sarif"; + next; + } + if ($arg eq "-plist") { shift @$Args; $Options{OutputFormat} = "plist"; @@ -1888,9 +1899,12 @@ my $ExitStatus = RunBuildCommand(\@ARGV, $Cmd, $CmdCXX, \%EnvVars); if (defined $Options{OutputFormat}) { - if ($Options{OutputFormat} =~ /plist/) { + if ($Options{OutputFormat} =~ /plist/ || + $Options{OutputFormat} =~ /sarif/) { Diag "Analysis run complete.\n"; - Diag "Analysis results (plist files) deposited in '$Options{OutputDir}'\n"; + Diag "Analysis results (" . + ($Options{OutputFormat} =~ /plist/ ? "plist" : "sarif") . + " files) deposited in '$Options{OutputDir}'\n"; } if ($Options{OutputFormat} =~ /html/) { # Postprocess the HTML directory. Modified: cfe/trunk/tools/scan-build/libexec/ccc-analyzer URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/libexec/ccc-analyzer?rev=349082&r1=349081&r2=349082&view=diff ============================================================================== --- cfe/trunk/tools/scan-build/libexec/ccc-analyzer (original) +++ cfe/trunk/tools/scan-build/libexec/ccc-analyzer Thu Dec 13 12:55:34 2018 @@ -746,9 +746,10 @@ if ($Action eq 'compile' or $Action eq ' if (defined $OutputFormat) { push @AnalyzeArgs, "-analyzer-output=" . $OutputFormat; - if ($OutputFormat =~ /plist/) { + if ($OutputFormat =~ /plist/ || $OutputFormat =~ /sarif/) { # Change "Output" to be a file. - my ($h, $f) = tempfile("report-XXXXXX", SUFFIX => ".plist", + my $Suffix = $OutputFormat =~ /plist/ ? ".plist" : ".sarif"; + my ($h, $f) = tempfile("report-XXXXXX", SUFFIX => $Suffix, DIR => $HtmlDir); $ResultFile = $f; # If the HtmlDir is not set, we should clean up the plist files. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits