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/Sema/SemaStmt.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/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index e405e6bdf2..cac70ca7a8 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -330,7 +330,7 @@ void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val, // Perform a conversion to the promoted condition type if needed. if (NewWidth > Val.getBitWidth()) { // If this is an extension, just do it. - Val.extend(NewWidth); + Val = Val.extend(NewWidth); Val.setIsSigned(NewSign); // If the input was signed and negative and the output is @@ -340,16 +340,16 @@ void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val, } else if (NewWidth < Val.getBitWidth()) { // If this is a truncation, check for overflow. llvm::APSInt ConvVal(Val); - ConvVal.trunc(NewWidth); + ConvVal = ConvVal.trunc(NewWidth); ConvVal.setIsSigned(NewSign); - ConvVal.extend(Val.getBitWidth()); + ConvVal = ConvVal.extend(Val.getBitWidth()); ConvVal.setIsSigned(Val.isSigned()); if (ConvVal != Val) Diag(Loc, DiagID) << Val.toString(10) << ConvVal.toString(10); // Regardless of whether a diagnostic was emitted, really do the // truncation. - Val.trunc(NewWidth); + Val = Val.trunc(NewWidth); Val.setIsSigned(NewSign); } else if (NewSign != Val.isSigned()) { // Convert the sign to match the sign of the condition. This can cause @@ -470,9 +470,9 @@ Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond, static void AdjustAPSInt(llvm::APSInt &Val, unsigned BitWidth, bool IsSigned) { if (Val.getBitWidth() < BitWidth) - Val.extend(BitWidth); + Val = Val.extend(BitWidth); else if (Val.getBitWidth() > BitWidth) - Val.trunc(BitWidth); + Val = Val.trunc(BitWidth); Val.setIsSigned(IsSigned); } |