summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-04-15 03:47:30 +0000
committerTed Kremenek <kremenek@apple.com>2008-04-15 03:47:30 +0000
commitf4212bdbc326a9ca9cee070969092a8b03d92fe2 (patch)
tree1c37bdb1f7a802c0b14ba2b9239b7351c82865b0 /clang/lib/Analysis
parent52bc4ac84f47d91863662a5ebd04e01b5704f20c (diff)
downloadbcm5719-llvm-f4212bdbc326a9ca9cee070969092a8b03d92fe2.tar.gz
bcm5719-llvm-f4212bdbc326a9ca9cee070969092a8b03d92fe2.zip
Bug fix in LiveVariables: Operators ++/-- may kill a value, but the variable
is still live. llvm-svn: 49705
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/LiveVariables.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Analysis/LiveVariables.cpp b/clang/lib/Analysis/LiveVariables.cpp
index acc13dead85..06f30fa4fdd 100644
--- a/clang/lib/Analysis/LiveVariables.cpp
+++ b/clang/lib/Analysis/LiveVariables.cpp
@@ -110,14 +110,13 @@ void TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
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 @@ void TransferFuncs::VisitAssign(BinaryOperator* B) {
// 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 @@ void TransferFuncs::VisitDeclStmt(DeclStmt* DS) {
// 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);
OpenPOWER on IntegriCloud