From 3f916501c91d3f6f37b1d43276c440343f9454f6 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 10 Mar 2008 15:17:11 +0000 Subject: [PATCH] Add transfer function support for pointer arithmetic where the 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h index 4cf9f2042f..ad592b7477 100644 --- a/include/clang/Analysis/PathSensitive/GRExprEngine.h +++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h @@ -428,7 +428,17 @@ protected: return TF->EvalBinOp(BasicVals, Op, cast(L), cast(R)); } - return TF->EvalBinOp(BasicVals, Op, cast(L), cast(R)); + if (isa(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(R), cast(L)); + } + else + return TF->EvalBinOp(BasicVals, Op, cast(L), cast(R)); } void EvalCall(NodeSet& Dst, CallExpr* CE, LVal L, NodeTy* Pred) { -- 2.40.0