[cfe-commits] r140031 - /cfe/trunk/lib/Sema/SemaExpr.cpp

Fariborz Jahanian fjahanian at apple.com
Mon Sep 19 11:06:07 PDT 2011


Author: fjahanian
Date: Mon Sep 19 13:06:07 2011
New Revision: 140031

URL: http://llvm.org/viewvc/llvm-project?rev=140031&view=rev
Log:
objc - some refactoring of my last 'self' patch.


Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=140031&r1=140030&r2=140031&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Sep 19 13:06:07 2011
@@ -5074,10 +5074,11 @@
                               OK));
 }
 
-/// SelfInClassMethodType - convet type of 'self' in class method
+/// ConvertObjCSelfToClassRootType - convet type of 'self' in class method
 /// to pointer to root of method's class.
-static void
-SelfInClassMethodType(Sema &S, Expr *selfExpr, QualType &SelfType) {
+static QualType
+ConvertObjCSelfToClassRootType(Sema &S, Expr *selfExpr) {
+  QualType SelfType;
   if (const ObjCMethodDecl *MD = S.GetMethodIfSelfExpr(selfExpr))
     if (MD->isClassMethod()) {
       const ObjCInterfaceDecl *Root = 0;
@@ -5086,9 +5087,10 @@
         Root = IDecl;
       } while ((IDecl = IDecl->getSuperClass()));
       if (Root)
-        SelfType = S.Context.getObjCObjectPointerType(
-                                                   S.Context.getObjCInterfaceType(Root)); 
+        SelfType =  S.Context.getObjCObjectPointerType(
+                      S.Context.getObjCInterfaceType(Root)); 
     }
+  return SelfType;
 }
 
 // checkPointerTypesForAssignment - This is a very tricky routine (despite
@@ -5326,8 +5328,6 @@
     return Compatible;
   }
 
-  SelfInClassMethodType(*this, RHS.get(), RHSType);
-
   // If the left-hand side is a reference type, then we are in a
   // (rare!) case where we've allowed the use of references in C,
   // e.g., as a parameter type in a built-in function. In this case,
@@ -5420,7 +5420,7 @@
         Kind = CK_BitCast;
         return Compatible;
       }
-
+      
       Kind = CK_BitCast;
       return IncompatiblePointer;
     }
@@ -5468,6 +5468,9 @@
 
   // Conversions to Objective-C pointers.
   if (isa<ObjCObjectPointerType>(LHSType)) {
+    QualType RHSQT = ConvertObjCSelfToClassRootType(*this, RHS.get());
+    if (!RHSQT.isNull())
+      RHSType = RHSQT;
     // A* -> B*
     if (RHSType->isObjCObjectPointerType()) {
       Kind = CK_BitCast;





More information about the cfe-commits mailing list