diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2018-12-13 20:55:34 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2018-12-13 20:55:34 +0000 |
| commit | 7d880862d21df4d38354a15f21dcf93e91005756 (patch) | |
| tree | 78297354d4611ccfd6c09e749c1b97fbe8c06622 | |
| parent | 934e534c473a2c7a5c94bda55c48c255849f2f4b (diff) | |
| download | bcm5719-llvm-7d880862d21df4d38354a15f21dcf93e91005756.tar.gz bcm5719-llvm-7d880862d21df4d38354a15f21dcf93e91005756.zip | |
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.
llvm-svn: 349082
| -rwxr-xr-x | clang/tools/scan-build/bin/scan-build | 18 | ||||
| -rwxr-xr-x | clang/tools/scan-build/libexec/ccc-analyzer | 5 |
2 files changed, 19 insertions, 4 deletions
diff --git a/clang/tools/scan-build/bin/scan-build b/clang/tools/scan-build/bin/scan-build index 25aeb2bf646..fd0dd66b2d6 100755 --- a/clang/tools/scan-build/bin/scan-build +++ b/clang/tools/scan-build/bin/scan-build @@ -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, $Options{IgnoreErrors}, $Options{KeepCC $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. diff --git a/clang/tools/scan-build/libexec/ccc-analyzer b/clang/tools/scan-build/libexec/ccc-analyzer index 49bffc6a77a..70afb5bcbbd 100755 --- a/clang/tools/scan-build/libexec/ccc-analyzer +++ b/clang/tools/scan-build/libexec/ccc-analyzer @@ -746,9 +746,10 @@ if ($Action eq 'compile' or $Action eq 'link') { 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. |

