Further simplifications
authorChris Lattner <sabre@nondot.org>
Tue, 2 Sep 2003 16:46:41 +0000 (16:46 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 2 Sep 2003 16:46:41 +0000 (16:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8321 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Type.cpp

index 8f397cba3068f90086d5346bf39691401cc0969e..4d838e2151d27cfd96cd85bd3a88c602685adad5 100644 (file)
@@ -402,52 +402,19 @@ static void getTypeProps(const Type *Ty, std::vector<const Type *> &TypeStack,
   }
 
   // Check to see if the Type is already on the stack...
-  unsigned Slot = 0, CurSize = TypeStack.size();
-  while (Slot < CurSize && TypeStack[Slot] != Ty) ++Slot; // Scan for type
-    
-  // This is another base case for the recursion.  In this case, we know 
-  // that we have looped back to a type that we have previously visited.
-  // Generate the appropriate upreference to handle this.
-  // 
-  if (Slot < CurSize) {
-    isRecursive = true;                         // We know we are recursive
-    return;
-  }
+  for (unsigned Slot = 0; Slot != TypeStack.size(); ++Slot)
+    if (TypeStack[Slot] == Ty) { // Scan for type
+      isRecursive = true;                         // We know we are recursive
+      return;
+    }
 
   // Recursive case: derived type...
   TypeStack.push_back(Ty);    // Add us to the stack..
-      
-  switch (Ty->getPrimitiveID()) {
-  case Type::FunctionTyID: {
-    const FunctionType *FTy = cast<FunctionType>(Ty);
-    getTypeProps(FTy->getReturnType(), TypeStack, isAbstract, isRecursive);
-    for (FunctionType::ParamTypes::const_iterator
-           I = FTy->getParamTypes().begin(),
-           E = FTy->getParamTypes().end(); I != E; ++I)
-      getTypeProps(*I, TypeStack, isAbstract, isRecursive);
-    break;
-  }
-  case Type::StructTyID: {
-    const StructType *STy = cast<StructType>(Ty);
-    for (StructType::ElementTypes::const_iterator
-           I = STy->getElementTypes().begin(),
-           E = STy->getElementTypes().end(); I != E; ++I)
-      getTypeProps(*I, TypeStack, isAbstract, isRecursive);
-    break;
-  }
-  case Type::PointerTyID: {
-    const PointerType *PTy = cast<PointerType>(Ty);
-    getTypeProps(PTy->getElementType(), TypeStack, isAbstract, isRecursive);
-    break;
-  }
-  case Type::ArrayTyID:
-    getTypeProps(cast<ArrayType>(Ty)->getElementType(), TypeStack,
-                 isAbstract, isRecursive);
-    break;
-  default:
-    assert(0 && "Unhandled type in getTypeProps!");
-  }
 
+  for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end();
+       I != E; ++I)
+    getTypeProps(*I, TypeStack, isAbstract, isRecursive);
+      
   TypeStack.pop_back();       // Remove self from stack...
 }