Make sure this method just return value equal or less than Limit.
authorZhou Sheng <zhousheng00@gmail.com>
Fri, 30 Mar 2007 16:50:28 +0000 (16:50 +0000)
committerZhou Sheng <zhousheng00@gmail.com>
Fri, 30 Mar 2007 16:50:28 +0000 (16:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35509 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constants.h

index e7020d3699803d8f328b5a4751276a6997c9b244..a36ac6e74749adfef3ad922937d6ee1a72244509 100644 (file)
@@ -187,7 +187,8 @@ public:
   /// not greater than 64, otherwise, just return the given uint64_t number.
   /// @brief Get the constant's value if possible.
   uint64_t getLimitedValue(uint64_t Limit) {
-    return (Val.getActiveBits() > 64) ? Limit : Val.getZExtValue();
+    return (Val.getActiveBits() > 64 || Val.getZExtValue() > Limit) ? 
+           Limit : Val.getZExtValue();
   }
 
   /// @returns the value for an integer constant of the given type that has all