[cfe-commits] r105560 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp lib/Sema/SemaExpr.cpp test/CodeGenObjC/dot-syntax-2.m

Fariborz Jahanian fjahanian at apple.com
Mon Jun 7 15:02:01 PDT 2010


Author: fjahanian
Date: Mon Jun  7 17:02:01 2010
New Revision: 105560

URL: http://llvm.org/viewvc/llvm-project?rev=105560&view=rev
Log:
When using property-dot assignment syntax to call a setter method,
type of rhs need be compared to setter's argument and
not the getter type. Fixes radar 8062778

Added:
    cfe/trunk/test/CodeGenObjC/dot-syntax-2.m
Modified:
    cfe/trunk/lib/CodeGen/CGObjC.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=105560&r1=105559&r2=105560&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Mon Jun  7 17:02:01 2010
@@ -595,7 +595,8 @@
                                              Args);
   } else if (const ObjCImplicitSetterGetterRefExpr *E =
                dyn_cast<ObjCImplicitSetterGetterRefExpr>(Exp)) {
-    Selector S = E->getSetterMethod()->getSelector();
+    const ObjCMethodDecl *SetterMD = E->getSetterMethod();
+    Selector S = SetterMD->getSelector();
     CallArgList Args;
     llvm::Value *Receiver;
     if (E->getInterfaceDecl()) {
@@ -606,7 +607,8 @@
       return;
     } else
       Receiver = EmitScalarExpr(E->getBase());
-    Args.push_back(std::make_pair(Src, E->getType()));
+    ObjCMethodDecl::param_iterator P = SetterMD->param_begin(); 
+    Args.push_back(std::make_pair(Src, (*P)->getType()));
     CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(),
                                              getContext().VoidTy, S,
                                              Receiver,

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=105560&r1=105559&r2=105560&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jun  7 17:02:01 2010
@@ -5796,11 +5796,22 @@
 
   QualType LHSType = LHS->getType();
   QualType RHSType = CompoundType.isNull() ? RHS->getType() : CompoundType;
-
   AssignConvertType ConvTy;
   if (CompoundType.isNull()) {
+    QualType LHSTy(LHSType);
     // Simple assignment "x = y".
-    ConvTy = CheckSingleAssignmentConstraints(LHSType, RHS);
+    if (const ObjCImplicitSetterGetterRefExpr *OISGE = 
+        dyn_cast<ObjCImplicitSetterGetterRefExpr>(LHS)) {
+      // If using property-dot syntax notation for assignment, and there is a
+      // setter, RHS expression is being passed to the setter argument. So,
+      // type conversion (and comparison) is RHS to setter's argument type.
+      if (const ObjCMethodDecl *SetterMD = OISGE->getSetterMethod()) {
+        ObjCMethodDecl::param_iterator P = SetterMD->param_begin();
+        LHSTy = (*P)->getType();
+      }
+    }
+    
+    ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
     // Special case of NSObject attributes on c-style pointer types.
     if (ConvTy == IncompatiblePointer &&
         ((Context.isObjCNSObjectType(LHSType) &&

Added: cfe/trunk/test/CodeGenObjC/dot-syntax-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/dot-syntax-2.m?rev=105560&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/dot-syntax-2.m (added)
+++ cfe/trunk/test/CodeGenObjC/dot-syntax-2.m Mon Jun  7 17:02:01 2010
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// rdar: // 8062778
+
+ at interface NSDictionary @end
+
+ at interface NSMutableDictionary : NSDictionary
+ at end
+
+ at interface MutableMyClass 
+- (NSMutableDictionary *)myDict;
+- (void)setMyDict:(NSDictionary *)myDict;
+
+- (NSMutableDictionary *)myLang;
+- (void)setMyLang:(NSDictionary *)myLang;
+ at end
+
+ at interface AnotherClass @end
+
+ at implementation AnotherClass
+- (void)foo
+{
+    MutableMyClass * myObject;
+    NSDictionary * newDict;
+    myObject.myDict = newDict; 
+    myObject.myLang = newDict;
+}
+ at end





More information about the cfe-commits mailing list