[cfe-commits] r131770 - in /cfe/trunk: lib/StaticAnalyzer/Core/ExprEngine.cpp test/Analysis/misc-ps-region-store.m
Ted Kremenek
kremenek at apple.com
Fri May 20 16:40:07 PDT 2011
Author: kremenek
Date: Fri May 20 18:40:06 2011
New Revision: 131770
URL: http://llvm.org/viewvc/llvm-project?rev=131770&view=rev
Log:
Fix regression in static analyzer's handling of prefix '--' operator. It was being treated as postfix '--' in C mode.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/misc-ps-region-store.m
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=131770&r1=131769&r2=131770&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri May 20 18:40:06 2011
@@ -2703,7 +2703,7 @@
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);
Modified: cfe/trunk/test/Analysis/misc-ps-region-store.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-region-store.m?rev=131770&r1=131769&r2=131770&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-region-store.m (original)
+++ cfe/trunk/test/Analysis/misc-ps-region-store.m Fri May 20 18:40:06 2011
@@ -1299,3 +1299,27 @@
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';
+}
+
More information about the cfe-commits
mailing list