diff options
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r-- | lib/Sema/SemaExprObjC.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 5bffdd1573..7b0db1cfc1 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -1669,7 +1669,7 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, DeclFilterCCC<ObjCPropertyDecl> Validator; if (TypoCorrection Corrected = CorrectTypo( DeclarationNameInfo(MemberName, MemberLoc), LookupOrdinaryName, NULL, - NULL, Validator, IFace, false, OPT)) { + NULL, Validator, CTK_ErrorRecovery, IFace, false, OPT)) { diagnoseTypo(Corrected, PDiag(diag::err_property_not_found_suggest) << MemberName << QualType(OPT, 0)); DeclarationName TypoResult = Corrected.getCorrection(); @@ -1762,10 +1762,7 @@ ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, // If this reference is in an @implementation, check for 'private' methods. if (!Getter) - if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) - if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) - if (ObjCImplementationDecl *ImpDecl = ClassDecl->getImplementation()) - Getter = ImpDecl->getClassMethod(Sel); + Getter = IFace->lookupPrivateClassMethod(Sel); if (Getter) { // FIXME: refactor/share with ActOnMemberReference(). @@ -1784,10 +1781,7 @@ ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, if (!Setter) { // If this reference is in an @implementation, also check for 'private' // methods. - if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) - if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) - if (ObjCImplementationDecl *ImpDecl = ClassDecl->getImplementation()) - Setter = ImpDecl->getClassMethod(SetterSel); + Setter = IFace->lookupPrivateClassMethod(SetterSel); } // Look through local category implementations associated with the class. if (!Setter) @@ -1907,7 +1901,8 @@ Sema::ObjCMessageKind Sema::getObjCMessageKind(Scope *S, ObjCInterfaceOrSuperCCC Validator(getCurMethodDecl()); if (TypoCorrection Corrected = CorrectTypo(Result.getLookupNameInfo(), Result.getLookupKind(), S, - NULL, Validator, NULL, false, NULL, false)) { + NULL, Validator, CTK_ErrorRecovery, NULL, false, NULL, + false)) { if (Corrected.isKeyword()) { // If we've found the keyword "super" (the only keyword that would be // returned by CorrectTypo), this is a send to super. @@ -3295,7 +3290,8 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, } template <typename TB> -static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr) { +static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr, + bool TollFreeBridgeCast) { QualType T = castExpr->getType(); while (const TypedefType *TD = dyn_cast<TypedefType>(T.getTypePtr())) { TypedefNameDecl *TDNDecl = TD->getDecl(); @@ -3314,8 +3310,15 @@ static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr) { ObjCInterfaceDecl *CastClass = InterfacePointerType->getObjectType()->getInterface(); if ((CastClass == ExprClass) || - (CastClass && ExprClass->isSuperClassOf(CastClass))) + (CastClass && ExprClass->isSuperClassOf(CastClass))) { + if (!TollFreeBridgeCast && S.getLangOpts().ObjCAutoRefCount) { + // bridge attribute is ok. However, under ARC, cast still requires + // an explicit cast and should not compile under ARC. + S.Diag(castExpr->getLocStart(), diag::err_objc_invalid_bridge) + << T << Target->getName(); + } return true; + } S.Diag(castExpr->getLocStart(), diag::warn_objc_invalid_bridge) << T << Target->getName() << castType->getPointeeType(); return true; @@ -3408,8 +3411,8 @@ void Sema::CheckTollFreeBridgeCast(QualType castType, Expr *castExpr) { ARCConversionTypeClass exprACTC = classifyTypeForARCConversion(castExpr->getType()); ARCConversionTypeClass castACTC = classifyTypeForARCConversion(castType); if (castACTC == ACTC_retainable && exprACTC == ACTC_coreFoundation) { - (void)CheckObjCBridgeNSCast<ObjCBridgeAttr>(*this, castType, castExpr); - (void)CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*this, castType, castExpr); + (void)CheckObjCBridgeNSCast<ObjCBridgeAttr>(*this, castType, castExpr, true); + (void)CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*this, castType, castExpr, true); } else if (castACTC == ACTC_coreFoundation && exprACTC == ACTC_retainable) { (void)CheckObjCBridgeCFCast<ObjCBridgeAttr>(*this, castType, castExpr); @@ -3630,8 +3633,8 @@ Sema::CheckObjCARCConversion(SourceRange castRange, QualType castType, if (castACTC == ACTC_retainable && exprACTC == ACTC_coreFoundation && (CCK == CCK_CStyleCast || CCK == CCK_FunctionalCast)) - if (CheckObjCBridgeNSCast<ObjCBridgeAttr>(*this, castType, castExpr) || - CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*this, castType, castExpr)) + if (CheckObjCBridgeNSCast<ObjCBridgeAttr>(*this, castType, castExpr, false) || + CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*this, castType, castExpr, false)) return ACR_okay; if (castACTC == ACTC_coreFoundation && exprACTC == ACTC_retainable && |