summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-06-26 21:22:16 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-06-26 21:22:16 +0000
commit53f867ac45ab2bd572d44dc96e476d8f398b2be0 (patch)
treed29fe3f828cec452f47ad942e602fbd713d916cb /clang/lib/Sema
parentf05a499339ff235fc6247593ee30338d089f8cfd (diff)
downloadbcm5719-llvm-53f867ac45ab2bd572d44dc96e476d8f398b2be0.tar.gz
bcm5719-llvm-53f867ac45ab2bd572d44dc96e476d8f398b2be0.zip
Objective-C ARC. Provide diagnostic and fix-it
when casting a retainable object to a objc_bridge_related CF type with the suggestion of applying the method specified in the bridging attribute to the object. // rdar://15932435 llvm-svn: 211807
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp4
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp23
2 files changed, 26 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8153dff4970..2f1d1a61729 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5274,7 +5274,9 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
Diag(LParenLoc, diag::warn_old_style_cast) << CastExpr->getSourceRange();
CheckTollFreeBridgeCast(castType, CastExpr);
-
+
+ CheckObjCBridgeRelatedCast(castType, CastExpr);
+
return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
}
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 299dd5d379e..0cae6bf3f70 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -3460,6 +3460,29 @@ void Sema::CheckTollFreeBridgeCast(QualType castType, Expr *castExpr) {
}
}
+void Sema::CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr) {
+ QualType SrcType = castExpr->getType();
+ if (ObjCPropertyRefExpr *PRE = dyn_cast<ObjCPropertyRefExpr>(castExpr)) {
+ if (PRE->isExplicitProperty()) {
+ if (ObjCPropertyDecl *PDecl = PRE->getExplicitProperty())
+ SrcType = PDecl->getType();
+ }
+ else if (PRE->isImplicitProperty()) {
+ if (ObjCMethodDecl *Getter = PRE->getImplicitPropertyGetter())
+ SrcType = Getter->getReturnType();
+
+ }
+ }
+
+ ARCConversionTypeClass srcExprACTC = classifyTypeForARCConversion(SrcType);
+ ARCConversionTypeClass castExprACTC = classifyTypeForARCConversion(castType);
+ if (srcExprACTC != ACTC_retainable || castExprACTC != ACTC_coreFoundation)
+ return;
+ CheckObjCBridgeRelatedConversions(castExpr->getLocStart(),
+ castType, SrcType, castExpr);
+ return;
+}
+
bool Sema::CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr,
CastKind &Kind) {
if (!getLangOpts().ObjC1)
OpenPOWER on IntegriCloud