From 28977af72a11fcad5d1b54d7a96b3df02828f6fc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 5 Apr 2004 01:30:19 +0000 Subject: 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 --- lib/VMCore/Type.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/VMCore/Type.cpp') 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(V)) - return CU->getValue() < ContainedTys.size(); + if (V->getType() == Type::UIntTy) + if (const ConstantUInt *CU = dyn_cast(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(V) && "Structure index must be a constant!!"); + assert(indexValid(V) && "Invalid structure index!"); unsigned Idx = cast(V)->getValue(); - assert(Idx < ContainedTys.size() && "Structure index out of range!"); - assert(indexValid(V) && "Invalid structure index!"); // Duplicate check return ContainedTys[Idx]; } -- cgit v1.1