r226927 - Objective-C modernizer. Avoid using property-dot syntax when

Fariborz Jahanian fjahanian at apple.com
Fri Jan 23 11:23:42 PST 2015


Author: fjahanian
Date: Fri Jan 23 13:23:42 2015
New Revision: 226927

URL: http://llvm.org/viewvc/llvm-project?rev=226927&view=rev
Log:
Objective-C modernizer. Avoid using property-dot syntax when
receiver type is not valid for property-dot syntz use.
rdar://19381786

Modified:
    cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
    cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m
    cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m.result

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=226927&r1=226926&r2=226927&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Fri Jan 23 13:23:42 2015
@@ -245,6 +245,10 @@ namespace {
         (Msg->getReceiverKind() != ObjCMessageExpr::Instance &&
          Msg->getReceiverKind() != ObjCMessageExpr::SuperInstance))
       return false;
+    if (const Expr *Receiver = Msg->getInstanceReceiver())
+      if (Receiver->getType()->isObjCBuiltinType())
+        return false;
+      
     const ObjCMethodDecl *Method = Msg->getMethodDecl();
     if (!Method)
       return false;

Modified: cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m?rev=226927&r1=226926&r2=226927&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m Fri Jan 23 13:23:42 2015
@@ -68,3 +68,25 @@ P* fun();
 id testRdar19038838(Rdar19038838 *obj) {
   return [obj newItem];
 }
+
+// rdar://19381786
+ at interface rdar19381786 : NSObject
+{
+  rdar19381786* obj;
+}
+ at property int count;
+ at end
+
+ at protocol PR 
+ at property int count;
+ at end
+
+ at implementation rdar19381786
+-(void)test:(id)some : (id<PR>)qsome : (SEL)selsome
+{
+  [obj setCount : 100];
+  [some setCount : [some count]];
+  [qsome setCount : [qsome count]];
+}
+ at end
+

Modified: cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m.result?rev=226927&r1=226926&r2=226927&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m.result Fri Jan 23 13:23:42 2015
@@ -68,3 +68,25 @@ P* fun();
 id testRdar19038838(Rdar19038838 *obj) {
   return obj.newItem;
 }
+
+// rdar://19381786
+ at interface rdar19381786 : NSObject
+{
+  rdar19381786* obj;
+}
+ at property int count;
+ at end
+
+ at protocol PR 
+ at property int count;
+ at end
+
+ at implementation rdar19381786
+-(void)test:(id)some : (id<PR>)qsome : (SEL)selsome
+{
+  obj.count = 100;
+  [some setCount : [some count]];
+  [qsome setCount : [qsome count]];
+}
+ at end
+





More information about the cfe-commits mailing list