aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenTypes.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-01 02:36:43 +0000
committerChris Lattner <sabre@nondot.org>2009-04-01 02:36:43 +0000
commit285d0dba947b7c9960eaa88e8c4fced0398d4319 (patch)
tree7f13cbb8bfb8e2e4383952425543ff52ba31b252 /lib/CodeGen/CodeGenTypes.cpp
parent5ad0f6778556535dca448e9d82e674d2d255ad06 (diff)
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
Diffstat (limited to 'lib/CodeGen/CodeGenTypes.cpp')
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp34
1 files changed, 34 insertions, 0 deletions
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<ObjCInterfaceDecl*>(OID));
+ llvm::DenseMap<Type *, llvm::PATypeHolder>::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<llvm::OpaqueType>(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<llvm::OpaqueType>(NT) && "Didn't do layout!");
+
+ // FIXME: Remove this check when shadow structs go away.
+ if (isa<llvm::OpaqueType>(OpaqueHolder)) {
+
+ // Refine the old opaque type to its new definition.
+ cast<llvm::OpaqueType>(OpaqueHolder.get())->refineAbstractTypeTo(NT);
+ }
+}
+
+
static const llvm::Type* getTypeForFormat(const llvm::fltSemantics &format) {
if (&format == &llvm::APFloat::IEEEsingle)
return llvm::Type::FloatTy;