[cfe-commits] r76529 - in /cfe/trunk: lib/Analysis/CFG.cpp test/Analysis/dead-stores.c
Eli Friedman
eli.friedman at gmail.com
Mon Jul 20 18:59:20 PDT 2009
On Mon, Jul 20, 2009 at 6:12 PM, Mike Stump<mrs at apple.com> wrote:
> --- cfe/trunk/lib/Analysis/CFG.cpp (original)
> +++ cfe/trunk/lib/Analysis/CFG.cpp Mon Jul 20 20:12:51 2009
> @@ -863,10 +863,24 @@
> }
>
> CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) {
> - // "for" is a control-flow statement. Thus we stop processing the current
> - // block.
> + // See if this is a known constant.
> + bool KnownTrue = false;
> + bool KnownFalse = false;
> + Expr::EvalResult Result;
> + if (F->getCond() && F->getCond()->Evaluate(Result, *Context)
> + && Result.Val.isInt()) {
> + if (Result.Val.getInt().getBoolValue())
> + KnownTrue = true;
> + else
> + KnownFalse = true;
> + }
> + if (F->getCond() == 0)
> + KnownTrue = true;
It might be slightly clearer to structure this as an "if ... else if".
-Eli
More information about the cfe-commits
mailing list