[cfe-dev] Extend Static Analyzer

Jordy Rose jediknil at belkadan.com
Thu Jun 30 12:32:29 PDT 2011


That should be all you need. The most important part, of course, is the registration function (see the bottom of MacOSXAPIChecker, if you're missing ).

If you put your checker in a non-default package in Checkers.td (core,deadcode,security, and possibly unix or osx, depending on your platform), you will have to enable it specifically when you run clang:

clang -cc1 -analyzer-checker somepackage.mychecker file.c
clang -Xanalyzer -analyzer-checker=somepackage.mychecker file.c

Jordy


On Jun 29, 2011, at 10:46, ajotwani wrote:

> Thanks for the reply to the question about extending the static analyzer. I
> have followed your recommendation and have added a simple self contained
> checker to lib/StaticAnalyzer/Checkers that implements some very basic
> warnings if it sees certain function calls for file access (e.g.
> 'writeToFile' in Objective C). I modeled the checker against the
> UnixAPIChecker.cpp and MacOSXAPIChecker.cpp. I also added the declaration of
> the checker to lib/StaticAnalyzer/Checkers/Checkers.td. 
> 
> Is there anywhere else I need to add anything to get this working? I am
> assuming the checker will be invoked when a function call happens based on
> check::PreStmt<CallExpr>, which I included from the UnixAPIChecker and
> MacOSXAPIChecker checkers. 
> 
> --
> View this message in context: http://clang-developers.42468.n3.nabble.com/Extend-Static-Analyzer-tp3120000p3122610.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list