[cfe-commits] r49705 - /cfe/trunk/lib/Analysis/LiveVariables.cpp
Ted Kremenek
kremenek at apple.com
Mon Apr 14 20:47:31 PDT 2008
Author: kremenek
Date: Mon Apr 14 22:47:30 2008
New Revision: 49705
URL: http://llvm.org/viewvc/llvm-project?rev=49705&view=rev
Log:
Bug fix in LiveVariables: Operators ++/-- may kill a value, but the variable
is still live.
Modified:
cfe/trunk/lib/Analysis/LiveVariables.cpp
Modified: cfe/trunk/lib/Analysis/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/LiveVariables.cpp?rev=49705&r1=49704&r2=49705&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp Mon Apr 14 22:47:30 2008
@@ -110,14 +110,13 @@
case UnaryOperator::PostDec:
case UnaryOperator::PreInc:
case UnaryOperator::PreDec:
- case UnaryOperator::AddrOf:
// Walk through the subexpressions, blasting through ParenExprs
// until we either find a DeclRefExpr or some non-DeclRefExpr
// expression.
if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(E->IgnoreParens()))
- if (VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl())) {
- // Treat the --/++/& operator as a kill.
- LiveState(VD, AD) = Dead;
+ if (isa<VarDecl>(DR->getDecl())) {
+ // Treat the --/++ operator as a kill. Note that the variable
+ // is still live, just its value has been changed.
if (AD.Observer) { AD.Observer->ObserverKill(DR); }
return VisitDeclRefExpr(DR);
}
@@ -134,7 +133,7 @@
// Assigning to a variable?
if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(LHS->IgnoreParens())) {
- LiveState(DR->getDecl(),AD) = Dead;
+ LiveState(DR->getDecl(), AD) = Dead;
if (AD.Observer) { AD.Observer->ObserverKill(DR); }
// Handle things like +=, etc., which also generate "uses"
@@ -153,7 +152,7 @@
// possibly be live before they are declared.
for (ScopedDecl* D = DS->getDecl(); D != NULL; D = D->getNextDeclarator())
if (VarDecl* VD = dyn_cast<VarDecl>(D)) {
- LiveState(D,AD) = Dead;
+ LiveState(D, AD) = Dead;
if (Expr* Init = VD->getInit())
Visit(Init);
More information about the cfe-commits
mailing list