aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Constants.h
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-12-19 01:28:19 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-12-19 01:28:19 +0000
commit9b11d518aef8e191e5e94f3503dfddbe1c0a387a (patch)
treebabef79a0da1ddc44e5918da55b590b90ee88038 /include/llvm/Constants.h
parent75de5ab9f58b84aa99c2a9133572ce1d997ec1a8 (diff)
downloadexternal_llvm-9b11d518aef8e191e5e94f3503dfddbe1c0a387a.zip
external_llvm-9b11d518aef8e191e5e94f3503dfddbe1c0a387a.tar.gz
external_llvm-9b11d518aef8e191e5e94f3503dfddbe1c0a387a.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32663 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Constants.h')
-rw-r--r--include/llvm/Constants.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 36d8299..5e46344 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -181,9 +181,12 @@ public:
/// 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 @@ public:
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 @@ public:
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;
}