Clang Static Analyzer: Checking absence of method definition

Hi all,

I want to write a checker that checks whether a handler method,
for example “didReceiveMemoryWarning”, has been implemented.

Based on what I read from the source code, most checkers find
violations in a specific location. Is there a way to check
the absence of implementing handler?

Thanks.
Vu Le

Take a look at CheckObjCDealloc.cpp, which warns about incomplete -dealloc implementations. Diagnostics still need a source location, but they can refer to the location of the @interface or @implementation (for example).

Hi Ted,
Thank you for your fast response.

I add a new file UnhandledMemoryWarningChecker.cpp under Checker.
Rebuilding Clang generates this error

UnhandledMemoryWarningChecker.cpp:59: error: ‘void clang::ento::registerUnhandledMemoryWarningChecker(clang::ento::CheckerManager&)’ should have been declared inside ‘clang::ento’

I couldn’t find the documentation for adding a new Checker.
What are the steps to define a new checker?

Thanks again.
Vu

Hi Vu LE,

You should add you checker in clang/lib/StaticAnalyzer/Checkers/Checkers.td, and implement a function to register it as the error says.

2011/3/9 Vu Le <minhvule@gmail.com>

You can also have a look at r125503 and r125636, where the new checker registration mechanism is introduced which can serve as samples on how to add or modify checkers.

Michael.