This is an archive of the discontinued LLVM Phabricator instance.

Output to SARIF from scan-build
ClosedPublic

Authored by aaron.ballman on Dec 13 2018, 12:21 PM.

Details

Summary

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.

There appear to be no tests for scan-build, which is why you only see implementation files here. I tested locally by running test/Analysis/diagnostics/sarif-diagnostics-taint-test.c through scan-build and ensuring the results are expected for the generated temp directory.

Diff Detail

Event Timeline

aaron.ballman created this revision.Dec 13 2018, 12:21 PM
NoQ accepted this revision.Dec 13 2018, 12:37 PM

Thanks, looks perfectly sane to me!

When i previously wanted to add tests for scan-build, it seemed fairly straightforward:

diff --git a/test/Analysis/scan-build/lit.local.cfg b/test/Analysis/scan-build/lit.local.cfg
new file mode 100644
index 0000000000..84749a790e
--- /dev/null
+++ b/test/Analysis/scan-build/lit.local.cfg
@@ -0,0 +1,7 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+
+import lit.util
+
+config.substitutions.append(('%scan_build',
+                             lit.util.which('scan-build',
+                                            config.environment['PATH'])))
diff --git a/test/Analysis/scan-build/simple-test.test b/test/Analysis/scan-build/simple-test.test
new file mode 100644
index 0000000000..61053dedce
--- /dev/null
+++ b/test/Analysis/scan-build/simple-test.test
@@ -0,0 +1,3 @@
+// RUN: %scan_build --help 2>&1 | FileCheck %s
+
+// CHECK: USAGE: scan-build

But i never committed it, so i'm not sure if it works anywhere except my machine, and i didn't write any actual tests after that. If you like this, you can add this to your patch or make me commit it separately, in any order.

This revision is now accepted and ready to land.Dec 13 2018, 12:37 PM
aaron.ballman closed this revision.Dec 13 2018, 1:03 PM

Committed in r349082.

I left the test file off; it looks like it might work, but given that scan-build puts its output into a temp directory, I wasn't able to see a good way to handle checking the output. Given the simplicity of the change here, I didn't want to spend a lot of time working on spinning up testing infrastructure.