diff options
author | Jay Foad <jay.foad@gmail.com> | 2010-12-07 08:25:34 +0000 |
---|---|---|
committer | Jay Foad <jay.foad@gmail.com> | 2010-12-07 08:25:34 +0000 |
commit | 9f71a8f4c7a182a5236da9e747d57cc1d1bd24c2 (patch) | |
tree | de2e74ed442ebccd54b82089e7953960c93a27ec /lib/AST/ExprConstant.cpp | |
parent | dd182ff10b9145e432dea1fd2fb67100ccca3b10 (diff) |
PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121121 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 7479d9d9be..459981886e 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -220,7 +220,7 @@ static APSInt HandleIntToIntCast(QualType DestType, QualType SrcType, APSInt Result = Value; // Figure out if this is a truncate, extend or noop cast. // If the input is signed, do a sign extend, noop, or truncate. - Result.extOrTrunc(DestWidth); + Result = Result.extOrTrunc(DestWidth); Result.setIsUnsigned(DestType->isUnsignedIntegerType()); return Result; } @@ -587,7 +587,7 @@ bool PointerExprEvaluator::VisitCastExpr(CastExpr* E) { break; if (Value.isInt()) { - Value.getInt().extOrTrunc((unsigned)Info.Ctx.getTypeSize(E->getType())); + Value.getInt() = Value.getInt().extOrTrunc((unsigned)Info.Ctx.getTypeSize(E->getType())); Result.Base = 0; Result.Offset = CharUnits::fromQuantity(Value.getInt().getZExtValue()); return true; @@ -731,8 +731,7 @@ APValue VectorExprEvaluator::VisitCastExpr(const CastExpr* E) { llvm::SmallVector<APValue, 4> Elts; for (unsigned i = 0; i != NElts; ++i) { - APSInt Tmp = Init; - Tmp.extOrTrunc(EltWidth); + APSInt Tmp = Init.extOrTrunc(EltWidth); if (EltTy->isIntegerType()) Elts.push_back(APValue(Tmp)); |