[cfe-dev] Newbie question

Anna Zaks ganna at apple.com
Wed Oct 10 17:35:31 PDT 2012


On Oct 10, 2012, at 1:39 PM, Simon Harris <haruki_zaemon at mac.com> wrote:

> Hi Anna,
> 
> On 11/10/2012, at 4:49 AM, Anna Zaks <ganna at apple.com> wrote:
> 
>> Simon,
>> 
>> Are you writing a path-sensitive checker or just an AST visitor?
> 
> A bit of both actually. Although I guess that depends on how "sensitive" we need to be. Mostly I just want to count certain things within methods and given that methods can't be nested, I could use the context to just set/reset the current count while visiting each node in an AST.
> 

Path sensitive checkers use symbolic execution to explore all paths through the program as opposed to working with the AST. (Ex: As described in Ted's very old talk: http://llvm.org/devmtg/2008-08/Kremenek_StaticAnalyzer.pdf).

>> If you have not looked at this yet, here are the bits of documentation we have available. It's very rudimentary and we are planning on extending it in the near future.
>> http://clang-analyzer.llvm.org/checker_dev_manual.html
>> http://clang.llvm.org/doxygen/classento_1_1CheckerDocumentation.html
> 
> I have read these pages which is how I got a skeleton up and "running". My ultimate goal is to have these checks run inside Xcode while building Mac/iOS applications so I'd love some guidance on that score too. Building a completely custom binary seemed, at face value, to be the simplest but least appealing approach.
> 
> Ideally I'd somehow configure them as "plugins" from within an Xcode project but for now, while I'm learning, a custom binary seems the easiest.

As of Xcode 4.5, you can use CLANG_ANALYZER_EXEC build setting to point Xcode to your clang for analyzes. You can also use CLANG_ANALYZER_OTHER_CHECKERS to list the additional checkers.

> 
>> It might be helpful to look at the existing checkers and use them as examples. For example, NSErrorChecker.cpp contains a non-path sensitive check that visits function/method declarations. AttrNonNullChecker is path sensitive and it registers a callback on all calls.
> 
> Oh thanks for the heads up on that. I looked at some of the checkers but hadn't managed to look at all of them. I shall check out both.
> 
> Thank you so much for getting back to me.
> 
> Simon
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121010/b2162521/attachment.html>


More information about the cfe-dev mailing list