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/CodeGen/CGExprCXX.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/CodeGen/CGExprCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGExprCXX.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index 87e9cc89e0..9cd3bdd70e 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/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. |