From 04b72c821e616c017d5c198487621d8be281f2d4 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 16 Oct 2002 00:08:22 +0000 Subject: [PATCH] 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 --- lib/Target/CBackend/CBackend.cpp | 12 ++++++++++-- lib/Target/CBackend/Writer.cpp | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 4765f409e20..feaf1352695 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -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(Ty)) { map::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(); diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 4765f409e20..feaf1352695 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -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(Ty)) { map::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(); -- 2.34.1