diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaCast.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 16 |
2 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index 51a339581d8..b842ce8889d 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -1067,6 +1067,11 @@ static TryCastResult TryStaticCast(Sema &Self, ExprResult &SrcExpr, Kind = CK_BitCast; return TC_Success; } + // Allow ns-pointer to cf-pointer conversion in either direction + // with static casts. + if (!CStyle && + Self.CheckTollFreeBridgeStaticCast(DestType, SrcExpr.get(), Kind)) + return TC_Success; // We tried everything. Everything! Nothing works! :-( return TC_NotApplicable; diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index d388a4b82e5..bf8af293773 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -3413,6 +3413,22 @@ void Sema::CheckTollFreeBridgeCast(QualType castType, Expr *castExpr) { } } +bool Sema::CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr, + CastKind &Kind) { + if (!getLangOpts().ObjC1) + return false; + ARCConversionTypeClass exprACTC = + classifyTypeForARCConversion(castExpr->getType()); + ARCConversionTypeClass castACTC = classifyTypeForARCConversion(castType); + if ((castACTC == ACTC_retainable && exprACTC == ACTC_coreFoundation) || + (castACTC == ACTC_coreFoundation && exprACTC == ACTC_retainable)) { + CheckTollFreeBridgeCast(castType, castExpr); + Kind = (castACTC == ACTC_coreFoundation) ? CK_BitCast + : CK_CPointerToObjCPointerCast; + return true; + } + return false; +} bool Sema::checkObjCBridgeRelatedComponents(SourceLocation Loc, QualType DestType, QualType SrcType, |