r314370 - Look through parentheses.
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 27 18:31:17 PDT 2017
Author: ahatanak
Date: Wed Sep 27 18:31:17 2017
New Revision: 314370
URL: http://llvm.org/viewvc/llvm-project?rev=314370&view=rev
Log:
Look through parentheses.
This fixes a bug where clang would emit instructions to reclaim a value
that's going to be __bridge-casted to CF.
rdar://problem/34687542
Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=314370&r1=314369&r2=314370&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Sep 27 18:31:17 2017
@@ -4322,7 +4322,7 @@ static Expr *maybeUndoReclaimObject(Expr
// problems here. To catch them all, we'd need to rebuild arbitrary
// value-propagating subexpressions --- we can't reliably rebuild
// in-place because of expression sharing.
- if (ImplicitCastExpr *ice = dyn_cast<ImplicitCastExpr>(e))
+ if (auto *ice = dyn_cast<ImplicitCastExpr>(e->IgnoreParens()))
if (ice->getCastKind() == CK_ARCReclaimReturnedObject)
return ice->getSubExpr();
Modified: cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m?rev=314370&r1=314369&r2=314370&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m Wed Sep 27 18:31:17 2017
@@ -97,3 +97,10 @@ void bridge_of_cf(int *i) {
// CHECK-NEXT: ret void
}
+// CHECK-LABEL: define %struct.__CFString* @bridge_of_paren_expr()
+CFStringRef bridge_of_paren_expr() {
+ // CHECK-NOT: call i8* @objc_retainAutoreleasedReturnValue(
+ // CHECK-NOT: call void @objc_release(
+ CFStringRef r = (__bridge CFStringRef)(CreateNSString());
+ return r;
+}
More information about the cfe-commits
mailing list