[cfe-commits] r49798 - /cfe/trunk/lib/Analysis/LiveVariables.cpp
Ted Kremenek
kremenek at apple.com
Wed Apr 16 10:08:00 PDT 2008
Author: kremenek
Date: Wed Apr 16 12:07:59 2008
New Revision: 49798
URL: http://llvm.org/viewvc/llvm-project?rev=49798&view=rev
Log:
LiveVariables now updates the liveness state of block-level expressions that
are referenced by CFGBlock terminators.
Modified:
cfe/trunk/lib/Analysis/LiveVariables.cpp
Modified: cfe/trunk/lib/Analysis/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/LiveVariables.cpp?rev=49798&r1=49797&r2=49798&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp Wed Apr 16 12:07:59 2008
@@ -143,22 +143,59 @@
}
void TransferFuncs::VisitTerminator(Stmt* S) {
- return;
- for (Stmt::child_iterator I = S->child_begin(), E = S->child_end();
- I != E; ++I) {
-
- Stmt* Child = *I;
- if (!Child) continue;
-
- if (getCFG().isBlkExpr(Child)) {
- LiveState(Child, AD) = Alive;
- return; // Only one "condition" expression.
- }
+ Expr* E = NULL;
+
+ switch (S->getStmtClass()) {
+ default:
+ return;
+
+ case Stmt::ForStmtClass:
+ E = cast<ForStmt>(S)->getCond();
+ break;
+
+ case Stmt::WhileStmtClass:
+ E = cast<WhileStmt>(S)->getCond();
+ break;
+
+ case Stmt::DoStmtClass:
+ E = cast<DoStmt>(S)->getCond();
+ break;
+
+ case Stmt::IfStmtClass:
+ E = cast<IfStmt>(S)->getCond();
+ break;
+
+ case Stmt::ChooseExprClass:
+ E = cast<ChooseExpr>(S)->getCond();
+ break;
+
+ case Stmt::IndirectGotoStmtClass:
+ E = cast<IndirectGotoStmt>(S)->getTarget();
+ break;
+
+ case Stmt::SwitchStmtClass:
+ E = cast<SwitchStmt>(S)->getCond();
+ break;
+
+ case Stmt::ConditionalOperatorClass:
+ E = cast<ConditionalOperator>(S)->getCond();
+ break;
+
+ case Stmt::BinaryOperatorClass: // '&&' and '||'
+ E = cast<BinaryOperator>(S)->getLHS();
+ break;
}
+
+ if (!E)
+ return;
+
+ E = E->IgnoreParens();
+
+ assert (getCFG().isBlkExpr(E));
+ LiveState(E, AD) = Alive;
}
-
void TransferFuncs::VisitDeclRefExpr(DeclRefExpr* DR) {
if (VarDecl* V = dyn_cast<VarDecl>(DR->getDecl()))
LiveState(V,AD) = Alive;
More information about the cfe-commits
mailing list