[cfe-commits] r53964 - /cfe/trunk/lib/Analysis/CheckDeadStores.cpp

Ted Kremenek kremenek at apple.com
Wed Jul 23 15:19:56 PDT 2008


Author: kremenek
Date: Wed Jul 23 17:19:56 2008
New Revision: 53964

URL: http://llvm.org/viewvc/llvm-project?rev=53964&view=rev
Log:
Don't flag dead stores when the result of a preincrement/predecrement is used in an enclosing expression.

Modified:
    cfe/trunk/lib/Analysis/CheckDeadStores.cpp

Modified: cfe/trunk/lib/Analysis/CheckDeadStores.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckDeadStores.cpp?rev=53964&r1=53963&r2=53964&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CheckDeadStores.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckDeadStores.cpp Wed Jul 23 17:19:56 2008
@@ -153,6 +153,11 @@
       if (!U->isIncrementOp())
         return;
       
+      // Don't flag dead stores when the result of a preincrement/predecrement
+      // is used in an enclosing expression.
+      if (U->isPrefix() && Parents.isSubExpr(U))
+        return;
+      
       Expr *Ex = U->getSubExpr()->IgnoreParenCasts();
       
       if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(Ex))
@@ -161,7 +166,7 @@
     else if (DeclStmt* DS = dyn_cast<DeclStmt>(S))
       // Iterate through the decls.  Warn if any initializers are complex
       // expressions that are not live (never used).
-      for (ScopedDecl* SD = DS->getDecl(); SD; SD = SD->getNextDeclarator()) {        
+      for (ScopedDecl* SD = DS->getDecl(); SD; SD = SD->getNextDeclarator()) {
         
         VarDecl* V = dyn_cast<VarDecl>(SD);
         if (!V) continue;





More information about the cfe-commits mailing list