Fix bug: test/Regression/CBackend/2002-10-15-OpaqueTypeProblem.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4190 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index 4765f40..feaf135 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -196,12 +196,12 @@
}
// 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 @@
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();
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index 4765f40..feaf135 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -196,12 +196,12 @@
}
// 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 @@
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();