[cfe-commits] r123158 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/ExprEngine.cpp test/Analysis/lvalue.cpp

Zhongxing Xu xuzhongxing at gmail.com
Sun Jan 9 19:54:20 PST 2011


Author: zhongxingxu
Date: Sun Jan  9 21:54:19 2011
New Revision: 123158

URL: http://llvm.org/viewvc/llvm-project?rev=123158&view=rev
Log:
In C++, assignment and compound assignment operators return an lvalue.

Added:
    cfe/trunk/test/Analysis/lvalue.cpp
Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp?rev=123158&r1=123157&r2=123158&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp Sun Jan  9 21:54:19 2011
@@ -3241,8 +3241,14 @@
           LHSVal = svalBuilder.evalCast(Result, LTy, CTy);
         }
 
-        evalStore(Tmp3, B, LHS, *I4, state->BindExpr(B, Result),
-                  location, LHSVal);
+        // In C++, assignment and compound assignment operators return an 
+        // lvalue.
+        if (B->isLValue())
+          state = state->BindExpr(B, location);
+        else
+          state = state->BindExpr(B, Result);
+
+        evalStore(Tmp3, B, LHS, *I4, state, location, LHSVal);
       }
     }
   }

Added: cfe/trunk/test/Analysis/lvalue.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lvalue.cpp?rev=123158&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/lvalue.cpp (added)
+++ cfe/trunk/test/Analysis/lvalue.cpp Sun Jan  9 21:54:19 2011
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -verify %s
+
+int f1() {
+  int x = 0, y = 1;
+  return x += y; // Should bind a location to 'x += y'. No crash.
+}





More information about the cfe-commits mailing list