From: Ted Kremenek Date: Thu, 24 Jan 2008 19:00:57 +0000 (+0000) Subject: Minor tweaks in the transfer functions for pre- and post- ++/-- where X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0cf9c85fe0c02f82a3e7bb65a2d3085548398c3;p=clang Minor tweaks in the transfer functions for pre- and post- ++/-- where we falsely constructed an APInt to represent the constant '1' instead of using an APSInt (which has a sign). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46317 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/GRConstants.cpp b/Analysis/GRConstants.cpp index 2d1ba56f7e..35758c672e 100644 --- a/Analysis/GRConstants.cpp +++ b/Analysis/GRConstants.cpp @@ -829,9 +829,10 @@ void GRConstants::VisitUnaryOperator(UnaryOperator* U, RValue R1 = cast(GetValue(St, L1)); QualType T = U->getType(); - llvm::APInt One(getContext()->getTypeSize(T,U->getLocStart()), 1); - RValue R2 = RValue::GetRValue(ValMgr, One); - + unsigned bits = getContext()->getTypeSize(T, U->getLocStart()); + llvm::APSInt One(llvm::APInt(bits, 1), T->isUnsignedIntegerType()); + RValue R2 = RValue::GetRValue(ValMgr, One); + RValue Result = R1.EvalAdd(ValMgr, R2); Nodify(Dst, U, N1, SetValue(SetValue(St, U, R1), L1, Result)); break; @@ -842,8 +843,9 @@ void GRConstants::VisitUnaryOperator(UnaryOperator* U, RValue R1 = cast(GetValue(St, L1)); QualType T = U->getType(); - llvm::APInt One(getContext()->getTypeSize(T,U->getLocStart()), 1); - RValue R2 = RValue::GetRValue(ValMgr, One); + unsigned bits = getContext()->getTypeSize(T, U->getLocStart()); + llvm::APSInt One(llvm::APInt(bits, 1), T->isUnsignedIntegerType()); + RValue R2 = RValue::GetRValue(ValMgr, One); RValue Result = R1.EvalSub(ValMgr, R2); Nodify(Dst, U, N1, SetValue(SetValue(St, U, R1), L1, Result)); @@ -855,7 +857,8 @@ void GRConstants::VisitUnaryOperator(UnaryOperator* U, RValue R1 = cast(GetValue(St, L1)); QualType T = U->getType(); - llvm::APInt One(getContext()->getTypeSize(T,U->getLocStart()), 1); + unsigned bits = getContext()->getTypeSize(T, U->getLocStart()); + llvm::APSInt One(llvm::APInt(bits, 1), T->isUnsignedIntegerType()); RValue R2 = RValue::GetRValue(ValMgr, One); RValue Result = R1.EvalAdd(ValMgr, R2); @@ -868,8 +871,9 @@ void GRConstants::VisitUnaryOperator(UnaryOperator* U, RValue R1 = cast(GetValue(St, L1)); QualType T = U->getType(); - llvm::APInt One(getContext()->getTypeSize(T,U->getLocStart()), 1); - RValue R2 = RValue::GetRValue(ValMgr, One); + unsigned bits = getContext()->getTypeSize(T, U->getLocStart()); + llvm::APSInt One(llvm::APInt(bits, 1), T->isUnsignedIntegerType()); + RValue R2 = RValue::GetRValue(ValMgr, One); RValue Result = R1.EvalSub(ValMgr, R2); Nodify(Dst, U, N1, SetValue(SetValue(St, U, Result), L1, Result));