diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-01 21:50:41 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-01 21:50:41 +0000 |
commit | 37eeaa729bc70258166a675ee00bbe95e608d519 (patch) | |
tree | 8ac8010fd61c596b62e2f9adf22ddde53b51cb9f | |
parent | c100b96b1536ef92cadac28bd268da105a67d4a0 (diff) |
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
-rw-r--r-- | include/llvm/Constants.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 21d9dca7a7..7257d2645a 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -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. |