Add a non-virtual test for zero, isZero, and rename isUnitValue isOne.
authorReid Spencer <rspencer@reidspencer.com>
Fri, 2 Mar 2007 00:27:06 +0000 (00:27 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Fri, 2 Mar 2007 00:27:06 +0000 (00:27 +0000)
These will be used in upcoming patches to avoid virtual function call when
the client knows it is a ConstantInt.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34820 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constants.h

index f17e02a4aa75ad576b2af4530c99f72275d340e2..988b53a284cc0d5c13f2bd5e1cf49ecb3460d1f9 100644 (file)
@@ -127,10 +127,18 @@ public:
     return Val == 0; 
   }
 
+  /// This is just a convenience method to make client code smaller for a
+  /// common code. It also correctly performs the comparison without the
+  /// potential for an assertion from getZExtValue().
+  bool isZero() const {
+    return Val == 0;
+  }
+
   /// This is just a convenience method to make client code smaller for a 
-  /// common case.
+  /// common case. It also correctly performs the comparison without the
+  /// potential for an assertion from getZExtValue().
   /// @brief Determine if the value is one.
-  bool isUnitValue() const {
+  bool isOne() const {
     return Val == 1;
   }