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 | |
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
-rw-r--r-- | lib/AST/ASTContext.cpp | 3 | ||||
-rw-r--r-- | lib/AST/ASTImporter.cpp | 8 | ||||
-rw-r--r-- | lib/AST/ExprConstant.cpp | 7 | ||||
-rw-r--r-- | lib/AST/Type.cpp | 3 | ||||
-rw-r--r-- | lib/Checker/SimpleConstraintManager.cpp | 4 | ||||
-rw-r--r-- | lib/Checker/SimpleSValBuilder.cpp | 8 | ||||
-rw-r--r-- | lib/CodeGen/CGExprCXX.cpp | 7 | ||||
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 28 | ||||
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 11 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 22 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 12 | ||||
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateDeduction.cpp | 4 |
16 files changed, 68 insertions, 69 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 9a8b153e26..d7dedc6169 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1422,7 +1422,8 @@ QualType ASTContext::getConstantArrayType(QualType EltTy, // Convert the array size into a canonical width matching the pointer size for // the target. llvm::APInt ArySize(ArySizeIn); - ArySize.zextOrTrunc(Target.getPointerWidth(EltTy.getAddressSpace())); + ArySize = + ArySize.zextOrTrunc(Target.getPointerWidth(EltTy.getAddressSpace())); llvm::FoldingSetNodeID ID; ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, EltTypeQuals); diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 13b89e1ac0..ffebbf349e 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -212,9 +212,9 @@ static bool IsSameValue(const llvm::APInt &I1, const llvm::APInt &I2) { return I1 == I2; if (I1.getBitWidth() > I2.getBitWidth()) - return I1 == llvm::APInt(I2).zext(I1.getBitWidth()); + return I1 == I2.zext(I1.getBitWidth()); - return llvm::APInt(I1).zext(I2.getBitWidth()) == I2; + return I1.zext(I2.getBitWidth()) == I2; } /// \brief Determine if two APSInts have the same value, zero- or sign-extending @@ -225,9 +225,9 @@ static bool IsSameValue(const llvm::APSInt &I1, const llvm::APSInt &I2) { // Check for a bit-width mismatch. if (I1.getBitWidth() > I2.getBitWidth()) - return IsSameValue(I1, llvm::APSInt(I2).extend(I1.getBitWidth())); + return IsSameValue(I1, I2.extend(I1.getBitWidth())); else if (I2.getBitWidth() > I1.getBitWidth()) - return IsSameValue(llvm::APSInt(I1).extend(I2.getBitWidth()), I2); + return IsSameValue(I1.extend(I2.getBitWidth()), I2); // We have a signedness mismatch. Turn the signed value into an unsigned // value. diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 7479d9d9be..459981886e 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -220,7 +220,7 @@ static APSInt HandleIntToIntCast(QualType DestType, QualType SrcType, APSInt Result = Value; // Figure out if this is a truncate, extend or noop cast. // If the input is signed, do a sign extend, noop, or truncate. - Result.extOrTrunc(DestWidth); + Result = Result.extOrTrunc(DestWidth); Result.setIsUnsigned(DestType->isUnsignedIntegerType()); return Result; } @@ -587,7 +587,7 @@ bool PointerExprEvaluator::VisitCastExpr(CastExpr* E) { break; if (Value.isInt()) { - Value.getInt().extOrTrunc((unsigned)Info.Ctx.getTypeSize(E->getType())); + Value.getInt() = Value.getInt().extOrTrunc((unsigned)Info.Ctx.getTypeSize(E->getType())); Result.Base = 0; Result.Offset = CharUnits::fromQuantity(Value.getInt().getZExtValue()); return true; @@ -731,8 +731,7 @@ APValue VectorExprEvaluator::VisitCastExpr(const CastExpr* E) { llvm::SmallVector<APValue, 4> Elts; for (unsigned i = 0; i != NElts; ++i) { - APSInt Tmp = Init; - Tmp.extOrTrunc(EltWidth); + APSInt Tmp = Init.extOrTrunc(EltWidth); if (EltTy->isIntegerType()) Elts.push_back(APValue(Tmp)); diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index cdcaa52717..489f766d04 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -41,7 +41,8 @@ unsigned ConstantArrayType::getNumAddressingBits(ASTContext &Context, const llvm::APInt &NumElements) { llvm::APSInt SizeExtended(NumElements, true); unsigned SizeTypeBits = Context.getTypeSize(Context.getSizeType()); - SizeExtended.extend(std::max(SizeTypeBits, SizeExtended.getBitWidth()) * 2); + SizeExtended = SizeExtended.extend(std::max(SizeTypeBits, + SizeExtended.getBitWidth()) * 2); uint64_t ElementSize = Context.getTypeSizeInChars(ElementType).getQuantity(); diff --git a/lib/Checker/SimpleConstraintManager.cpp b/lib/Checker/SimpleConstraintManager.cpp index c23c749aa3..9799aa8f96 100644 --- a/lib/Checker/SimpleConstraintManager.cpp +++ b/lib/Checker/SimpleConstraintManager.cpp @@ -265,11 +265,11 @@ const GRState *SimpleConstraintManager::assumeSymRel(const GRState *state, // Convert the adjustment. Adjustment.setIsUnsigned(isSymUnsigned); - Adjustment.extOrTrunc(bitwidth); + Adjustment = Adjustment.extOrTrunc(bitwidth); // Convert the right-hand side integer. llvm::APSInt ConvertedInt(Int, isSymUnsigned); - ConvertedInt.extOrTrunc(bitwidth); + ConvertedInt = ConvertedInt.extOrTrunc(bitwidth); switch (op) { default: diff --git a/lib/Checker/SimpleSValBuilder.cpp b/lib/Checker/SimpleSValBuilder.cpp index 49d55355ad..6632c8eb1a 100644 --- a/lib/Checker/SimpleSValBuilder.cpp +++ b/lib/Checker/SimpleSValBuilder.cpp @@ -97,7 +97,7 @@ SVal SimpleSValBuilder::evalCastNL(NonLoc val, QualType castTy) { 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 @@ SVal SimpleSValBuilder::evalCastL(Loc val, QualType castTy) { 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 @@ SVal SimpleSValBuilder::evalBinOpNN(const GRState *state, // 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 @@ SVal SimpleSValBuilder::evalBinOpLN(const GRState *state, // 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); 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. diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 9002253e72..51b1de37a9 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -142,11 +142,11 @@ void ConstStructBuilder::AppendBitField(const FieldDecl *Field, // constants are cast to bool, and because clang is not enforcing bitfield // width limits. if (FieldSize > FieldValue.getBitWidth()) - FieldValue.zext(FieldSize); + FieldValue = FieldValue.zext(FieldSize); // Truncate the size of FieldValue to the bit field size. if (FieldSize < FieldValue.getBitWidth()) - FieldValue.trunc(FieldSize); + FieldValue = FieldValue.trunc(FieldSize); if (FieldOffset < NextFieldOffsetInBytes * 8) { // Either part of the field or the entire field can go into the previous @@ -166,20 +166,20 @@ void ConstStructBuilder::AppendBitField(const FieldDecl *Field, if (CGM.getTargetData().isBigEndian()) { Tmp = Tmp.lshr(NewFieldWidth); - Tmp.trunc(BitsInPreviousByte); + Tmp = Tmp.trunc(BitsInPreviousByte); // We want the remaining high bits. - FieldValue.trunc(NewFieldWidth); + FieldValue = FieldValue.trunc(NewFieldWidth); } else { - Tmp.trunc(BitsInPreviousByte); + Tmp = Tmp.trunc(BitsInPreviousByte); // We want the remaining low bits. FieldValue = FieldValue.lshr(BitsInPreviousByte); - FieldValue.trunc(NewFieldWidth); + FieldValue = FieldValue.trunc(NewFieldWidth); } } - Tmp.zext(8); + Tmp = Tmp.zext(8); if (CGM.getTargetData().isBigEndian()) { if (FitsCompletelyInPreviousByte) Tmp = Tmp.shl(BitsInPreviousByte - FieldValue.getBitWidth()); @@ -231,13 +231,10 @@ void ConstStructBuilder::AppendBitField(const FieldDecl *Field, if (CGM.getTargetData().isBigEndian()) { // We want the high bits. - Tmp = FieldValue; - Tmp = Tmp.lshr(Tmp.getBitWidth() - 8); - Tmp.trunc(8); + Tmp = FieldValue.lshr(Tmp.getBitWidth() - 8).trunc(8); } else { // We want the low bits. - Tmp = FieldValue; - Tmp.trunc(8); + Tmp = FieldValue.trunc(8); FieldValue = FieldValue.lshr(8); } @@ -245,7 +242,7 @@ void ConstStructBuilder::AppendBitField(const FieldDecl *Field, Elements.push_back(llvm::ConstantInt::get(CGM.getLLVMContext(), Tmp)); NextFieldOffsetInBytes++; - FieldValue.trunc(FieldValue.getBitWidth() - 8); + FieldValue = FieldValue.trunc(FieldValue.getBitWidth() - 8); } assert(FieldValue.getBitWidth() > 0 && @@ -257,10 +254,9 @@ void ConstStructBuilder::AppendBitField(const FieldDecl *Field, if (CGM.getTargetData().isBigEndian()) { unsigned BitWidth = FieldValue.getBitWidth(); - FieldValue.zext(8); - FieldValue = FieldValue << (8 - BitWidth); + FieldValue = FieldValue.zext(8) << (8 - BitWidth); } else - FieldValue.zext(8); + FieldValue = FieldValue.zext(8); } // Append the last element. diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index d6aa4ce885..f53086e33c 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -2243,7 +2243,7 @@ IntRange GetValueRange(ASTContext &C, llvm::APSInt &value, unsigned MaxWidth) { return IntRange(value.getMinSignedBits(), false); if (value.getBitWidth() > MaxWidth) - value.trunc(MaxWidth); + value = value.trunc(MaxWidth); // isNonNegative() just checks the sign bit without considering // signedness. @@ -2656,16 +2656,15 @@ bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, if (OriginalWidth <= FieldWidth) return false; - llvm::APSInt TruncatedValue = Value; - TruncatedValue.trunc(FieldWidth); + llvm::APSInt TruncatedValue = Value.trunc(FieldWidth); // It's fairly common to write values into signed bitfields // that, if sign-extended, would end up becoming a different // value. We don't want to warn about that. if (Value.isSigned() && Value.isNegative()) - TruncatedValue.sext(OriginalWidth); + TruncatedValue = TruncatedValue.sext(OriginalWidth); else - TruncatedValue.zext(OriginalWidth); + TruncatedValue = TruncatedValue.zext(OriginalWidth); if (Value == TruncatedValue) return false; @@ -2712,7 +2711,7 @@ std::string PrettyPrintInRange(const llvm::APSInt &Value, IntRange Range) { llvm::APSInt ValueInRange = Value; ValueInRange.setIsSigned(!Range.NonNegative); - ValueInRange.trunc(Range.Width); + ValueInRange = ValueInRange.trunc(Range.Width); return ValueInRange.toString(10); } diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 88512af8b3..2924c7b8d6 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -7355,7 +7355,7 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum, // There is no integral type larger enough to represent this // value. Complain, then allow the value to wrap around. EnumVal = LastEnumConst->getInitVal(); - EnumVal.zext(EnumVal.getBitWidth() * 2); + EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2); ++EnumVal; if (Enum->isFixed()) // When the underlying type is fixed, this is ill-formed. @@ -7374,7 +7374,7 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum, // value, then increment. EnumVal = LastEnumConst->getInitVal(); EnumVal.setIsSigned(EltTy->isSignedIntegerType()); - EnumVal.zextOrTrunc(Context.getIntWidth(EltTy)); + EnumVal = EnumVal.zextOrTrunc(Context.getIntWidth(EltTy)); ++EnumVal; // If we're not in C++, diagnose the overflow of enumerator values, @@ -7396,7 +7396,7 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum, if (!EltTy->isDependentType()) { // Make the enumerator value match the signedness and size of the // enumerator's type. - EnumVal.zextOrTrunc(Context.getIntWidth(EltTy)); + EnumVal = EnumVal.zextOrTrunc(Context.getIntWidth(EltTy)); EnumVal.setIsSigned(EltTy->isSignedIntegerType()); } @@ -7659,7 +7659,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, } // Adjust the APSInt value. - InitVal.extOrTrunc(NewWidth); + InitVal = InitVal.extOrTrunc(NewWidth); InitVal.setIsSigned(NewSign); ECD->setInitVal(InitVal); diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 781d2b83e0..bf9e935981 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -4628,8 +4628,8 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, Stmt *InitStmt = new (S.Context) DeclStmt(DeclGroupRef(IterationVar),Loc,Loc); // Create the comparison against the array bound. - llvm::APInt Upper = ArrayTy->getSize(); - Upper.zextOrTrunc(S.Context.getTypeSize(SizeType)); + llvm::APInt Upper + = ArrayTy->getSize().zextOrTrunc(S.Context.getTypeSize(SizeType)); Expr *Comparison = new (S.Context) BinaryOperator(IterationVarRef, IntegerLiteral::Create(S.Context, Upper, SizeType, Loc), @@ -5021,8 +5021,8 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation, = Context.getAsConstantArrayType(FieldType); Array; Array = Context.getAsConstantArrayType(Array->getElementType())) { - llvm::APInt ArraySize = Array->getSize(); - ArraySize.zextOrTrunc(Size.getBitWidth()); + llvm::APInt ArraySize + = Array->getSize().zextOrTrunc(Size.getBitWidth()); Size *= ArraySize; } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 9038750591..c9e7f2733a 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2508,7 +2508,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok) { } if (ResultVal.getBitWidth() != Width) - ResultVal.trunc(Width); + ResultVal = ResultVal.trunc(Width); } Res = IntegerLiteral::Create(Context, ResultVal, Ty, Tok.getLocation()); } diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 7c4bd4a82e..6595927caf 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -972,7 +972,7 @@ void InitListChecker::CheckArrayType(const InitializedEntity &Entity, if (const ConstantArrayType *CAT = SemaRef.Context.getAsConstantArrayType(DeclType)) { maxElements = CAT->getSize(); - elementIndex.extOrTrunc(maxElements.getBitWidth()); + elementIndex = elementIndex.extOrTrunc(maxElements.getBitWidth()); elementIndex.setIsUnsigned(maxElements.isUnsigned()); maxElementsKnown = true; } @@ -999,9 +999,9 @@ void InitListChecker::CheckArrayType(const InitializedEntity &Entity, } if (elementIndex.getBitWidth() > maxElements.getBitWidth()) - maxElements.extend(elementIndex.getBitWidth()); + maxElements = maxElements.extend(elementIndex.getBitWidth()); else if (elementIndex.getBitWidth() < maxElements.getBitWidth()) - elementIndex.extend(maxElements.getBitWidth()); + elementIndex = elementIndex.extend(maxElements.getBitWidth()); elementIndex.setIsUnsigned(maxElements.isUnsigned()); // If the array is of incomplete type, keep track of the number of @@ -1641,9 +1641,11 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, if (isa<ConstantArrayType>(AT)) { llvm::APSInt MaxElements(cast<ConstantArrayType>(AT)->getSize(), false); - DesignatedStartIndex.extOrTrunc(MaxElements.getBitWidth()); + DesignatedStartIndex + = DesignatedStartIndex.extOrTrunc(MaxElements.getBitWidth()); DesignatedStartIndex.setIsUnsigned(MaxElements.isUnsigned()); - DesignatedEndIndex.extOrTrunc(MaxElements.getBitWidth()); + DesignatedEndIndex + = DesignatedEndIndex.extOrTrunc(MaxElements.getBitWidth()); DesignatedEndIndex.setIsUnsigned(MaxElements.isUnsigned()); if (DesignatedEndIndex >= MaxElements) { SemaRef.Diag(IndexExpr->getSourceRange().getBegin(), @@ -1656,10 +1658,12 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, } else { // Make sure the bit-widths and signedness match. if (DesignatedStartIndex.getBitWidth() > DesignatedEndIndex.getBitWidth()) - DesignatedEndIndex.extend(DesignatedStartIndex.getBitWidth()); + DesignatedEndIndex + = DesignatedEndIndex.extend(DesignatedStartIndex.getBitWidth()); else if (DesignatedStartIndex.getBitWidth() < DesignatedEndIndex.getBitWidth()) - DesignatedStartIndex.extend(DesignatedEndIndex.getBitWidth()); + DesignatedStartIndex + = DesignatedStartIndex.extend(DesignatedEndIndex.getBitWidth()); DesignatedStartIndex.setIsUnsigned(true); DesignatedEndIndex.setIsUnsigned(true); } @@ -1911,9 +1915,9 @@ ExprResult Sema::ActOnDesignatedInitializer(Designation &Desig, if (StartDependent || EndDependent) { // Nothing to compute. } else if (StartValue.getBitWidth() > EndValue.getBitWidth()) - EndValue.extend(StartValue.getBitWidth()); + EndValue = EndValue.extend(StartValue.getBitWidth()); else if (StartValue.getBitWidth() < EndValue.getBitWidth()) - StartValue.extend(EndValue.getBitWidth()); + StartValue = StartValue.extend(EndValue.getBitWidth()); if (!StartDependent && !EndDependent && EndValue < StartValue) { Diag(D.getEllipsisLoc(), diag::err_array_designator_empty_range) 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); } diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 1a8c44a0e6..29f77f333d 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -3120,7 +3120,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, // based on the template parameter's type. unsigned AllowedBits = Context.getTypeSize(IntegerType); if (Value.getBitWidth() != AllowedBits) - Value.extOrTrunc(AllowedBits); + Value = Value.extOrTrunc(AllowedBits); Value.setIsSigned(IntegerType->isSignedIntegerType()); // Complain if an unsigned parameter received a negative value. diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 070c334f87..c14acd62fe 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -57,9 +57,9 @@ using namespace clang; /// necessary to compare their values regardless of underlying type. static bool hasSameExtendedValue(llvm::APSInt X, llvm::APSInt Y) { if (Y.getBitWidth() > X.getBitWidth()) - X.extend(Y.getBitWidth()); + X = X.extend(Y.getBitWidth()); else if (Y.getBitWidth() < X.getBitWidth()) - Y.extend(X.getBitWidth()); + Y = Y.extend(X.getBitWidth()); // If there is a signedness mismatch, correct it. if (X.isSigned() != Y.isSigned()) { |