[llvm] r194928 - Annotate APInt methods where it's not clear whether they are in place with warn_unused_result.
Benjamin Kramer
benny.kra at googlemail.com
Sat Nov 16 08:25:41 PST 2013
Author: d0k
Date: Sat Nov 16 10:25:41 2013
New Revision: 194928
URL: http://llvm.org/viewvc/llvm-project?rev=194928&view=rev
Log:
Annotate APInt methods where it's not clear whether they are in place with warn_unused_result.
Fix ScalarEvolution bugs uncovered by this.
Modified:
llvm/trunk/include/llvm/ADT/APInt.h
llvm/trunk/include/llvm/ADT/APSInt.h
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=194928&r1=194927&r2=194928&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Sat Nov 16 10:25:41 2013
@@ -765,7 +765,9 @@ public:
return APInt(getBitWidth(), VAL & RHS.VAL);
return AndSlowCase(RHS);
}
- APInt And(const APInt &RHS) const { return this->operator&(RHS); }
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT And(const APInt &RHS) const {
+ return this->operator&(RHS);
+ }
/// \brief Bitwise OR operator.
///
@@ -785,7 +787,9 @@ public:
/// calling operator|.
///
/// \returns An APInt value representing the bitwise OR of *this and RHS.
- APInt Or(const APInt &RHS) const { return this->operator|(RHS); }
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT Or(const APInt &RHS) const {
+ return this->operator|(RHS);
+ }
/// \brief Bitwise XOR operator.
///
@@ -805,7 +809,9 @@ public:
/// through the usage of operator^.
///
/// \returns An APInt value representing the bitwise XOR of *this and RHS.
- APInt Xor(const APInt &RHS) const { return this->operator^(RHS); }
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT Xor(const APInt &RHS) const {
+ return this->operator^(RHS);
+ }
/// \brief Multiplication operator.
///
@@ -837,17 +843,17 @@ public:
/// \brief Arithmetic right-shift function.
///
/// Arithmetic right-shift this APInt by shiftAmt.
- APInt ashr(unsigned shiftAmt) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT ashr(unsigned shiftAmt) const;
/// \brief Logical right-shift function.
///
/// Logical right-shift this APInt by shiftAmt.
- APInt lshr(unsigned shiftAmt) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT lshr(unsigned shiftAmt) const;
/// \brief Left-shift function.
///
/// Left-shift this APInt by shiftAmt.
- APInt shl(unsigned shiftAmt) const {
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT shl(unsigned shiftAmt) const {
assert(shiftAmt <= BitWidth && "Invalid shift amount");
if (isSingleWord()) {
if (shiftAmt >= BitWidth)
@@ -858,31 +864,31 @@ public:
}
/// \brief Rotate left by rotateAmt.
- APInt rotl(unsigned rotateAmt) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT rotl(unsigned rotateAmt) const;
/// \brief Rotate right by rotateAmt.
- APInt rotr(unsigned rotateAmt) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT rotr(unsigned rotateAmt) const;
/// \brief Arithmetic right-shift function.
///
/// Arithmetic right-shift this APInt by shiftAmt.
- APInt ashr(const APInt &shiftAmt) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT ashr(const APInt &shiftAmt) const;
/// \brief Logical right-shift function.
///
/// Logical right-shift this APInt by shiftAmt.
- APInt lshr(const APInt &shiftAmt) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT lshr(const APInt &shiftAmt) const;
/// \brief Left-shift function.
///
/// Left-shift this APInt by shiftAmt.
- APInt shl(const APInt &shiftAmt) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT shl(const APInt &shiftAmt) const;
/// \brief Rotate left by rotateAmt.
- APInt rotl(const APInt &rotateAmt) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT rotl(const APInt &rotateAmt) const;
/// \brief Rotate right by rotateAmt.
- APInt rotr(const APInt &rotateAmt) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT rotr(const APInt &rotateAmt) const;
/// \brief Unsigned division operation.
///
@@ -890,12 +896,12 @@ public:
/// RHS are treated as unsigned quantities for purposes of this division.
///
/// \returns a new APInt value containing the division result
- APInt udiv(const APInt &RHS) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT udiv(const APInt &RHS) const;
/// \brief Signed division function for APInt.
///
/// Signed divide this APInt by APInt RHS.
- APInt sdiv(const APInt &RHS) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT sdiv(const APInt &RHS) const;
/// \brief Unsigned remainder operation.
///
@@ -906,12 +912,12 @@ public:
/// is *this.
///
/// \returns a new APInt value containing the remainder result
- APInt urem(const APInt &RHS) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT urem(const APInt &RHS) const;
/// \brief Function for signed remainder operation.
///
/// Signed remainder operation on APInt.
- APInt srem(const APInt &RHS) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT srem(const APInt &RHS) const;
/// \brief Dual division/remainder interface.
///
@@ -1145,7 +1151,7 @@ public:
///
/// Truncate the APInt to a specified width. It is an error to specify a width
/// that is greater than or equal to the current width.
- APInt trunc(unsigned width) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT trunc(unsigned width) const;
/// \brief Sign extend to a new width.
///
@@ -1153,38 +1159,38 @@ public:
/// bit is set, the fill on the left will be done with 1 bits, otherwise zero.
/// It is an error to specify a width that is less than or equal to the
/// current width.
- APInt sext(unsigned width) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT sext(unsigned width) const;
/// \brief Zero extend to a new width.
///
/// This operation zero extends the APInt to a new width. The high order bits
/// are filled with 0 bits. It is an error to specify a width that is less
/// than or equal to the current width.
- APInt zext(unsigned width) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT zext(unsigned width) const;
/// \brief Sign extend or truncate to width
///
/// Make this APInt have the bit width given by \p width. The value is sign
/// extended, truncated, or left alone to make it that width.
- APInt sextOrTrunc(unsigned width) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT sextOrTrunc(unsigned width) const;
/// \brief Zero extend or truncate to width
///
/// Make this APInt have the bit width given by \p width. The value is zero
/// extended, truncated, or left alone to make it that width.
- APInt zextOrTrunc(unsigned width) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT zextOrTrunc(unsigned width) const;
/// \brief Sign extend or truncate to width
///
/// Make this APInt have the bit width given by \p width. The value is sign
/// extended, or left alone to make it that width.
- APInt sextOrSelf(unsigned width) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT sextOrSelf(unsigned width) const;
/// \brief Zero extend or truncate to width
///
/// Make this APInt have the bit width given by \p width. The value is zero
/// extended, or left alone to make it that width.
- APInt zextOrSelf(unsigned width) const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT zextOrSelf(unsigned width) const;
/// @}
/// \name Bit Manipulation Operators
@@ -1421,7 +1427,7 @@ public:
std::string toString(unsigned Radix, bool Signed) const;
/// \returns a byte-swapped representation of this APInt Value.
- APInt byteSwap() const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT byteSwap() const;
/// \brief Converts this APInt to a double value.
double roundToDouble(bool isSigned) const;
@@ -1464,7 +1470,7 @@ public:
///
/// The conversion does not do a translation from double to integer, it just
/// re-interprets the bits of the double.
- static APInt doubleToBits(double V) {
+ static APInt LLVM_ATTRIBUTE_UNUSED_RESULT doubleToBits(double V) {
union {
uint64_t I;
double D;
@@ -1477,7 +1483,7 @@ public:
///
/// The conversion does not do a translation from float to integer, it just
/// re-interprets the bits of the float.
- static APInt floatToBits(float V) {
+ static APInt LLVM_ATTRIBUTE_UNUSED_RESULT floatToBits(float V) {
union {
unsigned I;
float F;
@@ -1507,12 +1513,12 @@ public:
}
/// \brief Compute the square root
- APInt sqrt() const;
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT sqrt() const;
/// \brief Get the absolute value;
///
/// If *this is < 0 then return -(*this), otherwise *this;
- APInt abs() const {
+ APInt LLVM_ATTRIBUTE_UNUSED_RESULT abs() const {
if (isNegative())
return -(*this);
return *this;
Modified: llvm/trunk/include/llvm/ADT/APSInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APSInt.h?rev=194928&r1=194927&r2=194928&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APSInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APSInt.h Sat Nov 16 10:25:41 2013
@@ -68,18 +68,18 @@ public:
}
using APInt::toString;
- APSInt trunc(uint32_t width) const {
+ APSInt LLVM_ATTRIBUTE_UNUSED_RESULT trunc(uint32_t width) const {
return APSInt(APInt::trunc(width), IsUnsigned);
}
- APSInt extend(uint32_t width) const {
+ APSInt LLVM_ATTRIBUTE_UNUSED_RESULT extend(uint32_t width) const {
if (IsUnsigned)
return APSInt(zext(width), IsUnsigned);
else
return APSInt(sext(width), IsUnsigned);
}
- APSInt extOrTrunc(uint32_t width) const {
+ APSInt LLVM_ATTRIBUTE_UNUSED_RESULT extOrTrunc(uint32_t width) const {
if (IsUnsigned)
return APSInt(zextOrTrunc(width), IsUnsigned);
else
@@ -212,7 +212,7 @@ public:
assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!");
return APSInt(static_cast<const APInt&>(*this) & RHS, IsUnsigned);
}
- APSInt And(const APSInt& RHS) const {
+ APSInt LLVM_ATTRIBUTE_UNUSED_RESULT And(const APSInt& RHS) const {
return this->operator&(RHS);
}
@@ -220,7 +220,7 @@ public:
assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!");
return APSInt(static_cast<const APInt&>(*this) | RHS, IsUnsigned);
}
- APSInt Or(const APSInt& RHS) const {
+ APSInt LLVM_ATTRIBUTE_UNUSED_RESULT Or(const APSInt& RHS) const {
return this->operator|(RHS);
}
@@ -229,7 +229,7 @@ public:
assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!");
return APSInt(static_cast<const APInt&>(*this) ^ RHS, IsUnsigned);
}
- APSInt Xor(const APSInt& RHS) const {
+ APSInt LLVM_ATTRIBUTE_UNUSED_RESULT Xor(const APSInt& RHS) const {
return this->operator^(RHS);
}
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=194928&r1=194927&r2=194928&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Sat Nov 16 10:25:41 2013
@@ -6684,9 +6684,9 @@ static const APInt gcd(const SCEVConstan
uint32_t BBW = B.getBitWidth();
if (ABW > BBW)
- B.zext(ABW);
+ B = B.zext(ABW);
else if (ABW < BBW)
- A.zext(BBW);
+ A = A.zext(BBW);
return APIntOps::GreatestCommonDivisor(A, B);
}
@@ -6698,9 +6698,9 @@ static const APInt srem(const SCEVConsta
uint32_t BBW = B.getBitWidth();
if (ABW > BBW)
- B.sext(ABW);
+ B = B.sext(ABW);
else if (ABW < BBW)
- A.sext(BBW);
+ A = A.sext(BBW);
return APIntOps::srem(A, B);
}
@@ -6712,9 +6712,9 @@ static const APInt sdiv(const SCEVConsta
uint32_t BBW = B.getBitWidth();
if (ABW > BBW)
- B.sext(ABW);
+ B = B.sext(ABW);
else if (ABW < BBW)
- A.sext(BBW);
+ A = A.sext(BBW);
return APIntOps::sdiv(A, B);
}
More information about the llvm-commits
mailing list