]> granicus.if.org Git - clang/commitdiff
Add transfer function support for pointer arithmetic where the
authorTed Kremenek <kremenek@apple.com>
Mon, 10 Mar 2008 15:17:11 +0000 (15:17 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 10 Mar 2008 15:17:11 +0000 (15:17 +0000)
increment/decrement operand is on the left side.

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

include/clang/Analysis/PathSensitive/GRExprEngine.h

index 4cf9f2042f13890d6628a5321d781ba5a57119af..ad592b74771bc5dcd535c7a956650e354ef8d6dc 100644 (file)
@@ -428,7 +428,17 @@ protected:
         return TF->EvalBinOp(BasicVals, Op, cast<LVal>(L), cast<NonLVal>(R));
     }
     
-    return TF->EvalBinOp(BasicVals, Op, cast<NonLVal>(L), cast<NonLVal>(R));
+    if (isa<LVal>(R)) {
+      // Support pointer arithmetic where the increment/decrement operand
+      // is on the left and the pointer on the right.
+      
+      assert (Op == BinaryOperator::Add || Op == BinaryOperator::Sub);
+
+      // Commute the operands.      
+      return TF->EvalBinOp(BasicVals, Op, cast<LVal>(R), cast<NonLVal>(L));
+    }
+    else
+      return TF->EvalBinOp(BasicVals, Op, cast<NonLVal>(L), cast<NonLVal>(R));
   }
   
   void EvalCall(NodeSet& Dst, CallExpr* CE, LVal L, NodeTy* Pred) {