+// getAlwaysOpaqueTy - This function returns an opaque type. It doesn't matter
+// _which_ opaque type it is, but the opaque type must never get resolved.
+//
+static Type *getAlwaysOpaqueTy() {
+ static Type *AlwaysOpaqueTy = OpaqueType::get();
+ static PATypeHolder Holder(AlwaysOpaqueTy);
+ return AlwaysOpaqueTy;
+}
+
+
+//===----------------------------------------------------------------------===//
+// dropAllTypeUses methods - These methods eliminate any possibly recursive type
+// references from a derived type. The type must remain abstract, so we make
+// sure to use an always opaque type as an argument.
+//
+
+void FunctionType::dropAllTypeUses() {
+ ResultType = getAlwaysOpaqueTy();
+ ParamTys.clear();
+}
+
+void ArrayType::dropAllTypeUses() {
+ ElementType = getAlwaysOpaqueTy();
+}
+
+void StructType::dropAllTypeUses() {
+ ETypes.clear();
+ ETypes.push_back(PATypeHandle(getAlwaysOpaqueTy(), this));
+}
+
+void PointerType::dropAllTypeUses() {
+ ElementType = getAlwaysOpaqueTy();
+}
+
+
+
+