diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-05-20 23:40:06 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-05-20 23:40:06 +0000 |
commit | ce30688b8aa0effd70a7a69a4d1e3d6a2a86efcd (patch) | |
tree | d62c8e5de8d82eee0c42410a53eb171045f7f841 | |
parent | e3406826db726960ede77dd18361eb327d30c108 (diff) |
Fix regression in static analyzer's handling of prefix '--' operator. It was being treated as postfix '--' in C mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131770 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/StaticAnalyzer/Core/ExprEngine.cpp | 2 | ||||
-rw-r--r-- | test/Analysis/misc-ps-region-store.m | 24 |
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp index 60b16abd19..4b7d999bd4 100644 --- a/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -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); diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m index be0356d176..27f12c9a89 100644 --- a/test/Analysis/misc-ps-region-store.m +++ b/test/Analysis/misc-ps-region-store.m @@ -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'; +} + |