summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-10-27 22:33:06 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-10-27 22:33:06 +0000
commit992bdf1b45bdb71871975729583e193ffbd67d13 (patch)
treebd8039ca7db0e0f92fcad4fc88db832919608453 /clang/lib
parentf0822fb00a10911a762d271008e41b47b3e0e2b9 (diff)
downloadbcm5719-llvm-992bdf1b45bdb71871975729583e193ffbd67d13.tar.gz
bcm5719-llvm-992bdf1b45bdb71871975729583e193ffbd67d13.zip
Objective-C ARC [qoi]. Issue diagnostic if __bridge casting
to C type a collection literal. rdar://18768214 llvm-svn: 220727
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 40ab95b6ec5..5746e732943 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -4075,11 +4075,22 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc,
// Okay: id -> CF
CK = CK_BitCast;
switch (Kind) {
- case OBC_Bridge:
- // Reclaiming a value that's going to be __bridge-casted to CF
- // is very dangerous, so we don't do it.
- SubExpr = maybeUndoReclaimObject(SubExpr);
- break;
+ case OBC_Bridge: {
+ const ImplicitCastExpr *implCE = dyn_cast<ImplicitCastExpr>(SubExpr);
+ while (implCE && implCE->getCastKind() == CK_BitCast)
+ implCE = dyn_cast<ImplicitCastExpr>(implCE->getSubExpr());
+ if (implCE && (implCE->getCastKind() == CK_ARCConsumeObject))
+ if (const Expr *LitExp = implCE->getSubExpr())
+ if ((isa<ObjCArrayLiteral>(LitExp) ||
+ isa<ObjCDictionaryLiteral>(LitExp)) &&
+ T->isCARCBridgableType())
+ Diag(BridgeKeywordLoc, diag::warn_arc_consumed_object_released)
+ << T << implCE->getType();
+ // Reclaiming a value that's going to be __bridge-casted to CF
+ // is very dangerous, so we don't do it.
+ SubExpr = maybeUndoReclaimObject(SubExpr);
+ break;
+ }
case OBC_BridgeRetained:
// Produce the object before casting it.
OpenPOWER on IntegriCloud