[cfe-commits] r61336 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/property-1.m test/SemaObjC/property-category-3.m

Fariborz Jahanian fjahanian at apple.com
Mon Dec 22 11:05:32 PST 2008


Author: fjahanian
Date: Mon Dec 22 13:05:31 2008
New Revision: 61336

URL: http://llvm.org/viewvc/llvm-project?rev=61336&view=rev
Log:
Patch to remove bogus warning in case of @dynamic
property in a category and to issue diagnostics
for mismatch method in some other cases.

Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/property-1.m
    cfe/trunk/test/SemaObjC/property-category-3.m

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=61336&r1=61335&r2=61336&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Mon Dec 22 13:05:31 2008
@@ -737,13 +737,16 @@
        E = IDecl->instmeth_end(); I != E; ++I)
     if (!(*I)->isSynthesized() && !InsMap.count((*I)->getSelector()))
       WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
-    else if (!(*I)->isSynthesized()){
+    else {
       ObjCMethodDecl *ImpMethodDecl = 
         IMPDecl->getInstanceMethod((*I)->getSelector());
       ObjCMethodDecl *IntfMethodDecl = 
         IDecl->getInstanceMethod((*I)->getSelector());
-      WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
-      
+      assert(IntfMethodDecl && 
+             "IntfMethodDecl is null in ImplMethodsVsClassMethods");
+      // ImpMethodDecl may be null as in a @dynamic property.
+      if (ImpMethodDecl)
+        WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
     }
       
   llvm::DenseSet<Selector> ClsMap;
@@ -790,14 +793,18 @@
   bool IncompleteImpl = false;
   for (ObjCCategoryDecl::instmeth_iterator I = CatClassDecl->instmeth_begin(),
        E = CatClassDecl->instmeth_end(); I != E; ++I)
-    if (!InsMap.count((*I)->getSelector()))
+    if (!(*I)->isSynthesized() && !InsMap.count((*I)->getSelector()))
       WarnUndefinedMethod(CatImplDecl->getLocation(), *I, IncompleteImpl);
     else {
       ObjCMethodDecl *ImpMethodDecl = 
         CatImplDecl->getInstanceMethod((*I)->getSelector());
       ObjCMethodDecl *IntfMethodDecl = 
         CatClassDecl->getInstanceMethod((*I)->getSelector());
-      WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
+      assert(IntfMethodDecl && 
+             "IntfMethodDecl is null in ImplCategoryMethodsVsIntfMethods");
+      // ImpMethodDecl may be null as in a @dynamic property.
+      if (ImpMethodDecl)        
+        WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
     }
 
   llvm::DenseSet<Selector> ClsMap;

Modified: cfe/trunk/test/SemaObjC/property-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-1.m?rev=61336&r1=61335&r2=61336&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/property-1.m (original)
+++ cfe/trunk/test/SemaObjC/property-1.m Mon Dec 22 13:05:31 2008
@@ -22,7 +22,7 @@
 @synthesize name;	// OK! property with same name as an accessible ivar of same name
 @end
 
- at implementation I(CAT)  // expected-warning {{incomplete implementation}}, expected-warning {{method definition for 'd1' not found}}, // expected-warning {{method definition for 'setD1:' not found}} 
+ at implementation I(CAT)  
 @synthesize d1;		// expected-error {{@synthesize not allowed in a category's implementation}}
 @dynamic bad;		// expected-error {{property implementation must have its declaration in the category 'CAT'}}
 @end

Modified: cfe/trunk/test/SemaObjC/property-category-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-category-3.m?rev=61336&r1=61335&r2=61336&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/property-category-3.m (original)
+++ cfe/trunk/test/SemaObjC/property-category-3.m Mon Dec 22 13:05:31 2008
@@ -18,4 +18,14 @@
 @end
 
 
+ at interface A 
+ at property(assign) int categoryProperty;
+ at end
+
+// Don't issue warning on unimplemented setter/getter
+// because property is @dynamic.
+ at implementation A 
+ at dynamic categoryProperty;
+ at end
+
 





More information about the cfe-commits mailing list