Add an isUnitValue method for comparison against 1. This just follows a

common pattern with isNullValue, isAllOnesValue, etc. It also helps to
prevent things like getZExtValue() == 1, which could assert for large
bitwidths.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34813 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2007-03-01 21:50:41 +00:00
parent c100b96b15
commit 37eeaa729b

View File

@ -127,6 +127,13 @@ public:
return Val == 0;
}
/// This is just a convenience method to make client code smaller for a
/// common case.
/// @brief Determine if the value is one.
virtual bool isUnitValue() const {
return Val == 1;
}
/// This function will return true iff every bit in this constant is set
/// to true.
/// @returns true iff this constant's bits are all set to true.