Teach static analyzer to analyze Objective-C methods in category implementations.

llvm-svn: 131614
This commit is contained in:
Ted Kremenek 2011-05-19 00:56:53 +00:00
parent 316b460309
commit 5f06955aa0
2 changed files with 20 additions and 4 deletions

View File

@ -200,18 +200,20 @@ void AnalysisConsumer::HandleDeclContext(ASTContext &C, DeclContext *dc) {
}
break;
}
case Decl::ObjCCategoryImpl:
case Decl::ObjCImplementation: {
ObjCImplementationDecl* ID = cast<ObjCImplementationDecl>(*I);
ObjCImplDecl* ID = cast<ObjCImplDecl>(*I);
HandleCode(ID);
for (ObjCImplementationDecl::method_iterator MI = ID->meth_begin(),
for (ObjCContainerDecl::method_iterator MI = ID->meth_begin(),
ME = ID->meth_end(); MI != ME; ++MI) {
checkerMgr->runCheckersOnASTDecl(*MI, *Mgr, BR);
if ((*MI)->isThisDeclarationADefinition()) {
if (!Opts.AnalyzeSpecificFunction.empty() &&
Opts.AnalyzeSpecificFunction != (*MI)->getSelector().getAsString())
Opts.AnalyzeSpecificFunction !=
(*MI)->getSelector().getAsString())
break;
DisplayFunction(*MI);
HandleCode(*MI);

View File

@ -1312,3 +1312,17 @@ void radar9414427() {
}
}
// Analyze methods in @implementation (category)
@interface RDar9465344
@end
@implementation RDar9465344 (MyCategory)
- (void) testcategoryImpl {
int *p = 0x0;
*p = 0xDEADBEEF; // expected-warning {{null}}
}
@end
@implementation RDar9465344
@end