From: Ted Kremenek Date: Thu, 19 May 2011 00:56:53 +0000 (+0000) Subject: Teach static analyzer to analyze Objective-C methods in category implementations. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e744db7c294f357e7e0af628275331f3a6c1b6b;p=clang Teach static analyzer to analyze Objective-C methods in category implementations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131614 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index cd2cea47d7..b8dbb54504 100644 --- a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -200,18 +200,20 @@ void AnalysisConsumer::HandleDeclContext(ASTContext &C, DeclContext *dc) { } break; } - + + case Decl::ObjCCategoryImpl: case Decl::ObjCImplementation: { - ObjCImplementationDecl* ID = cast(*I); + ObjCImplDecl* ID = cast(*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); diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 30532a8225..da84b2487a 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -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 +