]> granicus.if.org Git - clang/commitdiff
Fix regression in static analyzer's handling of prefix '--' operator. It was being...
authorTed Kremenek <kremenek@apple.com>
Fri, 20 May 2011 23:40:06 +0000 (23:40 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 20 May 2011 23:40:06 +0000 (23:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131770 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/ExprEngine.cpp
test/Analysis/misc-ps-region-store.m

index 60b16abd196b234a815c9c43a38ef26028e340b6..4b7d999bd4a9e533a3944f4aec84743c335d6656 100644 (file)
@@ -2703,7 +2703,7 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U,
       if (U->isLValue())
         state = state->BindExpr(U, loc);
       else
-        state = state->BindExpr(U, V2);
+        state = state->BindExpr(U, U->isPostfix() ? V2 : Result);
 
       // Perform the store.
       evalStore(Dst, NULL, U, *I2, state, loc, Result);
index be0356d176b5fef6dec009a288b980dc9a2a13f1..27f12c9a893a1f4b01d69ccf1e013d90b934a091 100644 (file)
@@ -1299,3 +1299,27 @@ RDar9163742_Rect RDar9163742_IntegralRect(RDar9163742_Rect frame)
     return RDar9163742_RectIntegral(integralFrame); // no-warning; all fields initialized
 }
 
+// Test correct handling of prefix '--' operator.
+void rdar9444714() {
+  int   x;
+  char    str[ 32 ];
+  char    buf[ 32 ];
+  char *  dst;
+  char *  ptr;
+
+  x = 1234;
+  dst = str;
+  ptr = buf;
+  do
+  {
+    *ptr++ = (char)( '0' + ( x % 10 ) );
+    x /= 10;  
+  } while( x > 0 );
+
+  while( ptr > buf )
+  {
+    *dst++ = *( --( ptr ) ); // no-warning
+  }
+  *dst = '\0';
+}
+