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
diff --git a/clang/lib/Checker/SimpleSValBuilder.cpp b/clang/lib/Checker/SimpleSValBuilder.cpp
index 49d5535..6632c8e 100644
--- a/clang/lib/Checker/SimpleSValBuilder.cpp
+++ b/clang/lib/Checker/SimpleSValBuilder.cpp
@@ -97,7 +97,7 @@
 
   llvm::APSInt i = cast<nonloc::ConcreteInt>(val).getValue();
   i.setIsUnsigned(castTy->isUnsignedIntegerType() || Loc::IsLocType(castTy));
-  i.extOrTrunc(Context.getTypeSize(castTy));
+  i = i.extOrTrunc(Context.getTypeSize(castTy));
 
   if (isLocType)
     return makeIntLocVal(i);
@@ -129,7 +129,7 @@
 
     llvm::APSInt i = cast<loc::ConcreteInt>(val).getValue();
     i.setIsUnsigned(castTy->isUnsignedIntegerType() || Loc::IsLocType(castTy));
-    i.extOrTrunc(BitWidth);
+    i = i.extOrTrunc(BitWidth);
     return makeIntVal(i);
   }
 
@@ -306,7 +306,7 @@
           // Transform the integer into a location and compare.
           llvm::APSInt i = cast<nonloc::ConcreteInt>(rhs).getValue();
           i.setIsUnsigned(true);
-          i.extOrTrunc(Context.getTypeSize(Context.VoidPtrTy));
+          i = i.extOrTrunc(Context.getTypeSize(Context.VoidPtrTy));
           return evalBinOpLL(state, op, lhsL, makeLoc(i), resultTy);
         }
         default:
@@ -837,7 +837,7 @@
 
       // Convert the bitwidth of rightI.  This should deal with overflow
       // since we are dealing with concrete values.
-      rightI.extOrTrunc(leftI.getBitWidth());
+      rightI = rightI.extOrTrunc(leftI.getBitWidth());
 
       // Offset the increment by the pointer size.
       llvm::APSInt Multiplicand(rightI.getBitWidth(), /* isUnsigned */ true);