diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-04-16 21:10:48 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-04-16 21:10:48 +0000 |
commit | c1f9a28e4da886e1053aa08b3d50760251e917a2 (patch) | |
tree | ba10e4e81063b9c8ee6bac3370de4fe83c413817 /clang/lib/Analysis/LiveVariables.cpp | |
parent | 9d981eb9ae1c3a77e62b74874357fb39c4095201 (diff) | |
download | bcm5719-llvm-c1f9a28e4da886e1053aa08b3d50760251e917a2.tar.gz bcm5719-llvm-c1f9a28e4da886e1053aa08b3d50760251e917a2.zip |
Added CFGBlock::getTerminatorCondition() to get the Expr* of the condition a block's terminator.
Refactored LiveVariables to use getTerminatorCondition() in VisitTerminator().
Bug fix: CFG now computes Block-level expression numbers using information
from block terminators. This fixes <rdar://problem/5868189>.
llvm-svn: 49818
Diffstat (limited to 'clang/lib/Analysis/LiveVariables.cpp')
-rw-r--r-- | clang/lib/Analysis/LiveVariables.cpp | 53 |
1 files changed, 5 insertions, 48 deletions
diff --git a/clang/lib/Analysis/LiveVariables.cpp b/clang/lib/Analysis/LiveVariables.cpp index feba80d6955..4148d9e838d 100644 --- a/clang/lib/Analysis/LiveVariables.cpp +++ b/clang/lib/Analysis/LiveVariables.cpp @@ -119,7 +119,7 @@ public: void VisitDeclStmt(DeclStmt* DS); void VisitUnaryOperator(UnaryOperator* U); void Visit(Stmt *S); - void VisitTerminator(Stmt* S); + void VisitTerminator(CFGBlock* B); void SetTopValue(LiveVariables::ValTy& V) { V = AD.AlwaysLive; @@ -142,56 +142,13 @@ void TransferFuncs::Visit(Stmt *S) { LiveState(S,AD) = Alive; } -void TransferFuncs::VisitTerminator(Stmt* S) { - - 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; - } - +void TransferFuncs::VisitTerminator(CFGBlock* B) { + + const Expr* E = B->getTerminatorCondition(); + if (!E) return; - E = E->IgnoreParens(); - assert (getCFG().isBlkExpr(E)); LiveState(E, AD) = Alive; } |