]> granicus.if.org Git - clang/commitdiff
If the unary operator is prefix and an lvalue (in C++), bind
authorZhongxing Xu <xuzhongxing@gmail.com>
Wed, 22 Dec 2010 08:38:13 +0000 (08:38 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Wed, 22 Dec 2010 08:38:13 +0000 (08:38 +0000)
the location (l-value) to it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122396 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Checker/GRExprEngine.cpp
test/Analysis/misc-ps-region-store.cpp

index a24a5df4fb699b81f87f67f5ae30b7c3e8e75f92..41a89e7b39d9119892f82925e5d0c6017ea36ed5 100644 (file)
@@ -2918,11 +2918,11 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U,
   for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) {
 
     const GRState* state = GetState(*I);
-    SVal V1 = state->getSVal(Ex);
+    SVal loc = state->getSVal(Ex);
 
     // Perform a load.
     ExplodedNodeSet Tmp2;
-    evalLoad(Tmp2, Ex, *I, state, V1);
+    evalLoad(Tmp2, Ex, *I, state, loc);
 
     for (ExplodedNodeSet::iterator I2=Tmp2.begin(), E2=Tmp2.end();I2!=E2;++I2) {
 
@@ -2964,7 +2964,7 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U,
         // propagate that constraint.
         if (Loc::IsLocType(U->getType())) {
           DefinedOrUnknownSVal Constraint =
-            svalBuilder.evalEQ(state, V2, svalBuilder.makeZeroVal(U->getType()));
+            svalBuilder.evalEQ(state, V2,svalBuilder.makeZeroVal(U->getType()));
 
           if (!state->assume(Constraint, true)) {
             // It isn't feasible for the original value to be null.
@@ -2979,10 +2979,15 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U,
         }
       }
 
-      state = state->BindExpr(U, U->isPostfix() ? V2 : Result);
+      // Since the lvalue-to-rvalue conversion is explicit in the AST,
+      // we bind an l-value if the operator is prefix and an lvalue (in C++).
+      if (U->isPrefix() && U->isLValue())
+        state = state->BindExpr(U, loc);
+      else
+        state = state->BindExpr(U, V2);
 
       // Perform the store.
-      evalStore(Dst, NULL, U, *I2, state, V1, Result);
+      evalStore(Dst, NULL, U, *I2, state, loc, Result);
     }
   }
 }
index 6b90305a8953658ff31790e14f69fcf6d60026c4..e87fba41f9687c7e61632c17da169de3178a8333 100644 (file)
@@ -1,6 +1,5 @@
 // RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -verify -fblocks   -analyzer-opt-analyze-nested-blocks %s
-// XFAIL: *
 
 // Test basic handling of references.
 char &test1_aux();