From 285d0dba947b7c9960eaa88e8c4fced0398d4319 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 1 Apr 2009 02:36:43 +0000 Subject: fix the two xfails I added with a previous patch by making ObjC interface types get completed when their definition is seen if previously laid out by the code generator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68177 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenTypes.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'lib/CodeGen/CodeGenTypes.cpp') diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index ff4b80f3b4..e13a4bc65d 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -197,6 +197,40 @@ void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) { } } +void CodeGenTypes::UpdateCompletedType(const ObjCInterfaceDecl *OID) { + // Check to see if we have already laid this type out, if not, just return. + QualType OIDTy = + Context.getObjCInterfaceType(const_cast(OID)); + llvm::DenseMap::iterator TCI = + TypeCache.find(OIDTy.getTypePtr()); + if (TCI == TypeCache.end()) return; + + // Remember the opaque LLVM type for this interface. + llvm::PATypeHolder OpaqueHolder = TCI->second; + assert(isa(OpaqueHolder.get()) && + "Updating compilation of an already non-opaque type?"); + + // Remove it from TagDeclTypes so that it will be regenerated. + TypeCache.erase(TCI); + + // Update the "shadow" struct that is laid out. + // FIXME: REMOVE THIS. + const RecordDecl *RD = Context.addRecordToClass(OID); + UpdateCompletedType(RD); + + // Generate the new type. + const llvm::Type *NT = ConvertType(OIDTy); + assert(!isa(NT) && "Didn't do layout!"); + + // FIXME: Remove this check when shadow structs go away. + if (isa(OpaqueHolder)) { + + // Refine the old opaque type to its new definition. + cast(OpaqueHolder.get())->refineAbstractTypeTo(NT); + } +} + + static const llvm::Type* getTypeForFormat(const llvm::fltSemantics &format) { if (&format == &llvm::APFloat::IEEEsingle) return llvm::Type::FloatTy; -- cgit v1.2.3-18-g5258