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/CodeGen/CGExprCXX.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/CodeGen/CGExprCXX.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprCXX.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 87e9cc89e0a..9cd3bdd70eb 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -407,7 +407,7 @@ static llvm::Value *EmitCXXNewAllocSize(ASTContext &Context, unsigned SizeWidth = NEC.getBitWidth(); // Determine if there is an overflow here by doing an extended multiply. - NEC.zext(SizeWidth*2); + NEC = NEC.zext(SizeWidth*2); llvm::APInt SC(SizeWidth*2, TypeSize.getQuantity()); SC *= NEC; @@ -416,8 +416,7 @@ static llvm::Value *EmitCXXNewAllocSize(ASTContext &Context, // overflow's already happened because SizeWithoutCookie isn't // used if the allocator returns null or throws, as it should // always do on an overflow. - llvm::APInt SWC = SC; - SWC.trunc(SizeWidth); + llvm::APInt SWC = SC.trunc(SizeWidth); SizeWithoutCookie = llvm::ConstantInt::get(SizeTy, SWC); // Add the cookie size. @@ -425,7 +424,7 @@ static llvm::Value *EmitCXXNewAllocSize(ASTContext &Context, } if (SC.countLeadingZeros() >= SizeWidth) { - SC.trunc(SizeWidth); + SC = SC.trunc(SizeWidth); Size = llvm::ConstantInt::get(SizeTy, SC); } else { // On overflow, produce a -1 so operator new throws. |