Did Clang support Incremental Static Analysis ????

Hi All,

My Apologies if the below question was ended up in the wrong forum.

Like to know that did Clang Static Analysis(CSA) has the feature called incremental analysis ???,When i say incremental here ,I mean when i kick off the CSA on the code base for the second time with set of files changed then CSA will use the analysis that was done for the last time along the doing CSA for changed files.


Hi Umesh,

No, currently, the Clang Static Analyzer does not have any support for incremental analysis.


How is this different from compilation? Why can't make(1) determine
which files to (re-)scan?


As David Chisnall pointed out to me, there is some inherent support of incremental build due to the way scan-build works. “The standard way of running the static analyser is via the scan-build script, which runs as part of your normal build system. If you run it as part of an incremental build, then you will get incremental analysis results. You will not, however, get these merged with the previous set.”

It would be relatively easy to merge the results in this setting. Note that, this happens to work well because the analyzer only deals with one file at a time, which does limit its power. Having whole program analyzes is something we are interested in doing in the future and it would greatly complicate the merging. Another problem with relying on this approach is that this would only give you file granularity. In principle, one might not need to reanalyze the whole file if one line in it changed. Coming up with a more general solution is a much more difficult problem.

Another feature that is somewhat related to this is identifying issues and tracking issues over time so that we could detect new warnings that just started appearing after a bunch of changes. This one is important to solve because many workflows involve looking at newly introduced issues. Hopefully, we’ll get to this one soon.

If incremental analysis is something you would love to see in the analyzer, you can chime in by filing an enhancement request on llvm Bugzilla.