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 | 6d4db0c8850543661493af107a1d601d12a89509 (patch) | |
tree | 8d09f8cde8e18587dc50e42150992071c57f9e43 /clang/lib/Sema/SemaStmt.cpp | |
parent | 583abbc4df3d9b9e5a86a56ae581970b98dc5249 (diff) | |
download | bcm5719-llvm-6d4db0c8850543661493af107a1d601d12a89509.tar.gz bcm5719-llvm-6d4db0c8850543661493af107a1d601d12a89509.zip |
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.
llvm-svn: 121121
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index e405e6bdf21..cac70ca7a85 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/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); } |