[cfe-dev] Proposal for statistic UncheckedReturnValue checker

Andrew McGregor andrewmcgr at gmail.com
Tue Oct 26 21:02:53 PDT 2010


On 26/10/2010, at 5:52 PM, Ted Kremenek wrote:
> In most cases the information for a statistical check can be acquired from doing intra-procedural analysis to sample the data (e.g., analyze functions individually and gather observations).  The problem is you just need to post-process all that data after analyzing a translation unit or an entire codebase.  So it isn't whole-program analysis in the traditional program analysis sense (e.g., using summary based analysis, etc.), just some data crunching afterwards.  Note that this kind of preprocessing doesn't have to be sophisticated.  Prototyping something is simple; just write a script that post-processes some data that you store on the side.  Integrating this completely into clang, however, is advantageous from an integration perspective (e.g., all error reporting goes through the same machinery).
> 
> One step I'm interested in taking the existing AnalysisConsumer and Checker objects is having Checker objects (potentially) live through the analysis of all functions (i.e., live through multiple instances of GRExprEngine).  Such checkers would then be able to accrue data across multiple functions, and then do the kind of analysis you are talking about.  This seems like a potentially essential step on the road to more sophisticated analyses, but the details are not fleshed out.

That would make it fairly trivial to calculate cyclomatic complexity, Halstead complexity and a few other metrics on a file as well.  That could be interesting in some contexts.  Right now as an experiment I'm doing that by printing the AST as XML and post-processing, but it would obviously be far faster inline.

Andrew





More information about the cfe-dev mailing list