[cfe-commits] r138334 - /cfe/trunk/lib/CodeGen/CGDecl.cpp

Eli Friedman eli.friedman at gmail.com
Tue Aug 23 16:12:24 PDT 2011


On Tue, Aug 23, 2011 at 9:47 AM, Fariborz Jahanian <fjahanian at apple.com> wrote:
> Author: fjahanian
> Date: Tue Aug 23 11:47:15 2011
> New Revision: 138334
>
> URL: http://llvm.org/viewvc/llvm-project?rev=138334&view=rev
> Log:
> checking for __block variable captured by given
> stmt expression, recursively walk down all substatements
> of the stmt expression. // rdar://10001085
>
> 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=138334&r1=138333&r2=138334&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Aug 23 11:47:15 2011
> @@ -875,8 +875,15 @@
>     return false;
>   }
>
> -  if (const StmtExpr *SE = dyn_cast<StmtExpr>(e))
> -    e = cast<Expr>(SE->getSubStmt()->body_back());
> +  if (const StmtExpr *SE = dyn_cast<StmtExpr>(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 (isCapturedBy(var, E))
> +            return true;
> +    return false;
> +  }

Closer, but still not right... you might not find a capturing use in a
substatement which is not an expression.

-Eli




More information about the cfe-commits mailing list