Bug 68910 - Would like an EWS bot that runs the Clang static analyzer on patches
Summary: Would like an EWS bot that runs the Clang static analyzer on patches
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2011-09-27 09:46 PDT by Adam Roben (:aroben)
Modified: 2021-08-15 15:26 PDT (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Roben (:aroben) 2011-09-27 09:46:42 PDT
It would be great to have an EWS bot that ran patches through the Clang static analyzer. Then we could find issues even before the patch is landed!
Comment 1 Radar WebKit Bug Importer 2011-09-27 09:47:12 PDT
<rdar://problem/10193189>
Comment 2 Adam Barth 2011-09-27 09:57:51 PDT
How do I run the clang static analyzer?
Comment 3 Adam Roben (:aroben) 2011-09-27 10:12:42 PDT
There are generic instructions on <http://clang-analyzer.llvm.org/scan-build.html>. I'm not sure what the specific process would be for WebKit.
Comment 4 Adam Roben (:aroben) 2011-09-27 10:13:22 PDT
See also bug 68908.
Comment 5 Adam Barth 2011-09-27 10:41:16 PDT
Thakis is working on switching the webkit.org build of Chromium Mac to use clang, which seems related.  (The chromium.org version already uses clang.)

I'm pretty ignorant about this topic, but I think that will help here.
Comment 6 Adam Roben (:aroben) 2011-09-28 05:05:17 PDT
I wonder if something as simple as "scan-build build-webkit" would work?
Comment 7 Adam Barth 2011-09-28 09:54:46 PDT
abarth@quadzen:~/svn/webkit$ scan-build build-webkit
-bash: scan-build: command not found

^^^ Maybe I need Lion?
Comment 8 Adam Roben (:aroben) 2011-09-28 10:01:33 PDT
I don't seem to have a "scan-build" binary either.

I do notice that clang supports an --analyze flag.

I guess we should figure out how Xcode drives clang for static analysis.
Comment 9 Adam Roben (:aroben) 2011-09-28 10:03:40 PDT
It looks like Xcode is just calling "clang --analyze" (with loads of other options appropriate for the project, of course).
Comment 10 Anders Carlsson 2011-09-28 10:04:25 PDT
scan-build is just a perl script - it's available from the clang svn repository.
Comment 11 Adam Roben (:aroben) 2011-09-28 10:49:43 PDT
Supposedly this will do it (for a single project, of course): xcodebuild RUN_CLANG_STATIC_ANALYZER=YES
Comment 12 Adam Roben (:aroben) 2012-01-11 07:58:33 PST
See also bug 68908.
Comment 13 Nico Weber 2012-01-11 08:09:32 PST
scan-build isn't distributed anywhere I know of, but it can be checked out from the clang svn repo here: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/

As of 2011-11-30, the analyzer doesn't understand RAII and smart pointers ( http://llvm.org/bugs/show_bug.cgi?id=11425#c1 ), which makes it not very useful for c++ projects in my experience. As far as I know, this is still true today.
Comment 14 Mark Rowe (bdash) 2012-01-11 10:43:29 PST
It's distributed as part of Xcode, and is incredibly effective at finding issues in code that makes use of Objective-C and CF. It's effectiveness in C++ code will only increase over time.
Comment 15 Adam Barth 2012-01-11 10:53:43 PST
If it's a Mac thing, then it should be straightforward to run on the mac-ews.  Sorry for the ignorant question, but does "xcodebuild RUN_CLANG_STATIC_ANALYZER=YES" generate a compiled binary, or just run the analysis?  If the analysis step is separate, we might want to run the analysis on separate bots to avoid slowing down the mac-ews.
Comment 16 Mark Rowe (bdash) 2012-01-11 11:08:22 PST
It both compiles and runs the analysis.
Comment 17 Adam Barth 2012-01-11 11:33:26 PST
Ok.  Maybe the thing to do is to add a --analyze flag to build-webkit that runs the analysis together with building.

thakis warned me in IRC that the static analysis can be much slower than the normal compile, so we'll want to make sure we have enough machine bandwidth.