aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Type.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-05 01:30:19 +0000
committerChris Lattner <sabre@nondot.org>2004-04-05 01:30:19 +0000
commit28977af72a11fcad5d1b54d7a96b3df02828f6fc (patch)
tree671a8fa4df839cb653ebd22dda8fa39639b3afa7 /lib/VMCore/Type.cpp
parent830b6f98686f40f86811dceb5497433ebac385e1 (diff)
downloadexternal_llvm-28977af72a11fcad5d1b54d7a96b3df02828f6fc.zip
external_llvm-28977af72a11fcad5d1b54d7a96b3df02828f6fc.tar.gz
external_llvm-28977af72a11fcad5d1b54d7a96b3df02828f6fc.tar.bz2
Support getelementptr instructions which use uint's to index into structure
types and can have arbitrary 32- and 64-bit integer types indexing into sequential types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12653 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Type.cpp')
-rw-r--r--lib/VMCore/Type.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index 1e2d741..b7d7181 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -295,8 +295,9 @@ const std::string &Type::getDescription() const {
bool StructType::indexValid(const Value *V) const {
// Structure indexes require unsigned integer constants.
- if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(V))
- return CU->getValue() < ContainedTys.size();
+ if (V->getType() == Type::UIntTy)
+ if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(V))
+ return CU->getValue() < ContainedTys.size();
return false;
}
@@ -304,10 +305,8 @@ bool StructType::indexValid(const Value *V) const {
// element. For a structure type, this must be a constant value...
//
const Type *StructType::getTypeAtIndex(const Value *V) const {
- assert(isa<Constant>(V) && "Structure index must be a constant!!");
+ assert(indexValid(V) && "Invalid structure index!");
unsigned Idx = cast<ConstantUInt>(V)->getValue();
- assert(Idx < ContainedTys.size() && "Structure index out of range!");
- assert(indexValid(V) && "Invalid structure index!"); // Duplicate check
return ContainedTys[Idx];
}