summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2019-12-11 22:51:18 -0800
committerAkira Hatanaka <ahatanaka@apple.com>2019-12-13 13:10:07 -0800
commita0a670614a36f1686c5086033bef85800128cf66 (patch)
tree2cb48ba8b13971558a1c3aef8fba2e802f51943a /clang/lib
parent5623bd52acd34db2e9cfc11d1510407610a14db0 (diff)
downloadbcm5719-llvm-a0a670614a36f1686c5086033bef85800128cf66.tar.gz
bcm5719-llvm-a0a670614a36f1686c5086033bef85800128cf66.zip
Call objc_retainBlock before passing a block as a variadic argument
Copy the block to the heap before passing it to the callee in case the block escapes in the callee. rdar://problem/55683462 Differential Revision: https://reviews.llvm.org/D71431
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 620ec30b128..36eef4f425e 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5247,6 +5247,9 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl,
for (Expr *A : Args.slice(ArgIx)) {
ExprResult Arg = DefaultVariadicArgumentPromotion(A, CallType, FDecl);
Invalid |= Arg.isInvalid();
+ // Copy blocks to the heap.
+ if (A->getType()->isBlockPointerType())
+ maybeExtendBlockObject(Arg);
AllArgs.push_back(Arg.get());
}
}
OpenPOWER on IntegriCloud