r186460 - ObjectiveC migrator. If a class implements a protocol's
Fariborz Jahanian
fjahanian at apple.com
Tue Jul 16 14:59:43 PDT 2013
Author: fjahanian
Date: Tue Jul 16 16:59:42 2013
New Revision: 186460
URL: http://llvm.org/viewvc/llvm-project?rev=186460&view=rev
Log:
ObjectiveC migrator. If a class implements a protocol's
properties, then class conforms to that protocol.
Modified:
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/test/ARCMT/objcmt-protocol-conformance.m
cfe/trunk/test/ARCMT/objcmt-protocol-conformance.m.result
Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=186460&r1=186459&r2=186460&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Tue Jul 16 16:59:42 2013
@@ -250,17 +250,22 @@ ClassImplementsAllMethodsAndProperties(A
if (Property->getPropertyImplementation() == ObjCPropertyDecl::Optional)
continue;
DeclContext::lookup_const_result R = IDecl->lookup(Property->getDeclName());
- if (R.size() == 0)
- return false;
- for (unsigned I = 0, N = R.size(); I != N; ++I) {
- if (ObjCPropertyDecl *ClassProperty = dyn_cast<ObjCPropertyDecl>(R[0])) {
- if (ClassProperty->getPropertyAttributes()
- != Property->getPropertyAttributes())
- return false;
- if (!Ctx.hasSameType(ClassProperty->getType(), Property->getType()))
+ if (R.size() == 0) {
+ // Relax the rule and look into class's implementation for a synthesize
+ // or dynamic declaration. Class is implementing a property coming from
+ // another protocol. This still makes the target protocol as conforming.
+ if (!ImpDecl->FindPropertyImplDecl(
+ Property->getDeclName().getAsIdentifierInfo()))
+ return false;
+ }
+ else if (ObjCPropertyDecl *ClassProperty = dyn_cast<ObjCPropertyDecl>(R[0])) {
+ if ((ClassProperty->getPropertyAttributes()
+ != Property->getPropertyAttributes()) ||
+ !Ctx.hasSameType(ClassProperty->getType(), Property->getType()))
return false;
- }
}
+ else
+ return false;
}
// At this point, all required properties in this protocol conform to those
// declared in the class.
Modified: cfe/trunk/test/ARCMT/objcmt-protocol-conformance.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-protocol-conformance.m?rev=186460&r1=186459&r2=186460&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-protocol-conformance.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-protocol-conformance.m Tue Jul 16 16:59:42 2013
@@ -46,3 +46,18 @@
- (id) Meth1: (double) arg { return 0; }
@end
+// Test5 - conforms to P3 because it implement's P3's property.
+ at protocol P3
+ at property (copy) id Prop;
+ at end
+
+ at protocol P4
+ at property (copy) id Prop;
+ at end
+
+ at interface Test5 : NSObject<P3>
+ at end
+
+ at implementation Test5
+ at synthesize Prop=_XXX;
+ at end
Modified: cfe/trunk/test/ARCMT/objcmt-protocol-conformance.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-protocol-conformance.m.result?rev=186460&r1=186459&r2=186460&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-protocol-conformance.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-protocol-conformance.m.result Tue Jul 16 16:59:42 2013
@@ -46,3 +46,18 @@
- (id) Meth1: (double) arg { return 0; }
@end
+// Test5 - conforms to P3 because it implement's P3's property.
+ at protocol P3
+ at property (copy) id Prop;
+ at end
+
+ at protocol P4
+ at property (copy) id Prop;
+ at end
+
+ at interface Test5 : NSObject<P3, P4>
+ at end
+
+ at implementation Test5
+ at synthesize Prop=_XXX;
+ at end
More information about the cfe-commits
mailing list