summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGClass.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2017-12-14 18:21:14 +0000
committerJohn McCall <rjmccall@apple.com>2017-12-14 18:21:14 +0000
commit9508845e3f48cec3273c45209c01eed3cfbf26f9 (patch)
tree77fc2c8380f2695dd85587369594ffd675175c24 /clang/lib/CodeGen/CGClass.cpp
parent99813ded7d407e78f9199503eaf43ca006b8aff0 (diff)
downloadbcm5719-llvm-9508845e3f48cec3273c45209c01eed3cfbf26f9.tar.gz
bcm5719-llvm-9508845e3f48cec3273c45209c01eed3cfbf26f9.zip
In an ARC lambda-to-block conversion thunk, reclaim the return value of
the lambda so that we don't over-release it. Patch by Dan Zimmerman! llvm-svn: 320721
Diffstat (limited to 'clang/lib/CodeGen/CGClass.cpp')
-rw-r--r--clang/lib/CodeGen/CGClass.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 9bbdc98f1f2..a6915071ec1 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -2777,9 +2777,12 @@ void CodeGenFunction::EmitForwardingCallToLambda(
RValue RV = EmitCall(calleeFnInfo, callee, returnSlot, callArgs);
// If necessary, copy the returned value into the slot.
- if (!resultType->isVoidType() && returnSlot.isNull())
+ if (!resultType->isVoidType() && returnSlot.isNull()) {
+ if (getLangOpts().ObjCAutoRefCount && resultType->isObjCRetainableType()) {
+ RV = RValue::get(EmitARCRetainAutoreleasedReturnValue(RV.getScalarVal()));
+ }
EmitReturnOfRValue(RV, resultType);
- else
+ } else
EmitBranchThroughCleanup(ReturnBlock);
}
OpenPOWER on IntegriCloud