From: Reid Spencer Date: Thu, 1 Mar 2007 21:50:41 +0000 (+0000) Subject: Add an isUnitValue method for comparison against 1. This just follows a X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=37eeaa729bc70258166a675ee00bbe95e608d519;p=oota-llvm.git 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 --- diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 21d9dca7a7e..7257d2645a7 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.