diff options
author | Chris Lattner <sabre@nondot.org> | 2003-09-05 02:30:47 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-09-05 02:30:47 +0000 |
commit | 266caa2c3dc56cb0c7c8dc8479a7f462cca603fa (patch) | |
tree | 068774546f90769669b6824aadaa9a6b2d1c21b3 | |
parent | b1678c61326feeb17712c4a0a5e68a382795ca6b (diff) |
Refactor what has effectively become copy-and-pasted code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8357 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Type.cpp | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 6a9bef21f1..d8ec500a4a 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -503,6 +503,7 @@ public: return I; } + // containsEquivalent - Return true if the typemap contains a type that is // structurally equivalent to the specified type. // @@ -519,6 +520,18 @@ public: return 0; } + void finishRefinement(TypeClass *Ty) { + if (TypeClass *NewTy = containsEquivalent(Ty)) { + // Refined to a different type altogether? + Ty->refineAbstractTypeToInternal(NewTy, false); + } else { + // If the type is currently thought to be abstract, rescan all of our + // subtypes to see if the type has just become concrete! + if (Ty->isAbstract()) Ty->setAbstract(Ty->isTypeAbstract()); + Ty->typeIsRefined(); // Same type, different contents... + } + } + // refineAbstractType - This is called when one of the contained abstract // types gets refined... this simply removes the abstract type from our table. // We expect that whoever refined the type will add it back to the table, @@ -1181,14 +1194,7 @@ void FunctionType::refineAbstractType(const DerivedType *OldType, ParamTys[i] = NewType; } - if (const FunctionType *MT = FunctionTypes.containsEquivalent(this)) { - refineAbstractTypeToInternal(MT, false); // Different type altogether... - } else { - // If the type is currently thought to be abstract, rescan all of our - // subtypes to see if the type has just become concrete! - if (isAbstract()) setAbstract(isTypeAbstract()); - typeIsRefined(); // Same type, different contents... - } + FunctionTypes.finishRefinement(this); } @@ -1215,14 +1221,7 @@ void ArrayType::refineAbstractType(const DerivedType *OldType, ElementType.removeUserFromConcrete(); ElementType = NewType; - if (const ArrayType *AT = ArrayTypes.containsEquivalent(this)) { - refineAbstractTypeToInternal(AT, false); // Different type altogether... - } else { - // If the type is currently thought to be abstract, rescan all of our - // subtypes to see if the type has just become concrete! - if (isAbstract()) setAbstract(isTypeAbstract()); - typeIsRefined(); // Same type, different contents... - } + ArrayTypes.finishRefinement(this); } @@ -1253,14 +1252,7 @@ void StructType::refineAbstractType(const DerivedType *OldType, ETypes[i] = NewType; } - if (const StructType *ST = StructTypes.containsEquivalent(this)) { - refineAbstractTypeToInternal(ST, false); // Different type altogether... - } else { - // If the type is currently thought to be abstract, rescan all of our - // subtypes to see if the type has just become concrete! - if (isAbstract()) setAbstract(isTypeAbstract()); - typeIsRefined(); // Same type, different contents... - } + StructTypes.finishRefinement(this); } // refineAbstractType - Called when a contained type is found to be more @@ -1286,13 +1278,6 @@ void PointerType::refineAbstractType(const DerivedType *OldType, ElementType.removeUserFromConcrete(); ElementType = NewType; - if (const PointerType *PT = PointerTypes.containsEquivalent(this)) { - refineAbstractTypeToInternal(PT, false); // Different type altogether... - } else { - // If the type is currently thought to be abstract, rescan all of our - // subtypes to see if the type has just become concrete! - if (isAbstract()) setAbstract(isTypeAbstract()); - typeIsRefined(); // Same type, different contents... - } + PointerTypes.finishRefinement(this); } |