[cfe-commits] r138314 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp test/CodeGen/block-3.c

John McCall rjmccall at apple.com
Mon Aug 22 19:32:10 PDT 2011


On Aug 22, 2011, at 5:59 PM, Eli Friedman wrote:
> On Mon, Aug 22, 2011 at 5:27 PM, Fariborz Jahanian <fjahanian at apple.com> wrote:
>> Author: fjahanian
>> Date: Mon Aug 22 19:27:49 2011
>> New Revision: 138314
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=138314&view=rev
>> Log:
>> block IRgen - Fixes a crash when determining if given block variable
>> is captured by a given statement expression. // rdar://10001085
>> 
>> Added:
>>    cfe/trunk/test/CodeGen/block-3.c
>> Modified:
>>    cfe/trunk/lib/CodeGen/CGDecl.cpp
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=138314&r1=138313&r2=138314&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Mon Aug 22 19:27:49 2011
>> @@ -875,6 +875,9 @@
>>     return false;
>>   }
>> 
>> +  if (const StmtExpr *SE = dyn_cast<StmtExpr>(e))
>> +    e = cast<Expr>(SE->getSubStmt()->body_back());
>> +
>>   for (Stmt::const_child_range children = e->children(); children; ++children)
>>     if (isCapturedBy(var, cast<Expr>(*children)))
>>       return true;
> 
> SE->getSubStmt()->body_back() isn't guaranteed to be an Expr here.
> Also, don't you need to check the other substatements?

I agree; the right solution here is to be able to recursively walk over
arbitrary statements.

John.



More information about the cfe-commits mailing list