summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-08-25 00:06:26 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-08-25 00:06:26 +0000
commit5c4b2ca6998e4d69ef0bb07ff3ab299dceb323bf (patch)
treeb9c6d5e9edd98fc8941ef7dc70a3eb8d006cf0aa /clang/lib/CodeGen
parente1be996baad57a1e00bd7839f07692df529b3506 (diff)
downloadbcm5719-llvm-5c4b2ca6998e4d69ef0bb07ff3ab299dceb323bf.tar.gz
bcm5719-llvm-5c4b2ca6998e4d69ef0bb07ff3ab299dceb323bf.zip
blocks - capturing logic of byref block variable's expression
statement initializer makes safe assumption when a substatement is encounterred (with a fix me). llvm-svn: 138528
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 0f6ceedb25c..8fcec30c6a9 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -879,9 +879,25 @@ static bool isCapturedBy(const VarDecl &var, const Expr *e) {
const CompoundStmt *CS = SE->getSubStmt();
for (CompoundStmt::const_body_iterator BI = CS->body_begin(),
BE = CS->body_end(); BI != BE; ++BI)
- if (Expr *E = dyn_cast<Expr>((*BI)))
+ if (Expr *E = dyn_cast<Expr>((*BI))) {
if (isCapturedBy(var, E))
return true;
+ }
+ else if (DeclStmt *DS = dyn_cast<DeclStmt>((*BI))) {
+ // special case declarations
+ for (DeclStmt::decl_iterator I = DS->decl_begin(), E = DS->decl_end();
+ I != E; ++I) {
+ if (VarDecl *VD = dyn_cast<VarDecl>((*I))) {
+ Expr *Init = VD->getInit();
+ if (Init && isCapturedBy(var, Init))
+ return true;
+ }
+ }
+ }
+ else
+ // FIXME. Make safe assumption assuming arbitrary statements cause capturing.
+ // Later, provide code to poke into statements for capture analysis.
+ return true;
return false;
}
OpenPOWER on IntegriCloud