From 71ac1e003b7a82ca6ac7ed76e4d0f9c6d4a1e30a Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 19 Sep 2011 18:06:07 +0000 Subject: [PATCH] objc - some refactoring of my last 'self' patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140031 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 715a4bd025..9fb0ac211f 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -5074,10 +5074,11 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc, 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 @@ SelfInClassMethodType(Sema &S, Expr *selfExpr, QualType &SelfType) { 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 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS, 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 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS, Kind = CK_BitCast; return Compatible; } - + Kind = CK_BitCast; return IncompatiblePointer; } @@ -5468,6 +5468,9 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS, // Conversions to Objective-C pointers. if (isa(LHSType)) { + QualType RHSQT = ConvertObjCSelfToClassRootType(*this, RHS.get()); + if (!RHSQT.isNull()) + RHSType = RHSQT; // A* -> B* if (RHSType->isObjCObjectPointerType()) { Kind = CK_BitCast; -- 2.50.1