diff options
| author | Ted Kremenek <kremenek@apple.com> | 2007-09-10 17:36:42 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2007-09-10 17:36:42 +0000 |
| commit | bd9cc5ca890d6d18eaaca1b78a0465b668e9a7dd (patch) | |
| tree | 343dc5c78284495b1a3f2565cd4a60b24cc73363 /clang/Analysis/DeadStores.cpp | |
| parent | 5f64ca8ec59dcd0320bc56481562fdb8f0363b7a (diff) | |
| download | bcm5719-llvm-bd9cc5ca890d6d18eaaca1b78a0465b668e9a7dd.tar.gz bcm5719-llvm-bd9cc5ca890d6d18eaaca1b78a0465b668e9a7dd.zip | |
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
Diffstat (limited to 'clang/Analysis/DeadStores.cpp')
| -rw-r--r-- | clang/Analysis/DeadStores.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
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<DeclRefExpr>(B->getLHS())) { + if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(B->getLHS())) // Is the variable live? - if (!L.isLive(Live,DR->getDecl())) { + if (!L.isLive(Live,cast<VarDecl>(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<DeclStmt>(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<VarDecl>(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<VarDecl>(DS->getDecl()); V != NULL ; + V = cast<VarDecl>(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); + } } } }; |

