From 7845b2607a662710d3e25359131d83151bf3e6b1 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 25 Feb 2008 22:28:54 +0000 Subject: [PATCH] Minor bug fix in LiveVariables: don't "kill" decls referenced by a DeclStmt that aren't VarDecls. llvm-svn: 47572 --- clang/Analysis/LiveVariables.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/Analysis/LiveVariables.cpp b/clang/Analysis/LiveVariables.cpp index 1201eb021d74..52f7f4d19bf9 100644 --- a/clang/Analysis/LiveVariables.cpp +++ b/clang/Analysis/LiveVariables.cpp @@ -156,13 +156,13 @@ void TransferFuncs::VisitAssign(BinaryOperator* B) { void TransferFuncs::VisitDeclStmt(DeclStmt* DS) { // Declarations effectively "kill" a variable since they cannot // possibly be live before they are declared. - for (ScopedDecl* D = DS->getDecl(); D != NULL; D = D->getNextDeclarator()) { - LiveState(D,AD) = Dead; - - if (VarDecl* VD = dyn_cast(D)) + for (ScopedDecl* D = DS->getDecl(); D != NULL; D = D->getNextDeclarator()) + if (VarDecl* VD = dyn_cast(D)) { + LiveState(D,AD) = Dead; + if (Expr* Init = VD->getInit()) Visit(Init); - } + } } } // end anonymous namespace