[llvm-commits] CVS: llvm/include/llvm/Constants.h

Reid Spencer reid at x10sys.com
Mon Dec 18 17:28:37 PST 2006



Changes in directory llvm/include/llvm:

Constants.h updated: 1.109 -> 1.110
---
Log message:

Make ConstantInt not care about sign any more. To ensure the AsmParser can
still check the validity of signed values an overload to isValueValidForType
was added to allow passing in an int64_t to check.


---
Diffs of the changes:  (+6 -3)

 Constants.h |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.109 llvm/include/llvm/Constants.h:1.110
--- llvm/include/llvm/Constants.h:1.109	Mon Dec 18 02:18:46 2006
+++ llvm/include/llvm/Constants.h	Mon Dec 18 19:28:19 2006
@@ -181,9 +181,12 @@
 
   /// This static method returns true if the type Ty is big enough to 
   /// represent the value V. This can be used to avoid having the get method 
-  /// assert when V is larger than Ty can represent.
+  /// assert when V is larger than Ty can represent. Note that values are
+  /// always treated as unsigned so if the intention is to represent a signed
+  /// type, you must do the conversion first.
   /// @returns true if V is a valid value for type Ty
   /// @brief Determine if the value is in range for the given type.
+  static bool isValueValidForType(const Type *Ty, uint64_t V);
   static bool isValueValidForType(const Type *Ty, int64_t V);
 
   /// @returns true if this is the null integer value.
@@ -205,7 +208,7 @@
       int64_t V = getSExtValue();
       if (V < 0) return false;    // Be careful about wrap-around on 'long's
       ++V;
-      return !isValueValidForType(getType()->getSignedVersion(), V) || V < 0;
+      return !isValueValidForType(getType(), V) || V < 0;
     }
     return isAllOnesValue();
   }
@@ -219,7 +222,7 @@
       int64_t V = getSExtValue();
       if (V > 0) return false;    // Be careful about wrap-around on 'long's
       --V;
-      return !isValueValidForType(getType()->getSignedVersion(), V) || V > 0;
+      return !isValueValidForType(getType(), V) || V > 0;
     }
     return getZExtValue() == 0;
   }






More information about the llvm-commits mailing list