aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-07-11 18:04:54 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-07-11 18:04:54 +0000
commit4e7c7f2b78ac3930e45f00626ef6acf08b3f80ca (patch)
tree2b269d2682284e0de8d31a7e1e9509e0a96801fb /lib/Sema/SemaExpr.cpp
parent0673cb30340aadaede7b795c763b00f6b64e611c (diff)
objc-arc: Diagnose when captured variable in block literals
require destruction and there is possibility of that without construction. Thanks Johnm for review and suggestions offline. // rdar://9535237. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134906 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 09c68aef69..9464da84c1 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -8501,6 +8501,15 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
const AnalysisBasedWarnings::Policy &WP = AnalysisWarnings.getDefaultPolicy();
PopFunctionOrBlockScope(&WP, Result->getBlockDecl(), Result);
+ for (BlockDecl::capture_const_iterator ci = BSI->TheDecl->capture_begin(),
+ ce = BSI->TheDecl->capture_end(); ci != ce; ++ci) {
+ const VarDecl *variable = ci->getVariable();
+ QualType T = variable->getType();
+ QualType::DestructionKind destructKind = T.isDestructedType();
+ if (destructKind != QualType::DK_none)
+ getCurFunction()->setHasBranchProtectedScope();
+ }
+
return Owned(Result);
}