Minor style cleanups
authorChris Lattner <sabre@nondot.org>
Tue, 13 Nov 2001 04:59:58 +0000 (04:59 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 13 Nov 2001 04:59:58 +0000 (04:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1287 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/iMemory.cpp

index cc24ca144120ec8162dd8e250f2ab41180c6e7fd..e980d600d466976911de33a0c3f85538fd53d164 100644 (file)
@@ -27,13 +27,12 @@ const Type* MemAccessInst::getIndexedType(const Type *Ptr,
   
   if (Ptr->isStructType()) {
     unsigned CurIDX = 0;
-    while (Ptr->isStructType()) {
+    while (const StructType *ST = dyn_cast<StructType>(Ptr)) {
       if (Idx.size() == CurIDX) 
        return AllowStructLeaf ? Ptr : 0;   // Can't load a whole structure!?!?
       if (Idx[CurIDX]->getType() != Type::UByteTy) return 0; // Illegal idx
       unsigned NextIdx = ((ConstPoolUInt*)Idx[CurIDX++])->getValue();
-      
-      const StructType *ST = (const StructType *)Ptr;
+      if (NextIdx >= ST->getElementTypes().size()) return 0;
       Ptr = ST->getElementTypes()[NextIdx];
     }
     return Ptr;