From 05ecfddfc3f02027172c047f8fbe7e549faa867e Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 18 Jan 2008 00:40:21 +0000 Subject: [PATCH] Fixed bug in 'LiveVariables' analysis where we incorrectly marked a variable dead at an assignment without taking into account if the variable was used in the RHS of the assignment. llvm-svn: 46153 --- clang/Analysis/LiveVariables.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/Analysis/LiveVariables.cpp b/clang/Analysis/LiveVariables.cpp index 5bd72b42af42..b96f7fc4bb21 100644 --- a/clang/Analysis/LiveVariables.cpp +++ b/clang/Analysis/LiveVariables.cpp @@ -77,10 +77,9 @@ void TransferFuncs::Visit(Stmt *S) { if (AD.Observer) AD.Observer->ObserveStmt(S,AD,LiveState); - if (S == getCurrentBlkStmt()) { - StmtVisitor::Visit(S); if (getCFG().isBlkExpr(S)) LiveState(S,AD) = Dead; + StmtVisitor::Visit(S); } else if (!getCFG().isBlkExpr(S)) StmtVisitor::Visit(S); @@ -199,6 +198,10 @@ bool LiveVariables::isLive(const Stmt* Loc, const Stmt* StmtVal) const { return getStmtData(Loc)(StmtVal,getAnalysisData()); } +bool LiveVariables::isLive(const Stmt* Loc, const VarDecl* D) const { + return getStmtData(Loc)(D,getAnalysisData()); +} + //===----------------------------------------------------------------------===// // printing liveness state for debugging //