Fix bug: test/Regression/CBackend/2002-10-15-OpaqueTypeProblem.ll
authorChris Lattner <sabre@nondot.org>
Wed, 16 Oct 2002 00:08:22 +0000 (00:08 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 16 Oct 2002 00:08:22 +0000 (00:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4190 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp

index 4765f409e20176d177613bd18370a56a804b0ba7..feaf1352695d0b50f965e58d3d93f4956768be07 100644 (file)
@@ -196,12 +196,12 @@ ostream &CWriter::printType(const Type *Ty, const string &NameSoFar,
     }
   
   // Check to see if the type is named.
-  if (!IgnoreName) {
+  if (!IgnoreName || isa<OpaqueType>(Ty)) {
     map<const Type *, string>::iterator I = TypeNames.find(Ty);
     if (I != TypeNames.end()) {
       return Out << I->second << " " << NameSoFar;
     }
-  }  
+  }
 
   switch (Ty->getPrimitiveID()) {
   case Type::FunctionTyID: {
@@ -257,6 +257,14 @@ ostream &CWriter::printType(const Type *Ty, const string &NameSoFar,
     return printType(ATy->getElementType(),
                      NameSoFar + "[" + utostr(NumElements) + "]");
   }
+
+  case Type::OpaqueTyID: {
+    static int Count = 0;
+    string TyName = "struct opaque_" + itostr(Count++);
+    assert(TypeNames.find(Ty) == TypeNames.end());
+    TypeNames[Ty] = TyName;
+    return Out << TyName << " " << NameSoFar;
+  }
   default:
     assert(0 && "Unhandled case in getTypeProps!");
     abort();
index 4765f409e20176d177613bd18370a56a804b0ba7..feaf1352695d0b50f965e58d3d93f4956768be07 100644 (file)
@@ -196,12 +196,12 @@ ostream &CWriter::printType(const Type *Ty, const string &NameSoFar,
     }
   
   // Check to see if the type is named.
-  if (!IgnoreName) {
+  if (!IgnoreName || isa<OpaqueType>(Ty)) {
     map<const Type *, string>::iterator I = TypeNames.find(Ty);
     if (I != TypeNames.end()) {
       return Out << I->second << " " << NameSoFar;
     }
-  }  
+  }
 
   switch (Ty->getPrimitiveID()) {
   case Type::FunctionTyID: {
@@ -257,6 +257,14 @@ ostream &CWriter::printType(const Type *Ty, const string &NameSoFar,
     return printType(ATy->getElementType(),
                      NameSoFar + "[" + utostr(NumElements) + "]");
   }
+
+  case Type::OpaqueTyID: {
+    static int Count = 0;
+    string TyName = "struct opaque_" + itostr(Count++);
+    assert(TypeNames.find(Ty) == TypeNames.end());
+    TypeNames[Ty] = TyName;
+    return Out << TyName << " " << NameSoFar;
+  }
   default:
     assert(0 && "Unhandled case in getTypeProps!");
     abort();