]> granicus.if.org Git - clang/commitdiff
Teach static analyzer to analyze Objective-C methods in category implementations.
authorTed Kremenek <kremenek@apple.com>
Thu, 19 May 2011 00:56:53 +0000 (00:56 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 19 May 2011 00:56:53 +0000 (00:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131614 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
test/Analysis/misc-ps.m

index cd2cea47d74c3ce5bcd8185b55c4fdb30529d52b..b8dbb545041e7215f1c00419f6324205234d80d8 100644 (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);
index 30532a82259def81752e4b18b4f79576cefad7e9..da84b2487a8e4e5e9a54d2d903aeafe7edbfcce2 100644 (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
+