From bd9cc5ca890d6d18eaaca1b78a0465b668e9a7dd Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 10 Sep 2007 17:36:42 +0000 Subject: Fixed LiveVariables to no longer track the liveness of function pointers that refer to direct function calls. Modified interface of LiveVariables to only track liveness of VarDecls. This cleans up a bunch of edge cases, and removed the bug just mentioned. llvm-svn: 41797 --- clang/Analysis/DeadStores.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'clang/Analysis/DeadStores.cpp') diff --git a/clang/Analysis/DeadStores.cpp b/clang/Analysis/DeadStores.cpp index 4073eccf60b..e0922eede94 100644 --- a/clang/Analysis/DeadStores.cpp +++ b/clang/Analysis/DeadStores.cpp @@ -36,29 +36,28 @@ public: return; // Is this an assignment to a variable? - if (DeclRefExpr* DR = dyn_cast(B->getLHS())) { + if (DeclRefExpr* DR = dyn_cast(B->getLHS())) // Is the variable live? - if (!L.isLive(Live,DR->getDecl())) { + if (!L.isLive(Live,cast(DR->getDecl()))) { SourceRange R = B->getRHS()->getSourceRange(); PP.getDiagnostics().Report(DR->getSourceRange().Begin(), diag::warn_dead_store, 0, 0, &R,1); } - } } else if(DeclStmt* DS = dyn_cast(S)) { // Iterate through the decls. Warn if any of them (which have // initializers) are not live. - for (Decl* D = DS->getDecl() ; D != NULL ; D = D->getNextDeclarator()) - if (VarDecl* V = dyn_cast(D)) - if (Expr* E = V->getInit()) - if (!L.isLive(Live,D)) { - SourceRange R = E->getSourceRange(); - PP.getDiagnostics().Report(D->getLocation(), - diag::warn_dead_store, 0, 0, - &R,1); - } + for (VarDecl* V = cast(DS->getDecl()); V != NULL ; + V = cast(V->getNextDeclarator())) + if (Expr* E = V->getInit()) + if (!L.isLive(Live,V)) { + SourceRange R = E->getSourceRange(); + PP.getDiagnostics().Report(V->getLocation(), + diag::warn_dead_store, 0, 0, + &R,1); + } } } }; -- cgit v1.2.3