From: Ted Kremenek Date: Wed, 23 Jan 2008 23:38:00 +0000 (+0000) Subject: Implemented value tracking support for '+=' and '-='. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b4ae33fe42ff0605cca15c5657bbdf063ef8f9be;p=clang Implemented value tracking support for '+=' and '-='. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46288 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/GRConstants.cpp b/Analysis/GRConstants.cpp index 84a8f048a8..84cc200d11 100644 --- a/Analysis/GRConstants.cpp +++ b/Analysis/GRConstants.cpp @@ -664,7 +664,6 @@ void GRConstants::VisitBinaryOperator(BinaryOperator* B, case BinaryOperator::Sub: { const RValue& R1 = cast(V1); const RValue& R2 = cast(V2); - Nodify(Dst, B, N2, SetValue(St, B, R1.Sub(ValMgr, R2))); break; } @@ -672,10 +671,25 @@ void GRConstants::VisitBinaryOperator(BinaryOperator* B, case BinaryOperator::Assign: { const LValue& L1 = cast(V1); const RValue& R2 = cast(V2); - Nodify(Dst, B, N2, SetValue(SetValue(St, B, R2), L1, R2)); break; } + + case BinaryOperator::AddAssign: { + const LValue& L1 = cast(V1); + RValue R1 = cast(GetValue(N1->getState(), L1)); + RValue Result = R1.Add(ValMgr, cast(V2)); + Nodify(Dst, B, N2, SetValue(SetValue(St, B, Result), L1, Result)); + break; + } + + case BinaryOperator::SubAssign: { + const LValue& L1 = cast(V1); + RValue R1 = cast(GetValue(N1->getState(), L1)); + RValue Result = R1.Sub(ValMgr, cast(V2)); + Nodify(Dst, B, N2, SetValue(SetValue(St, B, Result), L1, Result)); + break; + } default: Dst.Add(N2); @@ -700,6 +714,7 @@ void GRConstants::Visit(Stmt* S, GRConstants::NodeTy* Pred, switch (S->getStmtClass()) { case Stmt::BinaryOperatorClass: + case Stmt::CompoundAssignOperatorClass: VisitBinaryOperator(cast(S), Pred, Dst); break;