]> granicus.if.org Git - clang/commitdiff
Don't flag dead stores when the result of a preincrement/predecrement is used in...
authorTed Kremenek <kremenek@apple.com>
Wed, 23 Jul 2008 22:19:56 +0000 (22:19 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 23 Jul 2008 22:19:56 +0000 (22:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53964 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CheckDeadStores.cpp

index 005c71a5806487224152918ad2e84f615a3e18ef..433e61154f9c7d9d40d0fe47302480f1dc569932 100644 (file)
@@ -153,6 +153,11 @@ public:
       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 @@ public:
     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;