r188438 - ObjectiveC [Sema]. This patch makes sure that all inherited

Fariborz Jahanian fjahanian at apple.com
Wed Aug 14 16:58:56 PDT 2013


Author: fjahanian
Date: Wed Aug 14 18:58:55 2013
New Revision: 188438

URL: http://llvm.org/viewvc/llvm-project?rev=188438&view=rev
Log:
ObjectiveC [Sema]. This patch makes sure that all inherited
properties (direct or indirect) setter/getter (or declared 
methods as well) are seen by the method implementation type 
matching logic before declaration of method in super class 
is seen. This fixes the warning coming out of that method mismatch.
// rdar://14650159

Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/method-conflict-2.m

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=188438&r1=188437&r2=188438&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Aug 14 18:58:55 2013
@@ -1773,6 +1773,16 @@ void Sema::MatchAllMethodDeclarations(co
     }
   }
   
+  if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl> (CDecl)) {
+    // Also, check for methods declared in protocols inherited by
+    // this protocol.
+    for (ObjCProtocolDecl::protocol_iterator
+          PI = PD->protocol_begin(), E = PD->protocol_end(); PI != E; ++PI)
+      MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen,
+                                 IMPDecl, (*PI), IncompleteImpl, false,
+                                 WarnCategoryMethodImpl);
+  }
+  
   if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl> (CDecl)) {
     // when checking that methods in implementation match their declaration,
     // i.e. when WarnCategoryMethodImpl is false, check declarations in class

Modified: cfe/trunk/test/SemaObjC/method-conflict-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-conflict-2.m?rev=188438&r1=188437&r2=188438&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/method-conflict-2.m (original)
+++ cfe/trunk/test/SemaObjC/method-conflict-2.m Wed Aug 14 18:58:55 2013
@@ -64,3 +64,52 @@ typedef long long int64_t;
   return 0;
 }
 @end
+
+// rdar://14650159
+// Tests that property inherited indirectly from a nested protocol
+// is seen by the method implementation type matching logic before
+// method in super class is seen. This fixes the warning coming
+// out of that method mismatch.
+ at interface NSObject (NSDict)
+- (void)setValue:(id)value;
+- (id)value;
+ at end
+
+ at protocol ProtocolWithValue
+ at property (nonatomic) unsigned value;
+ at end
+
+ at protocol InterveningProtocol <ProtocolWithValue>
+ at end
+
+ at interface UsesProtocolWithValue : NSObject <ProtocolWithValue>
+ at end
+
+ at implementation UsesProtocolWithValue
+ at synthesize value=_value;
+- (unsigned) value
+{
+	return _value;
+}
+- (void) setValue:(unsigned)value
+{
+	_value = value;
+}
+ at end
+
+
+ at interface UsesInterveningProtocol : NSObject <InterveningProtocol>
+ at end
+
+ at implementation UsesInterveningProtocol
+
+ at synthesize value=_value;
+- (unsigned) value
+{
+	return _value;
+}
+- (void) setValue:(unsigned)value
+{
+	_value = value;
+}
+ at end





More information about the cfe-commits mailing list