From 7ba77f2a63a60d66c81ecbe8f8ee983030a42074 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 2 Sep 2003 16:46:41 +0000 Subject: [PATCH] Further simplifications git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8321 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Type.cpp | 51 ++++++++------------------------------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 8f397cba306..4d838e2151d 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -402,52 +402,19 @@ static void getTypeProps(const Type *Ty, std::vector &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(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(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(Ty); - getTypeProps(PTy->getElementType(), TypeStack, isAbstract, isRecursive); - break; - } - case Type::ArrayTyID: - getTypeProps(cast(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... }