diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-09-19 18:06:07 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-09-19 18:06:07 +0000 |
commit | 71ac1e003b7a82ca6ac7ed76e4d0f9c6d4a1e30a (patch) | |
tree | 7da268ba8d03668c541d2496b8503a14ca91b31b /lib/Sema/SemaExpr.cpp | |
parent | 5584d91c938384b57563edbca5c2d4f1c66ff02a (diff) |
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
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 19 |
1 files 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<ObjCObjectPointerType>(LHSType)) { + QualType RHSQT = ConvertObjCSelfToClassRootType(*this, RHS.get()); + if (!RHSQT.isNull()) + RHSType = RHSQT; // A* -> B* if (RHSType->isObjCObjectPointerType()) { Kind = CK_BitCast; |