diff options
Diffstat (limited to 'lib/VMCore/Type.cpp')
-rw-r--r-- | lib/VMCore/Type.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 1e2d741edf..b7d7181240 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]; } |