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

llvm-svn: 314370
This commit is contained in:
Akira Hatanaka 2017-09-28 01:31:17 +00:00
parent d122381288
commit fa1930c506
2 changed files with 8 additions and 1 deletions

View File

@ -4322,7 +4322,7 @@ static Expr *maybeUndoReclaimObject(Expr *e) {
// 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();

View File

@ -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;
}